Sign in to follow this  
Alexander Dronov

[SlimDX]Direct3D and VertexBuffer objects were not disposed ...

Recommended Posts

After my form closed, I get following error message in output window. Direct3D object was not disposed. Object of type SlimDX.Direct3D9.VertexBuffer was not disposed. ... same ... same Total of 1006 objects still alive. Can you give me an example, in what order should I dispose objects ?

Share this post


Link to post
Share on other sites
My question is, are you disposing of them at all?

You must explicitly call Dispose() on each one of your COMObjects.

Share this post


Link to post
Share on other sites
Quote:

My question is, are you disposing of them at all?


No, Before yesterday (day) I didn't dispose any objects. I accidentally found out that error only yesterday (day).

Quote:
You must explicitly call Dispose() on each one of your COMObjects.


Ok, I have a code:


Device _device;
Direct3D _direct3d;

...
_direct3d = new Direct3D();

_device = new Device(_direct3d, 0, DeviceType.Reference, IntPtr.Zero, CreateFlags.SoftwareVertexProcessing, present_params);


In which order should I dispose that objects:

_direct3d.Dispose();
_device.Dispose();

or

_device.Dispose();
_direct3d.Dispose();

Or it doesn't matter ?

Share this post


Link to post
Share on other sites
Quote:
Original post by Alexander Dronov
In which order should I dispose that objects:

_direct3d.Dispose();
_device.Dispose();

or

_device.Dispose();
_direct3d.Dispose();

Or it doesn't matter ?
It doesn't matter, although best practice is to dispose them in the reverse order they were created in (So the device, then the D3D interface).

It's more likely that you're not disposing an interface somewhere. Has this problem only recently shown up? If so, it'll be a problem in the code you've recently added.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this