Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / December 2003

Tip: Looking for answers? Try searching our database.

Can't detect memory leaks properly.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Str?iman - 01 Dec 2003 15:24 GMT
Hi.

I have a project that leaks :(
I tried using the _crtDumpMemoryLeaks function, and I get the memory leaks
written to the output window, but it doesn't show the correct source file.
Instead it shows the following:
---
Detected memory leaks!
Dumping objects ->
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\crtdbg.h(689)
: {53} normal block at 0x00FD28C0, 112 bytes long.
Data: < G G G G > 94 47 08 10 98 47 08 10 9C 47 08 10 A0 47 08 10
--
And that isn't really very helpful.

The objects that leaks are COM objects implemented using ATL ( It's a
VC++6.0 project that has been loadied into VS2003 - but the code is still
pretty much the same ).
The objects that leak are allocated using the CComObject< T
>::CreateInstance function.

I have the following specification in my stdafx.h file

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

I have included malloc.h before crtdbg.h because otherwise the compiler
fails when I have atlbase.h included after crtdbg.h
I have also tried this

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

With the same result.

Can anybody help me to get the correct source code line get displayed in my
debug output?

Thanks in advance,
Peter Str?iman
Mihajlo Cvetanovic - 02 Dec 2003 08:58 GMT
Peter Strøiman wrote:
> I have a project that leaks :(
> I tried using the _crtDumpMemoryLeaks function, and I get the memory leaks
> written to the output window, but it doesn't show the correct source file.

Look for the Tip 40 from
http://msdn.microsoft.com/msdnmag/issues/1200/bugslayer/
Leon Finker - 07 Dec 2003 01:16 GMT
Check atl7+:  atldbgmem.h
#include <windows.h>
#include <atldbgmem.h>
#include <atlbase.h>

At the end call: AtlDumpMemoryLeaks();

This tracks: malloc/new/HeapAlloc/VirtualAlloc

For VirtualAlloc it only reports "Memory operation".

> Hi.
>
[quoted text clipped - 41 lines]
> Thanks in advance,
> Peter Str?iman

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.