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?
Do Direct3D objects automatically have Release called from their destructor?,
Crossbones+ - Reputation: 12124
Posted 15 March 2013 - 05:44 PM
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.
It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.
Crossbones+ - Reputation: 6411
Posted 15 March 2013 - 05:48 PM
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.
Jason Zink :: DirectX MVP
Direct3D 11 engine on CodePlex: Hieroglyph 3
Direct3D Books: Practical Rendering and Computation with Direct3D 11, Programming Vertex, Geometry, and Pixel Shaders
Articles: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article (original):: Fast Silhouettes Article
Games: Lunar Rift