Results 1 to 3 of 3

Thread: Question about detecting memory leaks!

  1. #1
    Join Date
    Jun 2010
    Posts
    31
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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(7 7) : {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 why VS2008 doesn't show that messages by developing qt apps?

    Thanks a lot,
    jack

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question about detecting memory leaks!

    In visual studio you can enable some memory analysis features (causes your code to become slower). It could be that the memory analysis is automagically enabled to some extent when building an MFC application.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Jun 2010
    Posts
    31
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Question about detecting memory leaks!

    Quote Originally Posted by franz View Post
    In visual studio you can enable some memory analysis features (causes your code to become slower). It could be that the memory analysis is automagically enabled to some extent when building an MFC application.
    Where are the analysis features? Then I can check this.

    Thanks.

Similar Threads

  1. QT Memory Leaks
    By lukabratzi in forum Qt Programming
    Replies: 17
    Last Post: 28th February 2012, 21:01
  2. Memory Leaks
    By kaushal_gaurav in forum Qt Programming
    Replies: 4
    Last Post: 20th October 2008, 17:26
  3. Memory leaks..
    By santhoshv84 in forum Qt Programming
    Replies: 2
    Last Post: 28th August 2008, 20:28
  4. memory leaks
    By Fastman in forum Qt Programming
    Replies: 1
    Last Post: 5th March 2008, 09:00
  5. why there are memory leaks in Qt?
    By cocalele in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2006, 10:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.