首页 > 编程语言 > 详细

windows C++内存检测

时间:2014-08-29 12:53:28      阅读:259      评论:0      收藏:0      [点我收藏+]

作为一个C++程序员,一个简单例子更容易理解

#include "stdafx.h"
#include<windows.h>

#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

using namespace std;

int _tmain(int argc,char* argv[])
{
 int *p = new int();
 _CrtDumpMemoryLeaks();
 return 0;
}

运行完成后,查看输出窗口。
-->e:\program\test\memleaks\memleaks\memleaks.cpp(23) : {128} client block at 0x0066AF90, subtype 0, 4 bytes long.

这就是我们想要的结果。

windows C++内存检测

原文:http://www.cnblogs.com/weiweiqingfeng/p/3944500.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!