1
Vote

Memory leak when using rendertargets

description

It can be seen in the sample Projects that use render targets.
Whenever the graphicsDevice changes the rendertarget because of a different resolution between the rendertargets, it creates a depthStencilBuffer and doesn't dispose the old one.
I would also expect it to create the depthStencilBuffers per RenderTarget and not for every RenderTarget switch.

I suggest to move the depthStencilBuffers into the renderTargets and only apply them on the graphicsDevice if a new renderTarget is set. The DepthStencilBuffer for the null RenderTarget should only be recreated if the resolution or format for the backbuffer changes.

I also once had an AccessViolationException when running the MultiRenderTarget example, but it's hard to replicate.

comments