1 VisualC++ debugger 和 CRT 库
第一步: 包含以下头文件。
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
第二步: 接管 new 操作符。
#ifdef _DEBUG
#ifndef DBG_NEW
#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ ,__LINE__)
#define new DBG_NEW
#endif #endif
第三步: 在代码结束出输出内存泄漏信息。
_CrtDumpMemoryLeaks();
接管new操作符那里是没看明白,日后再看!