SlimDX: Disposing objects

Started by
4 comments, last by qingrui 16 years, 4 months ago
Hi again. I was wondering if you'd recommend that most of the objects from SlimDX gets Disposed manually when you are done with them or just let the GC collect the memory when it feels like it. I think of objects such as SlimDX.Direct3D9.Mesh, VertexBuffer etc. Do people use these objects for large scale programs, or is manually handling of VertexBuffers and Meshes etc. more common? Also, what is the reason for Dispose not showing up with intellisense(MSVC#08 EE)? The Disposed property does. Thanks in advance.
Advertisement
Quote:
I was wondering if you'd recommend that most of the objects from SlimDX gets Disposed manually when you are done with them or just let the GC collect the memory when it feels like it.

You should dispose of them when you are finished with them.

Quote:
Also, what is the reason for Dispose not showing up with intellisense(MSVC#08 EE)? The Disposed property does.

Mike and Promit have both worked on that issue, so they might be able to comment with more authority. However, the last I heard of the discussion about the problem is that intellisense isn't picking up the members of the generalized base class we use for most objects because that class is a template. We had a workaround in place to fix the issue, but it turned out not to work in all cases. I believe the code in SVN has a newer fix.
Yes indeed, a complete fix has been implemented and is in the repository. I suggest always working with the most recent commit as we make a staggering number of enhancements, fixes, and improvements between official releases.

Also, to comment on your first issue, you should indeed Dispose every object. If you do not, you *will* leak memory. The garbage collector will not take care of it for you, because the objects refer to unmanaged DirectX objects. When you run in debug build, take a look at your Output Window, which will contain the output from our custom object tracker. If you have forgotten to call dispose on any objects, they will be detailed in the output window.
Mike Popoloski | Journal | SlimDX
Thanks for the answers. I will get to use the latest commit from now on.

Only one question is now left unanswered, which is more likely a general DX questions. I'll repeat: "Do people use these objects for large scale programs, or is manually handling of VertexBuffers and Meshes etc. more common?". I'm used to OGL where no such things are apparent.

Thanks so far, and I really believe that it is a great project you guys work on. I'm learning DirectX through SlimDX and I do not seem to have any problems. I even got NVidia PerfHUD working just fine. Thumbs up!
People do create their own mesh objects, although many people still prefer to use the DirectX provided mesh support. I couldn't comment on the exact number of people that use either method, but both are viable options.

On the other hand, VertexBuffer objects are essential for efficient rendering. Large scale projects most certainly make use of them.
Mike Popoloski | Journal | SlimDX
The DX Mesh object is not harmful. Write your own if you can do it better; or simply use it to save your time. I saw even 3DSMAX use it in some version, not sure for now...

This topic is closed to new replies.

Advertisement