检测到内存泄漏 [英] Detected memory leaks

查看:89
本文介绍了检测到内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的wxWidgets应用程序中,以调试模式运行时,我在Visual Studio 2010的输出中收到了此消息.该应用程序运行良好,并且仅在关闭后才看到此消息.

In my wxWidgets application, while running in debug mode i got this message in Output of Visual Studio 2010. The application ran fine, and i only saw this after closing it.

检测到内存泄漏!

Detected memory leaks!

转储对象->

{9554}正常块,位于0x003CDCC0,长44个字节.
数据:< e n d> 20 C1 65 01 01 00 00 00 6E 00 00 00 9C CE 64 01

{9554} normal block at 0x003CDCC0, 44 bytes long.
Data: < e n d > 20 C1 65 01 01 00 00 00 6E 00 00 00 9C CE 64 01

{9553}正常块,位于0x003CDB58,长8个字节.

{9553} normal block at 0x003CDB58, 8 bytes long.

数据:< D e< > 44 BD 65 01 C0 DC 3C 00
{9552}正常块,位于0x003CDC50处,长48个字节.

Data: < D e < > 44 BD 65 01 C0 DC 3C 00
{9552} normal block at 0x003CDC50, 48 bytes long.

数据:< e> A0 95 65 01 01 00 00 00 19 00 00 00 19 00 00 00

Data: < e > A0 95 65 01 01 00 00 00 19 00 00 00 19 00 00 00

对象转储完成.

在我的程序中,我没有显式分配内存,但是wxWidgets框架却在.我是第一次收到这样的消息,但不知道其确切原因.

In my program i am not explicitly allocating memory, however the wxWidgets framework is. I have got such a message for first time, and don't know the exact cause of it.

如何摆脱这种内存泄漏?

How can i get rid of this memory leak?

推荐答案

您只需在主函数的开头添加以下几行.添加此标志后,Visual Studio将在创建内存泄漏的行处中断.

You just have to add the following lines at the beginning of your main function. Adding this flag, Visual Studio will break at the line that is creating the memory leak.

    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
    _CrtSetBreakAlloc(9554);
    _CrtSetBreakAlloc(9553);
    _CrtSetBreakAlloc(9552);

确保您具有正确的对象普通块地址,因为它们可能会更改,并确保您在_DEBUG上进行编译.

Make sure you have the correct object normal block address because they might change and ensure you are compiling on _DEBUG.

另请参见: _CrtSetDbgFlag _CrtSetBreakAlloc .

这篇关于检测到内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆