Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Memory Deallocation

Author
Message
PlusPlus
15
Years of Service
User Offline
Joined: 8th Apr 2009
Location:
Posted: 8th Apr 2009 19:57
Hi. Is the memory deallocated automatically? Or I must delete all the sprites-bitmaps-images that I load and create?

Thanks for helping, I'm new at this.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 8th Apr 2009 21:56 Edited at: 8th Apr 2009 21:56
When the program exits, DarkGDK automatically deletes anything with an id number. (So objects, sprites, bitmaps, images, etc.)

Even if it didn't windows XP and above automatically frees all resources owned by a program when it exits anyway.

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 8th Apr 2009 22:02
I believe DarKGDK only released resources by itself when using the default "Escape key to exit" behavior.

As stated above Windows should deallocate your resources, if it doesn't you could (and probably even should) create a function that deletes all your resources for you when you press your game "quit button".

------------------------------------
Currently developing an "over-the-shoulder", action based, RPG with combat based on rag-doll physics.
DaddyJ
15
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 8th Apr 2009 22:38
Its good programming practice to release anything you create.

An init function to create

A shutdown function to release
PlusPlus
15
Years of Service
User Offline
Joined: 8th Apr 2009
Location:
Posted: 9th Apr 2009 02:39
Thanks, I'm going to deallocate everything manually, just to be sure...
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 11th Apr 2009 18:19
Bear in mind that some of the text input functions return pointers to dynamically allocated space for the zero terminated string. If you're going to handle everything manually then you need to do

delete [] txtPtr;

or whatever the pointer is. And don't reassign the same pointer to another input until you've deleted any previous assignment, otherwise you get a memory leak for the duration of the program.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office

Login to post a reply

Server time is: 2024-09-30 23:10:25
Your offset time is: 2024-09-30 23:10:25