1 MFC 中检测内存泄漏
CPP 文件中加入以下代码
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
Comment: 调试的时候在多个CPP文件中添加上述调试信息,
VS2008 debug的时候出现ERROR:
"Microsoft Visual Studio has encountered an internal error"
去掉新添加的上述信息后,重新OK.
1、在stdafx.h头文件中添加两行代码
//内存泄露检测
#define _CRTDBG_MAP_ALLO
#include <crtdbg.h>
2、在程序退出的地方添加函数,
_CrtDumpMemoryLeaks();