Detect heap corruption
Does visual studio 2008 has any options (run time) to detect immedidate detection 开发者_如何学Goof heap corruption?
If you look through the list of Debug Routines exported from the Visual C++ debug runtime, you can find many useful debugging functions, including _CrtSetDbgFlags that can be used to set how often the debug heap checks itself for corruption.
Application Verifier from Microsoft is an excellent tool for this purpose. I've found it very useful. Download it :
http://www.microsoft.com/en-us/download/details.aspx?id=20028
And then look around for some tutorial. Usually just point to your executable, then run your exe in Visual Studio debug as always. It should break near where the issue occurs.
You can activate the 'Full Page Heap' on any windows (since Windows 2000 at least !), with the release build of your application. It will catch 99% of errors at the time they occur. You can look at this page for an tutorial of this functionality. Don't forget to deactivate full page heap when you are done troubleshooting your application. This technique may not work on a debug build, since the debug version of the CRT uses its own scheme to allocate dynamic memory.
精彩评论