Jump to content
  • Advertisement


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


Memory deallocation

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


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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!