//第一种
1. 在APP开头处包含如下代码
#define CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
2. 在APP初始化的函数中加入
_CrtDumpMemoryLeaks();
3. Output中将会跟踪全部内存建立和销毁的过程,这些信息能够忽略。
4. 程序退出时,output中将会显示出建立内存未释放的代码行信息。
这个能够解决绝大部分状况下出现的内存泄露
//第二种
用于在发生内存泄露后,能够定位到进行new操做的代码行数:函数
#ifdef _DEBUG
#define new DEBUG_NEW
#endifspa