visual c++ 2012 内存泄漏检测方法

转自: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 <stdlib.h>
#include <crtdbg.h>
#ifdef _DEBUG
#define new DEBUG_CLIENTBLOCK
#endif // _DEBUG

2.程序中添加下面的函数:

_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF);

原文地址:https://www.cnblogs.com/jerry1999/p/3677341.html