Results 1 to 4 of 4

Thread: Memory debugging in windows

  1. #1
    Join Date
    Nov 2008
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Memory debugging in windows

    Hello,

    I am developing a windows application with QT using its Eclipse integration.

    I am currently using Wu Yongwei's memory leak detector (http://wyw.dcweb.cn/leakage.htm), as recommended at MinGW site, but it seems to have problems with QT.

    Some memory leaks are detected in a simple application with only a MainWindow with a pair of simple widgets. All these leaks appear at ui_*.h files, generated by QT. I have edited these files and I can see that there is a "new" for each widget attatched to the MainWindow and that there is no "delete" for it.

    I'd like to know if:

    - QT is freeing that memory itself (and my memory leak detector has problems for detecting it).

    - QT leaves the memory allocated because windows will free it when the application is finished (so any memory leak detector will tell me about this memory).

    If it's the first case, can you recommend a memory leak detector for windows that can be used with MinGW that get rid of that memory leaks?

    If it's the second, do you know any way to "filter" the leaks detected in order to hide the ones produced by QT? It's quite annoying seeing lots of them

    Thanks in advance,

  2. #2
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Memory debugging in windows

    If you create a widget on the heap (using "new") as child of a different widget (using the "parent" argument of the constructor) Qt will delete the child widget for you if you delete the parent widget.
    This principle works with complete "widget trees". There is exactly one root widget in a tree. Deleting this widget will result of deletion of all widgets in that tree.

    Most likely your leak detection tool doen't know this and sees many "new newWidget( parentWidget );" statements without corresponding delete statements.

  3. The following user says thank you to Boron for this useful post:

    txandi (9th January 2009)

  4. #3
    Join Date
    Nov 2008
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Memory debugging in windows

    Ok, thanks...

    So, now, can someone recommend a memory leak detector for windows that can be used with MinGW that doesn't get confused with QT widget's deletion?

  5. #4
    Join Date
    Nov 2008
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Memory debugging in windows

    Still waiting...

Similar Threads

  1. Debugging in Windows
    By hardgeus in forum Qt Programming
    Replies: 3
    Last Post: 13th November 2008, 08:14
  2. Problem debugging Windows QT App w/ GDB
    By JDTexas in forum Qt Programming
    Replies: 4
    Last Post: 2nd March 2008, 09:02
  3. ide which supports debugging qt4.3.3 in windows
    By sakthi in forum Qt-based Software
    Replies: 2
    Last Post: 28th January 2008, 13:36
  4. Program crashes with assert error in xcb_lock.c
    By Valheru in forum Qt Programming
    Replies: 3
    Last Post: 18th November 2007, 20:56
  5. KDE 3.5.0 crash while opening project
    By MarkoSan in forum KDE Forum
    Replies: 2
    Last Post: 19th October 2007, 17:21

Tags for this Thread

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.