Windows C/C++ 内存泄露检测

#pragma once
#define _CRTDBG_MAP_ALLOC

#include<crtdbg.h>
#include<stdlib.h>
#include<locale.h>
#include <iostream>
#include<fstream>
#include <list>
#include <string>
#include <map>

#ifdef _DEBUG
#ifndef DBG_NEW
#define DBG_NEW new(_NORMAL_BLOCK,__FILE__,__LINE__)
#define new DBG_NEW
#endif
#endif

注意:DBG_NEW 的位置要放在stream和string的后面,否则会有冲突。

原文地址:https://www.cnblogs.com/qinfengxiaoyue/p/3476362.html