内存泄露的快速寻找方法
http://blog.csdn.net/ly402609921/article/details/5705663
看看代码:
// MemoryLeak.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <assert.h>
#ifdef _DEBUG
#define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
#else
#define DEBUG_CLIENTBLOCK
#endif
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#ifdef _DEBUG
#define new DEBUG_CLIENTBLOCK
#endif //此部分用于使_CrtDumpMemoryLeaks输出内存泄漏文件名和行号信息默认不会输出相关信息
int _tmain(int argc, _TCHAR* argv[])
{
// atexit(Exit);
int* p = new int;
_CrtDumpMemoryLeaks();
return 0;
}
进入调试模式,不要直接运行,可以直接定位内存泄漏的位置。