• Advertisement
Sign in to follow this  

immediate disposing of swapchains

This topic is 3840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi - ok, this is yet another "I'm doing swap-chains but they bug on me"-thread. I'm really in a mess here, so I hope someone can help me out. C#/Managed DirectX btw. [question] The swapchains implementation described below works like a charm... unless I'm low on memory. I use a viewarea of 1920x1200x4multisamples without problems. This is something like 73MB including depth-stencil - the cards I'm testing on has 256MB. When splitting the view into two separate views (swapchains), I often get an OutOfMemory-exception. I suspect this is due to the surfaces not being deallocated until later, making the program run out of memory due to double allocation. So finally: Is there anything I can do to force immediate deallocation? If not, am I doing something wrong to make it allocate too much memory? [method-outline] So basically I have everything working - swapchains are used for drawing to multiple controls. I create and use separate color- and depth-surfaces for each swapchain, and switch rendertargets/depth-surfaces manually. I switch off IsUsingEventHandlers when I create the surfaces, and manually dispose of them before creating new ones. I also call releasegraphics/dispose on the depth/color-surfaces whenever I stop rendering to them (apparently it's necessary to unhook events - doesn't crash the program anyway). The relevant part of the code can be found here: http://rafb.net/p/2F83qK72.html Cheers,

Share this post


Link to post
Share on other sites
Advertisement
I guess a simpler questions is: What is the command with least performance-penalty that will flush the d3d-command-buffer?
(unfortunately I'm not using d3d10, where I would be able to call device.flush)

Share this post


Link to post
Share on other sites
Deterministic Finalization in C#?
1) Look at the using construct
e.g.

using(Surface surface = new Surface())
{
//use the surface here
}


2) Disposal pattern
Disposal Pattern link
That's the only advice I can give you...
I hope this helps.

Share this post


Link to post
Share on other sites
The disposal pattern is how managed-d3d is structured to do the deallocation of surfaces - and hence, how I'm currently doing it. I'm explicitly calling dispose() though, as the allocation/deallocation are in separate functions.

My question, I believe, is not directly connected to c#-garbage-collection - I've come to the conclusion that it has to do with the d3d-command-buffer not being flushed until I call swapchain.present (which is after the allocation of the new buffer, hence I have a time-interval with double-memory allocated).

Some commands, e.g. present and occlusion-queries, force a flush of the command-buffer. I'm hoping for an extremely lightweight d3d-command that will force this flush, which in turn hopefully will force deallocation.

[Edited by - gjoel on July 18, 2007 9:23:22 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement