Jump to content
  • Advertisement
Sign in to follow this  
mattor

Allegro memory deallocation

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

Can anyone tell me what allegro_exit() does NOT free memory for, in other words, which things do I need to delete myself before exiting? I know user-made fonts are one, but are there others?

Share this post


Link to post
Share on other sites
Advertisement
Bitmaps, sounds, you need to delete pretty much any resource that you create. To delete a bitmap, use the destroy_bitmap() function.

Share this post


Link to post
Share on other sites
As far as I know, allegro_exit doesn't free anything unless it was allocated in allegro_init. So, basically, if you loaded it, you destroy it. Not doing so is bad form, even if the library could do it for you.

edit - too slow, once again.

Share this post


Link to post
Share on other sites
so my user created BITMAP buffer I should free, but not the global screen bitmap?
Also, do I need to delete my user class objects?

I know this is really elementary stuff but I'm a slow learner and I think my memory management is causing my dev-c++ to crash quite a lot. I want to learn how to clean up after myself.

Share this post


Link to post
Share on other sites
I think the global screen bitmap is released with the allegro_exit() function, but if you made BITMAPs (even if its in a class) you have to release them (in the destructure?).

Share this post


Link to post
Share on other sites
Unless otherwise noted you should assume that anything you dynamicly create should also be destroyed by yourself. Make it a habbit to always write the code to release any resource right after you've written the code to allocate it.

If you don't know when to release it take a while to ponder it and see to it that you know when to release it before you even create it.

Will save you loads of time in the long run.

Share this post


Link to post
Share on other sites
what do you put inside the destructor definition, and how do you use the destructor?
(if I've written my own class)

Share this post


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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!