Sign in to follow this  
mattor

Allegro memory deallocation

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this