How to deal with memory issues using WinXP
In the last days a lot people asked me questions regarding memory issues using Windows XP. SO I decided to write down my experiences with the common tools. Maybe I am not the first one who wrote down a proposal about this. But so my blog looks a bit more active
.
If you want to detect memory leaks in your application and you are using Windows Xp you can walk more than one way. The common way is to use the debug runtime support of Micorsoft. This debug runtine support can help you finding memory leaks and memory assertions. At first you must include the common headers and enable the debug support by defining _CRTDBG_MAP_ALLOC like:
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
Now you must enable the memory tracking and reporting support:
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
_CrtSetReportMode ( _CRT_ERROR, _CRTDBG_MODE_DEBUG);
And make sure, that the following preprocessor-definitions are at the beginning of your file
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
After this the debug runtime of Visual C++ tracks all new calls. If you just have forget to delete a allocated memory buffer you will get a notification after terminating your application in the output window.
Another way to deal with memoryleaks is umdh ( see http://support.microsoft.com/kb/268343 for more infos ). Here you can get a list will all allocations, which are currently not released. So by analysing that you can hopefully find your own leak.