开发者

D3DImage leaks?

开发者 https://www.devze.com 2023-03-16 17:48 出处:网络
I am using D3DImage with SlimDX. I have created a class called D3DImageSource which inherits D3DImage and creates a SlimDX.D3D9.Surface in it\'s ctor. The surface is assigned to the D3DImage in the

I am using D3DImage with SlimDX.

I have created a class called D3DImageSource which inherits D3DImage and creates a SlimDX.D3D9.Surface in it's ctor. The surface is assigned to the D3DImage in the ctor as well.

D3DImageSource implements IDisposable and disposes the internal Surface when c开发者_如何学Goalled.

Whenever I resize my WPF window I create a new D3DImageSource with the new size of the window, and disposes the old one. Even though I dispose the internal surface at this time it still eats A LOT of memory. It seems like D3DImage holds some internal buffer that is not released properly, and there seems to be no Dispose method in D3DImage either.

Has anyone else experienced anything like this?

I'm running Win7x64, VS2010, .NET4, SlimDX x86.


I haven't used SlimDX, but I have used D3DImageSource with a managed Direct3D wrapper, and when I change surfaces I tell D3DImageSource to let go of the original surface by doing the following

d3dImageSource.Lock()
d3dImageSource.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero)
d3dImageSource.Unlock()

If you don't have this already, you probably want it in your dispose method.

Also, just a heads up. I don't believe you need to reallocate the image source every time the size changes. On a size change, you can just change the backbuffer surface to the new surface with the updated size. Of course if you choose to do it this way, you still need to first release the old surface with the code above.

0

精彩评论

暂无评论...
验证码 换一张
取 消