码迷,mamicode.com
首页 > 编程语言 > 详细

windows C++内存检测

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

标签:style   color   ar   sp   line   on   new   c   ef   

作为一个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++内存检测

标签:style   color   ar   sp   line   on   new   c   ef   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!