vs如何检测内存泄漏DLL中的内存泄漏

2006年10月 总版技术专家分月排行榜第二2006年9月 总版技术专家分月排行榜第二
2006年5月 总版技术专家分月排行榜第三
2001年 总版技术专家分年内排行榜第七
2002年1月 总版技术专家分月排行榜第一
本帖子已过去太久远了,不再提供回复功能。26483人阅读
使用vs的内存检测有以下几种方法。
在debug模式下以F5运行:
#define CRTDBG_MAP_ALLOC
#include &stdlib.h&
#include &crtdbg.h&
//在入口函数中包含 _CrtDumpMemoryLeaks();
//即可检测到内存泄露
//以如下测试函数为例:
int main()
char* pChars = new char[10];
_CrtDumpMemoryLeaks();
F5运行输出窗口会得到:
Detected memory leaks!
Dumping objects -&
{58} normal block at 0x bytes long.
&Data: &&&&&&&&&& & CD CD CD CD CD CD CD CD CD CD
Object dump complete.
以上方法没有输出
<span style="color:#.在VS2010下测试的时候,发现_CrtDumpMemoryLeaks();这句必须放在函数结束处,放在主函数入口处输出窗口不会输出内存泄露信息
2.{}中的数字指明这块内存是程序中总计第几个被申请的,这种方法没有行号和其他信息输出。我们可以定义:
#ifdef _DEBUG
#define New
new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define CRTDBG_MAP_ALLOC
#include &stdlib.h&
#include &crtdbg.h&
//在入口函数中包含 _CrtDumpMemoryLeaks();
//即可检测到内存泄露
//以如下测试函数为例:
int main()
char* pChars = New char[10];
_CrtDumpMemoryLeaks();
Detected memory leaks!
Dumping objects -&
e:\vs2005\stltest\stltest\test.cpp(14) : {58} normal block at 0x bytes long.
&Data: &&&&&&&&&& & CD CD CD CD CD CD CD CD CD CD
Object dump complete.
#define CRTDBG_MAP_ALLOC
#include &stdlib.h&
#include &crtdbg.h&
//在入口函数中包含 _CrtDumpMemoryLeaks();
//即可检测到内存泄露
//定义函数:
inline void EnableMemLeakCheck()
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
//该函数可以放在主函数的任意位置,都能正确的触发内存泄露输出
//以如下测试函数为例:
int main()
EnableMemLeakCheck();
char* pChars = new char[10];
//_CrtDumpMemoryLeaks();
Detected memory leaks!
Dumping objects -&
{58} normal block at 0x004F1A38, 10 bytes long.
&Data: &&&&&&&&&& & CD CD CD CD CD CD CD CD CD CD
Object dump complete.
方法三:直接定位指定内存块错误的代码行
单确定了内存泄漏发生在哪一行,有时候并不足够。特别是同一个new对应有多处释放的情形。在实际的工程中,以下两种情况很典型:
创建对象的地方是一个类工厂(ClassFactory)模式。很多甚至全部类实例由同一个new创建。对于此,定位到了new出对象的所在行基本没有多大帮助。
COM对象。我们知道COM对象采用Reference Count维护生命周期。也就是说,对象new的地方只有一个,但是Release的地方很多,你要一个个排除。
那么,有什么好办法,可以迅速定位内存泄漏?
在内存泄漏情况复杂的时候,你可以用以下方法定位内存泄漏。这是我个人认为通用的内存泄漏追踪方法中最有效的手段。
我们再回头看看crtdbg生成的内存泄漏报告:
Detected memory leaks!
Dumping objects -&
{58} normal block at 0x004F1A38, 10 bytes long.
&Data: &&&&&&&&&& & CD CD CD CD CD CD CD CD CD CD&
Object dump complete.
除了产生该内存泄漏的内存分配语句所在的文件名、行号为,我们注意到有一个比较陌生的信息:{58}。这个整数&#20540;代表了什么意思呢?
其实,它代表了第几次内存分配操作。象这个例子,{58}代表了第<span style="color:#次内存分配操作发生了泄漏。你可能要说,我只new过一次,怎么会是第<span style="color:#次?这很容易理解,其他的内存申请操作在C的初始化过程调用的呗。:)
有没有可能,我们让程序运行到第<span style="color:#次内存分配操作的时候,自动停下来,进入调试状态?所幸,crtdbg确实提供了这样的函数:即
long _CrtSetBreakAlloc(long nAllocID)。我们加上它:
#define CRTDBG_MAP_ALLOC
#include &stdlib.h&
#include &crtdbg.h&
int main()
_CrtSetBreakAlloc(58);
char* pChars = new char[10];
_CrtDumpMemoryLeaks();
你发现,程序运行到&char* pChars = new char[10];一句时,自动停下来进入调试状态。细细体会一下,你可以发现,这种方式你获得的信息远比在程序退出时获得文件名及行号有价&#20540;得多。因为报告泄漏文件名及行号,你获得的只是静态的信息,然而_CrtSetBreakAlloc则是把整个现场恢复,你可以通过对函数调用栈分析(我发现很多人不习惯看函数调用栈,如果你属于这种情况,我强烈推荐你去补上这一课,因为它太重要了)以及其他在线调试技巧,来分析产生内存泄漏的原因。通常情况下,这种分析方法可以在<span style="color:#分钟内找到肇事者。
PS:在VS2010下使用这两种方法,宏和头文件不用包含也可以正确运行:
#define&CRTDBG_MAP_ALLOC&&
#include&&stdlib.h&&&
#include&&crtdbg.h& &&
&非MFC程序可以用以下方法检测内存泄露:
1.程序开始包含如下定义:
#ifdef _DEBUG
#define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
#define DEBUG_CLIENTBLOCK
#endif& // _DEBUG
#define _CRTDBG_MAP_ALLOC
#include &stdlib.h&
#include &crtdbg.h&
#ifdef _DEBUG
#define new DEBUG_CLIENTBLOCK
#endif& // _DEBUG
2.程序中添加下面的函数:
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF);
Debug版本程序运行结束后如有内存泄漏,输出窗口中会显示类&#20284;信息:
Detected memory leaks!
Dumping objects -&
g:\programs\test\test.cpp(16) : {51} client block at 0x00385C58, subtype 0, 4 bytes long.
&Data: &&&& & CD CD CD CD
Object dump complete.
MFC程序内存泄漏检测方法:
1.在 CMyApp 中添加如下三个 CMemoryState 类的成员变量:
#ifdef _DEBUG
protected:
&&&&& CMemoryState m_msOld, m_msNew, m_msD
#endif& // _DEBUG
2.在 CMyApp::InitInstance() 中添加如下代码:
#ifdef _DEBUG
&&&&& m_msOld.Checkpoint();
#endif& // _DEBUG
3.在 CMyApp::ExitInstance() 中添加如下代码:
#ifdef _DEBUG
&&&&& m_msNew.Checkpoint();
&&&&& if (m_msDiff.Difference(m_msOld, m_msNew))
&&&&&&&&&&& afxDump&&&\nMemory Leaked :\n&;
&&&&&&&&&&& m_msDiff.DumpStatistics();
&&&&&&&&&&& afxDump&&&Dump Complete !\n\n&;
#endif& // _DEBUG
Debug版本程序运行结束后如有内存泄漏,输出窗口中会显示类&#20284;信息:
Memory Leaked :
0 bytes in 0 Free Blocks.
8 bytes in 1 Normal Blocks.
0 bytes in 0 CRT Blocks.
0 bytes in 0 Ignore Blocks.
0 bytes in 0 Client Blocks.
Largest number used: 8825 bytes.
Total allocations: 47506 bytes.
Dump Complete !
Detected memory leaks!
Dumping objects -&
g:\programs\chat\chatdlg.cpp(120) : {118} normal block at 0x00D98150, 8 bytes long.
&Data: &&&&&&&& & A8 7F D9 00 01 00 00 00
Object dump complete.
&&相关文章推荐
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:522204次
积分:5627
积分:5627
排名:第4154名
原创:116篇
转载:63篇
评论:81条
(2)(1)(6)(5)(3)(7)(2)(3)(4)(9)(3)(6)(11)(3)(9)(2)(14)(6)(3)(25)(13)(5)(4)(1)(2)(2)(20)(9)(1)Pages: 1/3
主题 : 在VS下,大家用什么来检测内存泄漏啊?
可可豆: * CB
威望: * 点
在线时间: (时)
注册时间: *
最后登录: *
发自: Web Page
在VS下,大家用什么来检测内存泄漏啊?&&&
没有Mac,在windows下用VS2010发现用Visual Leak Detector检测不出retain()和release()的泄漏,只对new和delete有反应。
有没有好的工具推荐下啊?谢谢分享....
级别: 新手上路
可可豆: 0 CB
威望: 0 点
在线时间: 0(时)
发自: Web Page
[code]////////////////////////////////////////////////////////////////////////////////
//
$Id: vld.h,v 1.1
08:44:48 chengjing Exp $
//
//
Visual Leak Detector (Version 1.0)
//
Copyright (c) 2005 Dan Moulding
//
//
This prog you can redistribute it and/or modify
//
it under the terms of the GNU Lesser General Public License as published by
//
the Free Software F either version 2.1 of the License, or
//
(at your option) any later version.
//
//
This program is distributed in the hope that it will be useful,
//
but WITHOUT ANY WARRANTY; without even the implied warranty of
//
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the
//
GNU Lesser General Public License for more details.
//
//
You should have received a copy of the GNU Lesser General Public License
//
alo if not, write to the Free Software
//
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
See COPYING.txt for the full terms of the GNU Lesser General Public License.
//
////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifdef _DEBUG
////////////////////////////////////////////////////////////////////////////////
//
//
Configuration Options
//
// Configuration flags
#define VLD_CONFIG_AGGREGATE_DUPLICATES 0x1
#define VLD_CONFIG_SELF_TEST
0x2
#define VLD_CONFIG_SHOW_USELESS_FRAMES
0x4
#define VLD_CONFIG_START_DISABLED
#ifndef VLDBUILD
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// If VLD_AGGREGATE_DUPLICATES is defined, then duplicated leaks (those that
// have the same size and call stack as a previously identified leak) are not
// shown in detail in the memory leak report. Instead, only a count of the
// number of matching duplicate leaks is shown along with the detailed
// information from the first such leak encountered.
#ifdef VLD_AGGREGATE_DUPLICATES
#define VLD_FLAG_AGGREGATE_DUPLICATES VLD_CONFIG_AGGREGATE_DUPLICATES
#else
#define VLD_FLAG_AGGREGATE_DUPLICATES 0x0
#endif // VLD_AGGREGATE_DUPLICATES
// If VLD_MAX_DATA_DUMP is defined, then the amount of data shown in user-data
// memory dumps will be limited to the specified number of bytes.
#ifdef VLD_MAX_DATA_DUMP
unsigned long _VLD_maxdatadump = VLD_MAX_DATA_DUMP;
#else
unsigned long _VLD_maxdatadump = 0
#endif // VLD_MAX_DATA_DUMP
// If VLD_MAX_TRACE_FRAMES is defined, then the number of frames traced for each
// allocated memory block when walking the stack will be limited to the
// specified number of frames.
#ifdef VLD_MAX_TRACE_FRAMES
unsigned long _VLD_maxtraceframes = VLD_MAX_TRACE_FRAMES;
#else
unsigned long _VLD_maxtraceframes = 0
#endif // VLD_MAX_TRACE_FRAMES
// If VLD_SELF_TEST is defined, then Visual Leak Detector will perform a memory
// leak self-test, by intentionally leaking memory, to ensure that it is able to
// correctly detect memory leaks internal to Visual Leak Detector.
#ifdef VLD_SELF_TEST
#define VLD_FLAG_SELF_TEST VLD_CONFIG_SELF_TEST
#else
#define VLD_FLAG_SELF_TEST 0x0
#endif // VLD_SELF_TEST
// If VLD_SHOW_USELESS_FRAMES is defined, then all frames traced will be
// displayed, even frames internal to the heap and Visual Leak Detector.
#ifdef VLD_SHOW_USELESS_FRAMES
#define VLD_FLAG_SHOW_USELESS_FRAMES VLD_CONFIG_SHOW_USELESS_FRAMES
#else
#define VLD_FLAG_SHOW_USELESS_FRAMES 0x0
#endif // VLD_SHOW_USELESS_FRAMES
// If VLD_START_DISABLED is defined, then Visual Leak Detector will initially
// be disabled for all threads.
#ifdef VLD_START_DISABLED
#define VLD_FLAG_START_DISABLED VLD_CONFIG_START_DISABLED
#else
#define VLD_FLAG_START_DISABLED 0x0
#endif // VLD_START_DISABLED
// Initialize the configuration flags based on defined preprocessor macros.
unsigned _VLD_configflags = VLD_FLAG_AGGREGATE_DUPLICATES | VLD_FLAG_SELF_TEST |
VLD_FLAG_SHOW_USELESS_FRAMES | VLD_FLAG_START_DISABLED;
#ifdef __cplusplus
}
#endif // __cplusplus
////////////////////////////////////////////////////////////////////////////////
//
//
Linker Directives
//
// Link with the appropriate Visual Leak Detector library. One of: multithreaded
// DLL, multithreaded static, or single threaded. All three link with debug
// versions of the CRT.
#ifdef _DLL
#pragma comment (lib, "vldmtdll.lib")
#else
#ifdef _MT
#pragma comment (lib, "vldmt.lib")
#else
#pragma comment (lib, "vld.lib")
#endif // _MT
#endif // _DLL
// Force a symbolic reference to the global VisualLeakDetector class object from
// the library. This enusres that the object is linked with the program, even
// though nobody directly references it outside of the library.
#pragma comment(linker, "/include:?visualleakdetector@@3VVisualLeakDetector@@A")
#endif // VLDBUILD
#endif // _DEBUG[/code]百度搜索vld
级别: 新手上路
可可豆: 0 CB
威望: 0 点
在线时间: 0(时)
发自: Web Page
[quote][size=2][color=#999999]juckerpp 发表于
23:43[/color] [url=forum.php?mod=redirect&goto=findpost&pid=8562&ptid=3525][img]static/image/common/back.gif[/img][/url][/size]
百度搜索vld[/quote]我用的就是这个 vld 2.2.3
但是我这有个问题:
CCSprite *sprite = CCSprite::spriteWithFile("Button1.png");
sprite->retain();
后面没有调用sprite->release()不报leak:
No memory leaks detected.
Visual Leak Detector is now exiting.
但是如果这样写:
CCSprite *sprite = new CCS
sprite->autorelease();
sprite->retain();
没有调用release的话就会报:
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 3 at 0x: 456 bytes ----------
Call Stack:
f:cocos2d-xzlsr_3_bearzlsr_3_bearclasseshelloworldscene.cpp (45): Zlsr_3_bear.win32.exe!HelloWorld::init + 0xA bytes
........
.........
Visual Leak Detector detected 1 memory leak (492 bytes).
Largest number used: 900 bytes.
Total allocations: 900 bytes.
Visual Leak Detector is now exiting.
这是什么情况?
级别: 新手上路
可可豆: 0 CB
威望: 0 点
在线时间: 0(时)
发自: Web Page
因为你new了一个新的对象,如果你用的是spritewithxxxx,就等于将内存交给了cocos2d-x去管理
如果你使用 sprite = new CCspirte的话,那么就等于内存交给你自己管理
你注意看CCsprite的头文件描述,我记得明确说明了他是一个autorelease 的obj,所以关于sprite的内存管理你可以完全交给cocos2d-x来运作
级别: 新手上路
可可豆: 0 CB
威望: 0 点
在线时间: 0(时)
发自: Web Page
[quote][size=2][color=#999999]juckerpp 发表于
16:15[/color] [url=forum.php?mod=redirect&goto=findpost&pid=8691&ptid=3525][img]static/image/common/back.gif[/img][/url][/size]
因为你new了一个新的对象,如果你用的是spritewithxxxx,就等于将内存交给了cocos2d-x去管理
如果你使用 spr ...[/quote]但是我看CCSprite源码里面spriteWithXXX也是通过先new一个对象出来,然后在给加个autorelease再返回的:
CCSprite* CCSprite::spriteWithFile(const char *pszFileName)
{
CCSprite *pobSprite = new CCSprite();
if (pobSprite && pobSprite->initWithFile(pszFileName))
pobSprite->autorelease();
return pobS
CC_SAFE_DELETE(pobSprite);
return NULL;
}
跟自己去:
CCSprite *sprite = new CCS
sprite->autorelease();
中间有什么差别吗? 新手初学...求指导...非常谢谢
级别: 新手上路
可可豆: 0 CB
威望: 0 点
在线时间: 0(时)
发自: Web Page
这中间的过程我还没细研究哈,因为我知道他内部肯定会各种析构,所以我一般会用
spritewithfile或者spritewithframename来建立我的精灵
狠少new
级别: 新手上路
可可豆: 0 CB
威望: 0 点
在线时间: 0(时)
发自: Web Page
[quote][size=2][color=#999999]juckerpp 发表于
21:40[/color] [url=forum.php?mod=redirect&goto=findpost&pid=8722&ptid=3525][img]static/image/common/back.gif[/img][/url][/size]
这中间的过程我还没细研究哈,因为我知道他内部肯定会各种析构,所以我一般会用
spritewithfile或者spritew ...[/quote]嗯嗯 我也只是觉得:
CCSprite *sprite = CCSprite::spriteWithFile("Button1.png");
sprite->retain();
没手动release一次的话,vld应该给我一个leak的提示。。。
级别: 新手上路
可可豆: 0 CB
威望: 0 点
在线时间: 0(时)
发自: Web Page
还是没搞懂.....
级别: 新手上路
可可豆: 0 CB
威望: 0 点
在线时间: 0(时)
发自: Web Page
CCSprite *sprite = CCSprite::spriteWithFile("Button1.png");
sprite->retain();
retain代表你要使用一段之后,再交给cocos2d-x的内存池去释放这个对象,也就是说,你retain了一下,cocos2d-x后台就会+1,这个+1代表你的使用次数
也就是说你下文如果
sprite->xxxxx();
那么这个count就会-1
然后cocos2d-x的内存管理机制检测到count为0的时候,就会认定他为autorelease的对象,pool就会将它release掉,所以你在vld里估计是不会有leak的
级别: 新手上路
可可豆: 0 CB
威望: 0 点
在线时间: 0(时)
发自: Web Page
[quote]是如果这样写:
CCSprite *sprite = new CCS
sprite->autorelease();
sprite->retain();
没有调用release的话就会报:
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 3 at 0x: 456 bytes ----------
Call Stack:
f:cocos2d-xzlsr_3_bearzlsr_3_bearclasseshelloworldscene.cpp (45): Zlsr_3_bear.win32.exe!HelloWorld::init + 0xA bytes
........
.........
Visual Leak Detector detected 1 memory leak (492 bytes).
Largest number used: 900 bytes.
Total allocations: 900 bytes.
Visual Leak Detector is now exiting.
[/quote]
我的理解是,首先你告诉pool,这是一个交给你自动管理的对象。
然后你又让pool将它的count+1
然后pool就认为你还要用。。
然后报leak了。。
你可以做一个测试
1.就是retain之后在用一次
2.retain之后不用
看看分别是否报leak。。
总之他的内存pool的原理就是给每个对象加一个count来管理
Pages: 1/3
关注本帖(如果有新回复会站内信通知您)
苹果公司现任CEO是谁?2字 正确答案:库克
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版VisualStudio 使用Visual Leak Detector检查内存泄漏
投稿:hebedich
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了VisualStudio 使用Visual Leak Detector检查内存泄漏的相关资料,需要的朋友可以参考下
那么在Windows下有什么好的内存泄漏检测工具呢?微软提供Visual Studio开发工具本身没有什么太好的内存泄漏检测功能,我们可以使用第三方工具Visual Leak Detector(以下简称vld)。
vld工具是VC++环境下一款小巧易用、免费开源的内存泄漏检测工具,vld可以显示导致内存泄漏的完整内存分配调用堆栈。vld的检测报告能够对每个内存泄漏点提供完整的堆栈跟踪,并且包含其源文件及行号信息。
安装过程是,先在到地址下载vld安装文件,然后进行安装,安装过程中需要安装程序会配置环境变量。我们需要记住安装目录。
安装完成后打开要检测的Visual Studio工程,我们需要在工程中配置:vld头文件目录和vld库目录。
选中游戏工程,打开菜单“项目”→ “属性”弹出工程属性对话框,如图所示,选择“配置属性”→“VC++目录” →“常规”,在右边的“包含目录”中添加C:\Program Files (x86)\Visual Leak Detector\include,其中C:\Program Files (x86)\Visual Leak Detector是我的vld安装目录。“库目录”中添加C:\Program Files (x86)\Visual Leak Detector\lib\Win32,注意配置目之间需要用分号分隔开。
配置完成之后点击确定按钮关闭对话框,然后我们需要在程序代码中引入头文件#include &vld.h&,但是这个头文件在哪里引入比较好?如果是普通的一个VC++工程在哪里引入都无所谓,但是Cocos2d-x的工程就不同了,我们需要考虑跨平台,#include &vld.h&代码不宜添加到Classes目录下的h或cpp文件中,这个目录下的文件是要在其它平台编译运行的,而#include &vld.h&只是在Windrows平台才有效。我们可以在Win32目录(见图)下的main.cpp或main.h文件引入头文件。这些文件是与Win32平台有关的,不同平台移植的时候不需要。
如果在main.cpp中引入代码如下:
#include "main.h"
#include "AppDelegate.h"
#include "cocos2d.h"
#include &vld.h&
USING_NS_CC;
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
lpCmdLine,
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// create the application instance
return Application::getInstance()-&run();
引入之后,就测试一下了,我们来人为制造一个内存泄漏,与20.1.1一节一样在HelloWorldScene.cpp中修改代码:
bool HelloWorld::init()
if ( !Layer::init() )
__String *s = new __String();
log("%s",s-&getCString());
运行工程,需要注意的是在程序运行过程中vld是没有堆栈输出的,但是日志会有输出vld的安装信息,日志信息如下:
Visual Leak Detector Version 2.4RC2 installed.
Ready for GLSL
Ready for OpenGL 2.0
从日志中可以看到vld是否安装成功,以及安装的版本。要想看到vld检测报告需要退出程序后,才会在日志中输出信息。使用Cocos2d-x会输出很多日志信息,信息如下:
---------- Block 526166 at 0x bytes ----------
Leak Hash: 0x780B2033, Count: 1, Total 84 bytes
Call Stack (TID 4660):
---------- Block 526214 at 0x bytes ----------
Leak Hash: 0xE1DC1852, Count: 1, Total 8 bytes
Call Stack (TID 4660):
63 6F 63 6F
73 32 64 20
61 75 74 6F
72 65 6C 65
cocos2d. autorele
61 73 65 20
70 6F 6F 6C
00 CD CD CD
CD CD CD CD
ase.pool ........
Visual Leak Detector detected 33 memory leaks (2892 bytes).
Largest number used: 3204961 bytes.
Total allocations:
Visual Leak Detector is now exiting.
其中一个Block表示一个内存泄漏点,在众多Block如果能够找到关于我们自己类的日志信息呢?我们可以查找关键字“helloworldscene.cpp”,这就可以定位到HelloWorld场景中的内存泄漏的Block了,我们找到如下日志信息:
---------- Block 1153 at 0x bytes ----------
Leak Hash: 0x5545A5ED, Count: 1, Total 48 bytes
Call Stack (TID 2088):
f:\dd\vctools\crt_bld\self_x86\crt\src\new.cpp (57): MSVCR110D.dll!operator new
d:\helloworld\classes\helloworldscene.cpp (33): HelloWorld.exe!HelloWorld::init + 0x7 bytes
d:\helloworld\classes\helloworldscene.h (37): HelloWorld.exe!HelloWorld::create + 0xB1 bytes
d:\helloworld\classes\helloworldscene.cpp (12): HelloWorld.exe!HelloWorld::createScene + 0x5 bytes
d:\helloworld\classes\appdelegate.cpp (30): HelloWorld.exe!AppDelegate::applicationDidFinishLaunching + 0x5 bytes
d:\helloworld\cocos2d\cocos\2d\platform\win32\ccapplication.cpp (74): HelloWorld.exe!cocos2d::Application::run + 0xF bytes
d:\helloworld\proj.win32\main.cpp (19): HelloWorld.exe!wWinMain + 0xC bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (528): HelloWorld.exe!__tmainCRTStartup + 0x15 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (377): HelloWorld.exe!wWinMainCRTStartup
0x7563850D (File and line number not available): KERNEL32.DLL!BaseThreadInitThunk + 0xE bytes
0x77B7BF39 (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x85 bytes
0x77B7BF0C (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0x58 bytes
1C 34 07 01
01 00 00 00
27 00 00 00
00 00 00 00
.4...... '.......
2C 34 07 01
A0 77 01 03
00 CD CD CD
CD CD CD CD
,4...w.. ........
CD CD CD CD
CD CD CD CD
00 00 00 00
0F 00 00 00
........ ........
从这个日志中能看到内存泄漏点,从日志的堆栈中找到我们自己编写的类,点击那一行打开代码窗口,定位内存泄漏点代码,如图所示。
定位内存泄漏点
找到哪一个有可能有内存泄漏,解决就不是问题了。
以上所述就是本文的全部内容了,希望大家能够喜欢。
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具}

我要回帖

更多关于 如何检测内存泄漏 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信