[Qt-interest] Question about detecting memory leaks!

Tony Rietwyk tony.rietwyk at rightsoft.com.au
Thu Dec 16 01:37:43 CET 2010


Hi Jack, 
 
In non MFC applications, use Visual Leak Detector - google for it.  Note
that the latest version has a small problem, which requires you to copy the
32 or 64 bit dbghelp.dll from their folder into the same folder as your
application.  Otherwise it works really well and gives you stack traces of
each leaking call. 
 
Tony.
 
 

-----Original Message-----
From: qt-interest-bounces+tony.rietwyk=rightsoft.com.au at qt.nokia.com
[mailto:qt-interest-bounces+tony.rietwyk=rightsoft.com.au at qt.nokia.com] On
Behalf Of Jack Mack
Sent: Thursday, 16 December 2010 00:27
To: qt-interest at trolltech.com
Subject: [Qt-interest] Question about detecting memory leaks!


Hi all,

I have a question about detecting memory leaks in my qt based application.

I'm using Qt 4.7.0 with VS2008.

Maybe this is a simple question and I get a fast answer.
This is my snipped out code of my qt based application:

    int* a = new int;
    *a = 1;

When I start the app in debug-mode within VS2008 and finish the app
correctly by clicking the windows system menu then the output window of
VS2008 shows only some text like:

...
Thread 'Win32 Thread' (0xf68) finished with code 0 (0x0).
BTMMHOOK 15.12.2010 12:19:31 Thread<0460> Hook DLL unloaded
Thread 'Win32 Thread' (0x132c) finished with code 0 (0x0).
Program "[4052] LineView.exe: Systemown" finished with code 0 (0x0).

When I use the snipped code above in a simple MFC application and run it in
debug-mode and close it then the following text is showed by output window
of VS2008:

...
BTMMHOOK 15.12.2010 12:21:16 Thread<0E14> Hook DLL unloaded
Detected memory leaks!
Dumping objects ->
e:\entwicklung\simplemfc\simplemfc\simplemfc.cpp(77) : {565} normal block at
0x0034B790, 4 bytes long.
 Data: <    > 01 00 00 00 
Object dump complete.
Program "[2160] SimpleMFC.exe: Systemown" finished with code 0 (0x0).

I think that's strange! The compiler warning options are the same.
Yes, I know that all classed inherited by QObject are deleted automatically
and "delete" is not neccessary. But the snipped code above causes definitly
a memory leak.

Can someone explain that to me?

Thanks a lot,
jack
	

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101216/98421fcb/attachment.html 


More information about the Qt-interest-old mailing list