• Advertisement
Sign in to follow this  

Do Direct3D objects automatically have Release called from their destructor?

This topic is 1770 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

I am saying this, because I use a wrapper class that in its destructor deletes its content and I'm using it for many kinds of objects, some of them have release methods(like d3d buffers) and some of them don't, so I was wondering if it's sufficient to only call delete on the pointer.I couldn't find any info on this in MSDN, but I'm almost sure they did some safety measure like that, I mean why wouldn't they?

Share this post


Link to post
Share on other sites
Advertisement

D3D objects don't have destructors - they're not C++ objects as you understand them, but COM objects instead.  If you look at the D3D header files you'll see that they're declared as neither classes nor structs, and you'll know from your own code that they're not instantiated via "new" but rather returned as a pointer from a Create call.

 

So you must manually Release them all yourself.

Share this post


Link to post
Share on other sites

And of course, you should only release it once for each proper acquisition of the object that you have performed.  If you do it too many times (accessing illegal memory area) or too few (memory leak) times, then you will get some issues.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement