转自:http://hi.baidu.com/ufownl/item/f15e8ad6df7da1cf1a72b4f2
1.程序开始包含如下定义:
#ifdef _DEBUG #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) #else #define DEBUG_CLIENTBLOCK #endif // _DEBUG #define _CRTDBG_MAP_ALLOC #include #include #ifdef _DEBUG #define new DEBUG_CLIENTBLOCK #endif // _DEBUG
2.程序中添加下面的函数:
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF);