为什么_CrtDumpMemoryLeaks不报告代码位置

Herro 2007-10-27 05:33:25
如下代码


#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

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



输出为:
Detected memory leaks!
Dumping objects ->
{63} normal block at 0x003A6B58, 1024 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.

不显示任何代码位置,这样我无法调试。

我用的是VS 2005,非托管。

请问如何解决?谢谢。
...全文
851 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
lyhylex 2011-12-04
  • 打赏
  • 举报
回复
同样问题
hjd1056 2010-03-30
  • 打赏
  • 举报
回复
楼主可以查一下:win32下内存泄漏的检测。会找到需要使用一个叫debug_new.h的文件,将这个文件添加到工程中,再使用 _CrtDumpMemoryLeaks(),就能显示具体代码了
shanhqk 2007-10-27
  • 打赏
  • 举报
回复
_CrtSetBreakAlloc(63);
可以使用这个方法来判断具体的位置,前提是:分配的地址是固定的

Herro 2007-10-27
  • 打赏
  • 举报
回复
贴错了
是“test2.exe”: 已加载“D:\test2\Debug\test2.exe”,已加载符号。
Herro 2007-10-27
  • 打赏
  • 举报
回复
to DentistryDoctor :
我试了你那个工具,依旧无法显示:

“test.exe”: 已加载“D:\test2\Debug\test.exe”,已加载符号。
WARNING: Visual Leak Detector: A module, test2.exe, included in memory leak detection
does not have any debugging symbols available, or they could not be located.
Function names and/or line numbers for this module may not be available.
Visual Leak Detector Version 1.9d installed.

WARNING: Visual Leak Detector detected memory leaks!
---------- Block 0 at 0x00526CC8: 1024 bytes ----------
Call Stack:
0x004113C8 (File and line number not available): (Function name unavailable)
0x00411956 (File and line number not available): (Function name unavailable)
0x0041179D (File and line number not available): (Function name unavailable)
0x7C816FD7 (File and line number not available): RegisterWaitForInputIdle
凤矶 2007-10-27
  • 打赏
  • 举报
回复
{63} normal block at 0x003A6B58, 1024 bytes long.
---------------------------------------------
前面没显示文件名,但双击定位应该可以找到吧
DentistryDoctor 2007-10-27
  • 打赏
  • 举报
回复
用VLD
http://www.codeproject.com/tools/visualleakdetector.asp

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧