473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Can't detect memory leaks properly.

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
Nov 16 '05 #1
2 4519
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/is...200/bugslayer/

Nov 16 '05 #2
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".

"Peter Strĝiman" <blah@blahblahblah> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
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

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Generic Usenet Account | last post by:
I have been using STL for a long time now, without any problems. Recently we generated a purification report on our software using Rational Purify, and we found some memory leaks. My colleague...
2
by: rythm | last post by:
I read a some doumentation about avoiding Memory Leaks. Like use the Dispose method properly, creating and using variable and objects in a certain way. However, my question is how do I find Memory...
19
by: lihua | last post by:
Hi, Group! I got one question here: We all know that fclose() must be called after file operations to avoid unexpected errors.But there are really cases when you forget to do that!Just like...
8
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? ...
0
by: Frank Lopez | last post by:
Does anyone know if Microsoft generated a whitepaper on this topic? Does anyone know what the solution is? (meaning, eliminate the leak problem -- I am seeing three memory leaks from...
2
by: ASP.Confused | last post by:
How would I go about detecting a memory leak? My web hosting provider has our site set up to only have a root "bin" folder for .NET apps, and I would like to be able to watch how much memory is...
23
by: James | last post by:
The following code will create memory leaks!!! using System; using System.Diagnostics; using System.Data; using System.Data.SqlClient; namespace MemoryLeak
16
by: Pedro Graca | last post by:
I have a file with different ways to write numbers ---- 8< (cut) -------- 0: zero, zilch,, nada, ,,,, empty , void, oh 1: one 7: seven 2: two, too ---- >8 -------------- ...
48
by: Ward Bekker | last post by:
Hi, I'm wondering if the GC.Collect method really collects all objects possible objects? Or is this still a "smart" process sometimes keeping objects alive even if they can be garbage collected?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.