CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14
  1. #1
    Join Date
    May 2002
    Location
    Germany
    Posts
    451

    Memory leak detection tool with Windows7 64 bit Visual Studio

    Hello There,

    I have been through reading on what is available and would like to get some advise on tools you would recommend to find memory few leaks. My all time favorite is TotalView (it finds leaks in a click and shows the exact source line where the object was allocated - and works only on linux).
    I do need something else.
    The server application I am debugging runs about 300 threads at the same time, binds to 3 TCP ports and also does some network communication as client. It has a console GUI and a huge log file hard to follow. The problem is that it leaks memory - sometime. So there are requests which are served flawlessly but some leak for some reason.

    What I am after:
    1) Runs (and it is said to run) on windows 7 with Visual Studio 2010 (binaries built by VS2010 and pdb files it generated). That gets about 90% of tools excluded since most stopped with (or before) Vista/Visual Studio 2008 support.
    2) It gets to the line in the source code where the leaking object was allocated when the debugged application is stopped/paused. Click in the GUI of the tool and job done. Simple. Easy.
    3) There is no need for code insertion/inclusion of any extra header nor special build except for a debug build.
    4) Have the least features except for memory leak detection.

    What I found so far:
    1) About 10 tools what do not work/crash.
    2) Glow Code is the only one what works to some extent. It shows a number it says memory leaks detected. Right click on its Show source loads the class it identifies as leaking however - without getting to a line where the allocation was done. It is not very helpful when the file is over 2,000 lines long.
    The rest of tools quoted in different forums/different discussions just did not work (some did not even start on windows 7).
    3) An announcement that BoundsChecker will be sold over again so it is not convincing.
    4) A few words on Insure++ (I did not try that particular one).

    Thanks

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Memory leak detection tool with Windows7 64 bit Visual Studio

    Quote Originally Posted by luftwaffe View Post
    Hello There,

    I have been through reading on what is available and would like to get some advise on tools you would recommend to find memory few leaks.
    Unfortunately, there aren't a lot of tools for 64-bit leak detection. Most of the major players such as Purify and BoundsChecker are stuck in the 32-bit world with their current Windows software.

    I don't know if Insure++ has a 64-bit version, but get ready to pay about twice as much as for Purify or BoundsChecker. That product is one of the most, if not most expensive tool out of the bunch. It's a good product, but the price is prohibitive (if price is important).

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    May 2002
    Location
    Germany
    Posts
    451

    Re: Memory leak detection tool with Windows7 64 bit Visual Studio

    Continuing reading on Isure++, I found: http://www.parasoft.com/jsp/products....jsp?itemId=63

    They support up to VS 2008.

    Might it be possible that there are no supported memory leak checkers for VS 2010 at all?

  4. #4
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Memory leak detection tool with Windows7 64 bit Visual Studio

    Do you use VC++ built-in memory leaks detection? Using _CrtSetDbgFlag and redefinition of new to DEBUG_NEW gives full list of leaked allocations. It doesn't show call stack - this is the only advantage of another tools like BoundsChecker.

  5. #5
    Join Date
    May 2002
    Location
    Germany
    Posts
    451

    Re: Memory leak detection tool with Windows7 64 bit Visual Studio

    That requires code modification, and that is exactly what I would like to avoid. The code is based on Qt and there is no chance to replace all allocation calls with microsoft specific stuff. Also, code portability is required as platform may change (what I will be recommending anyway if there is not memory debugger available at all).
    I am really surprised, TotalView just a couple hundred bucks and does it perfectly on linux. Is it impossible on Windows, or... is it better than actual coding can take longer and requires instrumentation in the code? Hmm, I cannot find the right words to explain - maybe disappointment is a good one. :O

  6. #6
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Memory leak detection tool with Windows7 64 bit Visual Studio

    Most Windows leak tracking tools show a huge logs containing a lot of unnecessary statistics, everything you can think about, except your own memory leaks.
    In my cross-platform project (UI is written with wxWidgets) I have the following lines in every .cpp file, after all # include lines:
    Code:
    #ifdef WIN32
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #endif
    #endif
    DEBUG_NEW is defines as:

    Code:
    #ifdef WIN32
    
    #include "crtdbg.h"
    
    #ifdef _DEBUG
    #ifndef DEBUG_NEW
    #define DEBUG_NEW   new( _NORMAL_BLOCK, __FILE__, __LINE__)
    #endif
    #else
    #ifndef DEBUG_NEW
    #define DEBUG_NEW
    #endif
    #endif
    
    #else
    
    #ifndef DEBUG_NEW
    #define DEBUG_NEW
    #endif
    
    #endif          // WIN32
    In the program initialization code:
    Code:
    #ifdef WIN32
    #include <crtdbg.h>
    #endif
    
    ...
    
    #ifdef WIN32
        _CrtSetDbgFlag( _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
    #endif
    This is quite enough for me to track memory leaks in Windows. I don't use any leak tracking Linux tool since all leaks are detected and fixed in Windows.

  7. #7
    Join Date
    May 2002
    Location
    Germany
    Posts
    451

    Re: Memory leak detection tool with Windows7 64 bit Visual Studio

    Thank you, I will give it a try.

  8. #8
    Join Date
    Nov 2011
    Posts
    21

    Re: Memory leak detection tool with Windows7 64 bit Visual Studio

    You should use VC++ built-in memory leaks detection or deleaker...

  9. #9
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Memory leak detection tool with Windows7 64 bit Visual Studio

    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  10. #10
    Join Date
    Mar 2001
    Posts
    2,529

    Re: Memory leak detection tool with Windows7 64 bit Visual Studio

    Doesn't anybody search the CG site anymore?

    http://www.codeguru.com/forum/showthread.php?t=518382
    ahoodin
    To keep the plot moving, that's why.

  11. #11
    Join Date
    Jan 2012
    Location
    Belleville, Michigan, USA
    Posts
    13

    Re: Memory leak detection tool with Windows7 64 bit Visual Studio

    Quote Originally Posted by luftwaffe View Post
    An announcement that BoundsChecker will be sold over again so it is not convincing.
    "Will be sold over again?" We never really stopped, though our former corporate owners certainly seemed to be trying to kill us off...

    Anyway, BoundsChecker is part of the DevPartner Studio product, and has been for many years. This product is available from Micro Focus, through Component Source. The current version (10.5.3) runs on Windows from XP X86 SP3 and XP X64 SP2, through Windows 7 X86 and X64 SP1, including server versions of the system. It integrates with Visual Studio 2005, 2008 and 2010, and (minus the integration) supports Visual Studio 6 and 2003. Both 32-bit and 64-bit target processes are supported.

    We've been working on bringing the product back to reasonable currency, and expect to ship a new version when Microsoft ships it's next version of Visual Studio. The product works better now than it has in many years, probably since the 2005 time frame.

  12. #12
    Join Date
    Nov 2011
    Posts
    21

    Arrow Re: Memory leak detection tool with Windows7 64 bit Visual Studio


  13. #13
    Join Date
    Aug 2014
    Posts
    7

    Thumbs up Re: Memory leak detection tool with Windows7 64 bit Visual Studio

    Quote Originally Posted by Paul McKenzie View Post
    Unfortunately, there aren't a lot of tools for 64-bit leak detection.
    Deleaker supports x64 now.

  14. #14
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Memory leak detection tool with Windows7 64 bit Visual Studio

    As AlexF says it's enough to call CrtSetDbgFlag in main to get leakage information. If you wan't to get more information (such as allocation line of code) you have to do the other stuff he mentions
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured