对于内存泄露,没必要使用BoundChecker了。 VC自己就有库来检测。
把这些代码加入StdAfx.h的最前面: C/C++ code
```#ifdef _DEBUG#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)#else#define DEBUG_NEW#endif#define _CRTDBG_MAP_ALLOC#include<stdlib.h>#include<crtdbg.h>#ifdef _DEBUG#define new DEBUG_NEW#endifss MemoryLeakChecker{public:MemoryLeakChecker(){#ifdef _DEBUG_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);#endif// _DEBUG}~MemoryLeakChecker(){#ifdef _DEBUG_CrtDumpMemoryLeaks();#endif// _DEBUG}static MemoryLeakChecker& GetInstance(){static MemoryLeakChecker checker;return checker;}};使用的时候,在main或者WinMain函数入口的第一行写上: C/C++ codeMemoryLeakChecker::GetInstance(); 然后,F5调试运行一次,结束后,会输出是否泄露、哪个源码,具体行数。 我把这点加在了StdAfx.h的#PRagma once的上面,但报了很多错误 到底加呢? 加在#pragma once的后面,否则会重复包含了。 最好是加在:
#include <windows.h>之后 http://blog.csdn.net/zxcred/archive/2008/11/05/3228239.aspx http://blog.sina.com.cn/s/blog_51396f890100qjtq.html
bounds checker8.2安装记 收藏 http://blog.sina.com.cn/s/blog_51396f890100qjxi.html
新闻热点
疑难解答