不用MFC也可以查内存泄露,简单好用。
2010-07-08 09:41
204 查看
先上代码
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);就这么一句
然后就是debug了 不是run哦。
然后在输出窗口就可以看到了
Detected memory leaks!
Dumping objects ->
d:/program files/microsoft visual studio 8/vc/include/crtdbg.h(1150) : {110} normal block at 0x003B9BA8, 40 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
程序“[2760] t1.exe: 本机”已退出,返回值为 0 (0x0)。
40 bytes 10个int没错。
// t1.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #define _CRTDBG_MAP_ALLOC #include <crtdbg.h> int _tmain(int argc, _TCHAR* argv[]) { _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); int* test=new int[10]; return 0; }
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);就这么一句
然后就是debug了 不是run哦。
然后在输出窗口就可以看到了
Detected memory leaks!
Dumping objects ->
d:/program files/microsoft visual studio 8/vc/include/crtdbg.h(1150) : {110} normal block at 0x003B9BA8, 40 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
程序“[2760] t1.exe: 本机”已退出,返回值为 0 (0x0)。
40 bytes 10个int没错。
相关文章推荐
- VS2005 简单内存泄露检测方法(MFC)
- MFC判断内存泄露的简单方法 CmemoryState
- vs2008下的MFC程序,怎么检测内存泄露
- 避免内存泄露的一些简单方法
- VS2005 MFC 简单内存泄漏检测方法,解决Detected memory leaks!问题
- <转载>浅谈MFC内存泄露检测及内存越界访问保护机制
- MFC内存泄露检测
- 关于MFC下检查和消除内存泄露的技巧
- vc不包含MFC就不打印内存泄露?
- MFC 简单内存泄漏检测方法,解决Detected memory leaks!问题
- 不用splitter控件 简单实现对mfc对话框的分割的方法
- MFC内存泄露检测
- VS2005检查内存泄露的简单方法
- 关于MFC下检查和消除内存泄露的技巧
- vs2008下MFC内存泄露问题一点经验
- 关于MFC下检查和消除内存泄露的技巧
- 如何检测非MFC程序的内存泄露?
- 关于在VS2008以下版本的MFC程序使用VS 2008 FeaturePack出现内存泄露的理解
- 检查MFC程序的内存泄露
- 程序模式VS2010 C++最简单的检查内存泄露