内存泄漏问题,请高手回答

zhaomaster 2005-07-21 01:21:46
Dumping objects ->
{408} normal block at 0x003C9870, 50 bytes long.
Data: <OM5UKM2OPVYC93WF> 4F 4D 35 55 4B 4D 32 4F 50 56 59 43 39 33 57 46
{406} normal block at 0x003C8FE0, 50 bytes long.
Data: <24ITP6B417VQ5O66> 32 34 49 54 50 36 42 34 31 37 56 51 35 4F 36 36
Object dump complete.

怎样用工具查出,是dll的内存泄漏,还是自己的程序泄漏的?
怎样找这个地址?
...全文
175 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
gohappy_1999 2005-07-22
  • 打赏
  • 举报
回复
1.双击这些提示信息,就可以跳转到具体的代码处
2。不能跳转的话,装个BoundsChecker
sjjf 2005-07-22
  • 打赏
  • 举报
回复
另外一种不用工具的方法,把你调用的dll部分用一个简单的替换实现(确定替换中没有泄漏)。
如果还有泄漏,那么就是 程序的问题 如果没有那就是dll的问题。
AntonlioX 2005-07-22
  • 打赏
  • 举报
回复
up
wangk 2005-07-22
  • 打赏
  • 举报
回复
Setting a Breakpoint on a Memory Allocation Number
The filename and line number in the memory leak report tell you where leaked memory is allocated, but knowing where the memory is allocated is not always sufficient to identify the problem. Often an allocation will be called many times during a run of the program, but it may leak memory only on certain calls. To identify the problem, you need to know not only where the leaked memory is allocated but also the conditions under which the leak occurs. The piece of information that allows you to do this is the memory allocation number. This is the number that appears in braces after the filename and line number when those are displayed. For example, in the following output, the memory allocation number is 18. It means that the leaked memory is the 18th block of memory allocated in your program.

Detected memory leaks!
Dumping objects ->
C:\PROGRAM FILES\VISUAL STUDIO\MyProjects\leaktest\leaktest.cpp(20) : {18}
normal block at 0x00780E80, 64 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
The CRT library counts all memory blocks allocated during a run of the program, including memory allocated by the CRT library itself or by other libraries such as MFC. Therefore, an object with allocation number N will be the Nth object allocated in your program but may not be the Nth object allocated by your code. (In most cases, it will not be.)

You can use the allocation number to set a breakpoint at the location where memory is allocated. To do this, set a location breakpoint near the start of your program. When your program breaks at that point, you can set such a memory-allocation breakpoint from the QuickWatch dialog box or the Watch window.

To set a memory-allocation breakpoint in the Watch window

In the Watch window, type the following expression in the Name column:
_crtBreakAlloc
If you are using the multithreaded DLL version of the CRT library (the /MD option), include the context operator, as shown here:

{,,msvcr71d.dll}_crtBreakAlloc
Press RETURN.
The debugger evaluates the call and places the result in the Value column. This value will be –1 if you have not set any breakpoints on memory allocations.

Replace the value in the Value column with the allocation number of the memory allocation where you want to break. For example, 18 to break at the allocation shown in the output above.
After you set breakpoints on the memory allocations you are interested in, you can continue debugging. Be careful to run the program under the same conditions as the previous run so that the allocation order does not change. When your program breaks at the specified memory allocation, you can look at the Call Stack window and other debugger information to determine the conditions under which the memory was allocated. If necessary, you can continue execution of the program from that point to see what happens to the object and perhaps determine why it is not properly deallocated.

Note Setting a data breakpoint on the object may be helpful. For more information, see Breakpoint Operations in a Source Window and Inserting a New Breakpoint from the Debug Menu.
Although it is usually easier to set memory-allocation breakpoints in the debugger, you can set them in your code, if you prefer.

To set a memory-allocation breakpoint in your code

Add a line like this (for the 18th memory allocation):
_crtBreakAlloc = 18;
Alternately, you can use the _CrtSetBreakAlloc function, which has the same effect:

_CrtSetBreakAlloc(18);
会思考的草 2005-07-22
  • 打赏
  • 举报
回复
装一个boundschecker.
flyhigh 2005-07-21
  • 打赏
  • 举报
回复
boundschecker
qrlvls 2005-07-21
  • 打赏
  • 举报
回复
建议写一个小的使用 dll 的软件来排除 dll 泄漏的可能性
DentistryDoctor 2005-07-21
  • 打赏
  • 举报
回复
50 bytes long,你可以估计一下是什么数据类型
DentistryDoctor 2005-07-21
  • 打赏
  • 举报
回复
向楼主推荐一本书
Windows程序调试(Debugging Windows Programs)
DentistryDoctor 2005-07-21
  • 打赏
  • 举报
回复
0x003C9870
0x003C8FE0

?

编译时生成一个.map文件,查看一下.map文件就可以找到源代码相应的位置了。
booklove 2005-07-21
  • 打赏
  • 举报
回复
debug呀,运行时的地址,你申请的时候记下地址不就知道了。
没有纸笔就用记事本了。

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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