查找内存泄露的方法
2015-07-26 23:43
253 查看
这样一段小程序:
#define _CRTDBG_MAP_ALLOC //这里是必须要的
#include <iostream>
#include<stdlib.h>
#include<crtdbg.h>//这里是必须要的
using namespace std;
int main()
{
cout<<"test"<<endl;
{
int* pInt = new int(10);
cout<<*pInt<<endl;
}
_CrtDumpMemoryLeaks();//这里是必须要的
system("pause");
return 0;
}
debug的输出如下,
Detected memory leaks!
Dumping objects ->
{119} normal block at 0x003B5D88, 4 bytes long.
Data: < > 0A 00 00 00
Object dump complete.
#define _CRTDBG_MAP_ALLOC //这里是必须要的
#include <iostream>
#include<stdlib.h>
#include<crtdbg.h>//这里是必须要的
using namespace std;
int main()
{
cout<<"test"<<endl;
{
int* pInt = new int(10);
cout<<*pInt<<endl;
}
_CrtDumpMemoryLeaks();//这里是必须要的
system("pause");
return 0;
}
debug的输出如下,
Detected memory leaks!
Dumping objects ->
{119} normal block at 0x003B5D88, 4 bytes long.
Data: < > 0A 00 00 00
Object dump complete.
相关文章推荐
- [转]http://lua-users.org/wiki/LpegTutorial
- 科技行业为Flash准备“葬礼”
- 科技行业为Flash准备“葬礼”
- java数据类型
- MyBatis入门
- shell 入门练习:输入网卡名显示ip
- sgu293:Game with Q an C(构造)
- JDNI
- hdu 5310 Souvenir (简单题)
- !HDU 4193 循环序列前缀和非负-单调队列-(区间最值)
- libpcap详解
- ThinkPHP配置文件的加载
- 理解JNDI中 java:comp/env/jdbc/datasource 与 jdbc/datasource 的不同之处(转)
- unity3d v5.1.1 ugui 带垂直滚动条的文本框
- apache 403 forbidden怎么解决
- 云服务器试用
- C++ Primer快速入门之六:数组和指针
- android开发中常用颜色代码
- Ubuntu 12.04.5 LTS下配置android4.4编译环境
- 深入理解AsyncTask