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的后面,否则会有冲突。

posted on 2013-12-16 11:14  qinfengxiaoyue  阅读(248)  评论(0编辑  收藏  举报