Results 1 to 5 of 5

Thread: Qt4 & Visual Studio memory leak detection

  1. #1
    Join Date
    Nov 2006
    Posts
    86
    Thanks
    6
    Thanked 14 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Qt4 & Visual Studio memory leak detection

    I was trying to use Visual Studios's built in memory leak detection according to
    http://msdn2.microsoft.com/en-us/lib...h3(VS.80).aspx
    but when I compile my project I get errors in the Qt library:

    help!?
    Paul

    Qt Code:
    1. 2>c:\devel\code\3rdparty\qt-4.3.3\src\corelib\tools\qbytearray.h(332) : warning C4003: not enough actual parameters for macro 'realloc'
    2. 2>c:\devel\code\3rdparty\qt-4.3.3\src\corelib\tools\qbytearray.h(332) : error C2059: syntax error : ','
    3. 2>c:\devel\code\3rdparty\qt-4.3.3\src\corelib\tools\qbytearray.h(365) : warning C4003: not enough actual parameters for macro 'realloc'
    4. 2>c:\devel\code\3rdparty\qt-4.3.3\src\corelib\tools\qbytearray.h(365) : error C2059: syntax error : ','
    5. 2>c:\devel\code\3rdparty\qt-4.3.3\src\corelib\tools\qbytearray.h(379) : warning C4003: not enough actual parameters for macro 'realloc'
    6. 2>c:\devel\code\3rdparty\qt-4.3.3\src\corelib\tools\qbytearray.h(379) : error C2059: syntax error : ','
    7. 2>c:\devel\code\3rdparty\qt-4.3.3\src\corelib\tools\qbytearray.h(382) : warning C4003: not enough actual parameters for macro 'realloc'
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Nov 2006
    Posts
    86
    Thanks
    6
    Thanked 14 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt4 & Visual Studio memory leak detection

    Ah, figures, the MS header stuff has to be after all the Qt stuff. To bad it still doesn't work right.

    Paul
    Last edited by thomaspu; 22nd January 2008 at 04:03.

  3. #3
    Join Date
    Jan 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt4 & Visual Studio memory leak detection

    I can recommend Visual Leak Detector for memory leak detection, works very well for me.

  4. #4
    Join Date
    Nov 2006
    Posts
    86
    Thanks
    6
    Thanked 14 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt4 & Visual Studio memory leak detection

    Huh, I just tried to use it and it couldn't catch any memory leaks at all. I even started putting in memory leaks on purpose, and each time it kept saying "No memory leaks detected."

    You really use this? It doesn't seem to work worth a darn. For instance, this code should leak pretty badly.
    Qt Code:
    1. #include "vld.h"
    2. int main () {
    3. char *pChar = new char[30];
    4. pChar = 0;
    5. int *pInt = new int;
    6. return 0;
    7. }
    To copy to clipboard, switch view to plain text mode 
    Yet the output on the visual studio says:
    Visual Leak Detector Version 1.9f installed.
    No memory leaks detected.
    Visual Leak Detector is now exiting.

    Doesn't seem to work at all.
    Paul

  5. #5
    Join Date
    Nov 2006
    Posts
    86
    Thanks
    6
    Thanked 14 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt4 & Visual Studio memory leak detection

    What sucks is that using Visual Studio's method, it picks up the memory leaks just fine, but doesn't tell me where in the world they originated from!
    Qt Code:
    1. #define _CRTDBG_MAP_ALLOC
    2. #include <stdlib.h>
    3. #include <crtdbg.h>
    4. int main () {
    5. _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
    6.  
    7. char *pChar = new char[30];
    8. pChar = 0;
    9. int *pInt = new int;
    10. return 0;
    11. }
    To copy to clipboard, switch view to plain text mode 
    Detected memory leaks!
    Dumping objects ->
    {61} normal block at 0x00335FD8, 4 bytes long.
    Data: < > CD CD CD CD
    {60} normal block at 0x00332A00, 30 bytes long.
    Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
    Object dump complete.
    The program '[1380] exceptions.exe: Native' has exited with code 0 (0x0).
    Anyone know what I'm doing wrong here?
    Paul

Similar Threads

  1. Memory leak detection
    By Sid in forum Qt Programming
    Replies: 8
    Last Post: 4th May 2011, 22:38
  2. Replies: 2
    Last Post: 23rd November 2007, 17:44
  3. Qt configure with msvc.net
    By jivanr in forum Installation and Deployment
    Replies: 1
    Last Post: 11th June 2007, 08:17
  4. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 13:15
  5. Qt Designer & Visual Studio 2005
    By pSiCho in forum Qt Tools
    Replies: 6
    Last Post: 9th February 2006, 13:40

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.