Re: Interpreting Visual C++ Object Dump.
- From: "Oleg Starodumov" <com-dot-debuginfo-at-oleg>
- Date: Fri, 28 Oct 2005 10:46:58 +0300
> Hi, I have a MFC program created in Visual Studio 6.0. I noticed the
> following message if I manually exiting the program while running from
> the debugger in the "debug tab":
>
> ========================================================================
> The thread 0x944 has exited with code 0 (0x0).
> Detected memory leaks!
> Dumping objects ->
> {54} normal block at 0x020227F8, 928 bytes long.
> Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
> CD
> ...
> I have little in interpretting object dump in this environment. Some of
> the questions that I have:
>
> 1). Do I need to enable some setting neither in the source code or in
> some menu of visual studio to even get this object dump message?
>
In MFC projects everything is already set up to enable memory leak detection.
In non-MFC projects you have to enable it manually, with the help
of some macros and _CrtSetDbgFlag function (for more information,
see the links below; MFC's approach can be used as a good sample).
> 2). Any recommendations of a good resource where I can learn about
> object dump messages/memory leak detection methods for visual studio?
>
http://www.microsoft.com/msj/1097/bugslayer.aspx
http://msdn.microsoft.com/library/en-us/vccore98/html/_core_solving_buffer_overwrites_and_memory_leaks.asp
http://groups.google.com/group/microsoft.public.vc.mfc/browse_frm/thread/73493ddec165a5cb
http://www.codeproject.com/tools/leakfinder.asp
> 3). Since I get this message when I exit the program and the fact I can
> run the program for days without crashing, does that mean the memory
> leak as described in the message only occur WHEN the program exits?
>
You can get much better statistics about memory usage and possible
memory/resource leaks with Performance Monitor (see Administrative Tools | Performance).
Monitor at least the following counters for your Process object and see how
they change while the application is running:
- Private Bytes
- Virtual Bytes
- Handle Count
- Thread Count
> 4). Any thoughts as to what the memory leak can come from? I am pretty
> good at initializing variables and when I can avoid do not use the new
> operator or the malloc function...The data being dumped in above seems
> to be alot of New Page and Carriage Returns....any thoughts on
> that?>
'CD' is the fill pattern used for uninitialized data in heap blocks allocated
from CRT library heap. It means that the leaked blocks are not initialized.
> .... and what does the "{number }" mean?
This is the "allocation request number", the serial number of the allocation
that was leaked. If the allocation numbers of the leaked blocks are persistent
(the same) between debugging sessions, you can set a breakpoint at the given
allocation number so that the debugger will break at the moment when the
problematic block is being allocated, so that you can see who is allocating it.
http://msdn.microsoft.com/library/en-us/vccore98/html/_core_tracking_heap_allocation_requests.asp
But in general, it is better to use a tool that can show you the call stacks
of the leaked allocations, e.g. LeakFinder (see the link above).
Regards,
Oleg
[VC++ MVP]
.
- References:
- Interpreting Visual C++ Object Dump.
- From: ratcharit
- Interpreting Visual C++ Object Dump.
- Prev by Date: Re: Heap block modified past requested size!
- Next by Date: Re: how to debug a dll containing a com object instantiated by a jscript called from a batch file
- Previous by thread: Interpreting Visual C++ Object Dump.
- Next by thread: RE: Heap block modified past requested size!
- Index(es):
Relevant Pages
|