网上有很多这个的说明,我只是总结了一下
#include <assert.h>
#include <iostream>
#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输出内存泄漏文件名和行号信息默认不会输出相关信息
using namespace std;
int main(int argc, char* argv[])
{
int* p = new int;
_CrtDumpMemoryLeaks();
system("pause");
return 0;
}