Why free memory on application quit?
AnotherJake Wrote:That's weird. Like what else besides freeing resources would be appropriate in a destructor?
IO objects are a good example. They close the stream when they are collected. You don't want them to just leave it open because it may be a long time before the program exits.
Now consider that you've built some buffered IO object on top of that. If it was simply allowed to be GCed, it may still have data buffered that hasn't been written to the physical stream. If the stream was to be closed before the buffered data is written to it, it would corrupt the data.
OneSadCookie: Again, I assume it has to do with it being impossible to tell which destructor functions are safe to skip, and which ones aren't.
Back to the original topic. I once thought that it was good practice to free everything before the program quit, but have since come to agree with the consensus here. It doesn't actually benefit anybody, so why bother?
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
|Messages In This Thread|
Why free memory on application quit? - Skorche - Nov 24, 2008 11:34 PM
Possibly Related Threads...
|My game crashes on quit...||hangt5||17||7,767||
Jan 30, 2005 09:38 PM
Last Post: hangt5
|Carbon Apple quit Event troubles||deekpyro||3||5,000||
May 7, 2002 06:24 AM
Last Post: deekpyro