My application is shut down somehow开发者_运维百科 only in release mode. And I can't even see the call stack. I guess it's all broken somehow.
And it works fine in debug mode. What can be the problem? Or how can I figure out what the problem is?
Another issue is, I want to try debug mode with not initialized variables. I mean, as far as I know, in debug mode, all variables are initialized properly (Is this right?). But not in release mode. So I want to try debug mode with no automatic initialize mode. Is this possible?
I'm working on VS2010, c++, directX, Windows 7. Thanks.
Try disable optimizations and try again
99% of the time it is some of your variables are not initialized, check very carefully.
In debug mode variable are not initialized, they are filled with a value which is selected to cause you trouble when used (non-zero, high enough to cause overflows often) and to be recognizable.
My application is shut down somehow only in release mode
You need to identify first what kind of shut down is it. Is it crashing, aborting, or closing? Place breakpoint on all possible exit points (both regular, like WM_CLOSE), and irregular, like _abort.
If no breakpoint is hit, at least copy the debug output here, to see what is is telling about how the main thread was terminated (what result code or anything which could give more information).
To summarize differences between debug and release:
- debug initializes dynamically allocated variables by a bad value (this is done by debug runtime library, controlled by Code generation/Runtime library)
- debug initializes stack allocated variables by a bad value (controlled by Code generation/Basic runtime checks - /RTC options)
- optimizations are turned off in debug (controlled by Optimization - /O options)
- different macros are defined (_DEBUG vs NDEBUG) (controlled by Preprocessor/Preprocessor defintions)
You can adjust your release mode settings one by one to match debug settings until the "automatic shutdown" stops. Then you will know what kind of problem to look for.
精彩评论