Archived

This topic is now archived and is closed to further replies.

Memory deallocation

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

When you free an object using delete it calls your destructor, does whatever the destructor tells it, then frees the memory of the object itself.
It won't check your object for pointers and auto free them (thank God) unless you explicitly tell it to in the destructor of the object your freeing.
So in the destructor you should put code to free all memory you want freeing with as much error checking as possible.

C/C++ is great because it gives you all the control in the world but it also expects you to do all the work. A fair trade off IMHO.

Mike

Share this post


Link to post
Share on other sites
I have a question about memory deallocation in a double linked lists. If I have a pointer to a list, lets call it pmonster, witch among other things contains a pointer to a surface, and I deallocate memory for the pointer. Now what happens to the surface pointer in the class? Should´nt I call Release() on that pointer before I deallocate pmonster, or is this done automaticly?

------------------
Gandalf the White

Share this post


Link to post
Share on other sites