Sign in to follow this  

SlimDX: Disposing objects

This topic is 3628 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 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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

This topic is 3628 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.

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