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 / Delete Objects etc on exit, Why?

Author
Message
old man
20
Years of Service
User Offline
Joined: 25th Feb 2004
Location:
Posted: 3rd May 2009 10:10
In the examples and templates the objects etc are often deleted at the end of the program.

Is this just an old fashioned approach or is there real value in the statements?

The progs appear to end ok if you do not delete anything.

Any thoughts?

uff
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 3rd May 2009 14:36
It's good practice to; Your destructors may need to get called in some specific order or if you're checking for memory leaks you'll want to correctly destroy as much as you can and see what's left. If you mean GDK 3D objects then there's no requirement to do so, but I still do(mainly because my GDK wrapper destroys objects, images, etc once a destructor is called for something, and GDK crashes when this is done at the end of the entry point).

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th May 2009 16:35
I know it was crucial when using earlier versions of DirectX, but I don't think it's a problem any more (since DX came in its DLL forms) - however, I can't state that I'm absolutely certain of this.

jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 4th May 2009 16:56
Not releasing meshes in DirectX does give you a DirectX memory leak, which it then tries to repair itself just before the program closes. this makes closing time longer. I think GDK though does it all for you when it closes, i'm not sure. But I agree, just to be on the safe side, release resources explicitly always.
stevebrit
15
Years of Service
User Offline
Joined: 6th Jan 2009
Location: Florida USA
Posted: 6th May 2009 03:52
Just an idea make a note of memory available.
then run program with resources deleted.
Do the same thing checking available memory without deleting resources... Do you see a difference ??

Personally i have read so many times about deleting resources
because they can cause memory leaks, and although the computer seems to be ok..... Its not in my opinion worth the risk of creating an unstable computer just to save a few lines of code .............

Regards "- Steve

AMD Athlon64x2 3.1Ghz - Ram 4Gb DDR2 800Mhz - 500Gb HD
Ndivia 9600GT SLI - 24in LCD - WIN 7 - 64 bit BETA

Login to post a reply

Server time is: 2024-11-25 12:22:43
Your offset time is: 2024-11-25 12:22:43