|
-
Nov 2nd, 2004, 11:40 PM
#1
Thread Starter
PowerPoster
Stop/Test lingering objects
Alright, I am trying to capture all the basic ways to exit a program and to deal with the unloading of all the important objects like Dx interfaces for example.
Is there a way to test if I missed any? Like get size at beginning and end or something.
Now, what if the game stalls, exception handle, a user terminates it with ctrl+alt+del...some sort of error which cause's instant termination...
Is there a way to deal with that? Like to make sure things unload, it is my idea that if some sort of unexpected termination occurs then memory leaks would follow.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Nov 3rd, 2004, 04:29 AM
#2
There is always a way to kill your app that can't be caught. The simplest is to call TerminateProcess. It's zaps your app immediately. You don't get a single instruction for cleanup. You can't even block it.
Similarly, the abort() CRT function kills your process without giving anyone a chance to clean up.
exit() only calls the functions registered with atexit().
However, these are unusual circumstances. In a C++ program, calling exit() somewhere high up in the stack is usually a bad idea. To deal with everything else (exceptions and friends), use RAII: everything that needs to be cleaned up ought to be wrapped at least in a simple holder object that frees it on destruction.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 4th, 2004, 11:05 PM
#3
Thread Starter
PowerPoster
That said, s`all a good idea.
I suppose kind of useless for most apps.
So no way to double-check I am hitting an unload everytime on a plain regular exit from WinMain?
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
-
Nov 5th, 2004, 04:55 AM
#4
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|