Is there a good Valgrind substitute for Windows?

366,459

Solution 1

Some more good commercial tools:

Solution 2

As jakobengblom2 pointed out, valgrind has a suit of tools. Depending which one you are talking about there are different windows counter parts. I will only mention OSS or free tools here.

1. MemCheck:

Dr. Memory. It is a relatively new tool, works very well on Windows 7. My favorite feature is that it groups the same leaks' allocation stacks in the report.

http://code.google.com/p/drmemory/

I have also used UMDH( http://support.microsoft.com/kb/268343 ) and found it quiet useful and easy to setup. It works from Win2000 to Win7.

AppVerifier is a must have swissknife for windows native code developers, its "memory" checker does similar job http://msdn.microsoft.com/en-us/library/dd371695%28v=vs.85%29.aspx

2. Callgrind:

My favorite is verysleepy ( http://www.codersnotes.com/sleepy ) It is tiny but very useful and easy to use.

If you need more features, AMD CodeAnalyst™ Performance Analyzer is free: http://developer.amd.com/documentation/videos/pages/introductiontoamdcodeanalystperformanceanalyzer.aspx

Windows Performance Analysis tools is free from Microsoft, not very easy to use but can get the job done if you are willing to spend the time. http://blogs.microsoft.co.il/blogs/sasha/archive/2008/03/15/xperf-windows-performance-toolkit.aspx Download: http://msdn.microsoft.com/en-us/performance/cc752957

3. Massif:

Similar(not quite exact match) free tools on windows are:

VMMap from sysinternals : http://technet.microsoft.com/en-us/sysinternals/dd535533

!heap command in windbg : http://hacksoflife.blogspot.com/2009/06/heap-debugging-memoryresource-leak-with.html

4. Cachegrind:

Above mentioned Windows Performance Tools has certain level of L2 cache miss profiling capability but not quite as good and easy to use as Cachegrind.

5. DRD:

Haven't found anything free and as powerful on Windows yet, the only free tool for windows I can find that is slightly close is the "lock" checker in AppVerifier: http://msdn.microsoft.com/en-us/library/dd371695%28v=vs.85%29.aspx

Solution 3

Why not use Valgrind + Wine to debug your Windows app? See http://wiki.winehq.org/Wine_and_Valgrind

(Chromium uses this to check the Windows version for memory errors; see build.chromium.org and look at the experimental or memory waterfalls, and search for wine.)

There's also Dr. Memory, see dynamorio.org/drmemory.html

Solution 4

For Visual C++, try Visual Leak Detector. When I used it, it detected a memory leak from a new call and returned the actual line in source code of the leak. The latest release can be found at http://vld.codeplex.com/.

Solution 5

i would like to list some tool , hope will be useful

read this article for more detail

  1. Purify
  2. Bounds Checker
  3. Coverity (basically its a code analyzer but, it will catch memory leak in static )
  4. Glow Code
  5. dmalloc
  6. ccmalloc
  7. NJAMD
  8. YAMD
  9. Valgrind
  10. mpatrol
  11. Insure++
Share:
366,459

Related videos on Youtube

Drake
Author by

Drake

Masters student in Information Security. I program in C, C++, Java, Perl and currently learning the ins and outs of Objective-C and iPhone development.

Updated on January 25, 2020

Comments

  • Drake
    Drake over 4 years

    I was looking into Valgrind to help improve my C coding/debugging when I discovered it is only for Linux - I have no other need or interest in moving my OS to Linux so I was wondering if there is a equally good program for Windows.

    • jakobengblom2
      jakobengblom2 over 14 years
      What kinds of debugging are you looking to do? Valgrind is quite a rich toolset, and the answers below point in all kinds of directions. With an emphasis on memory leak/allocation debugging.
    • Liran Orevi
      Liran Orevi over 14 years
      Maybe you can test the code on a virtual Linux machine inside your Windows, just when you need to check it. you can share the development folder between the virtual and non-virtual machine. that is, if the code is portable enough.
  • Norman Ramsey
    Norman Ramsey over 15 years
    Purify: venerable but still useful, as shown by how many changes of corporate ownership it has survived!
  • EvilTeach
    EvilTeach over 15 years
    Expensive yes. It paid back in one weekend, just using the profiler piece.
  • user9665
    user9665 about 15 years
    It is of very little practical use. It will log the filename/linenumber for offending allocations, but it's only informative if you call malloc directly. When using new/delete, it will unhelpfully pinpoint new.h as the "offending" code.
  • Rodrigo
    Rodrigo about 15 years
    It works correctly for me, pointing the right line even new/delete are used.
  • David Rodríguez - dribeas
    David Rodríguez - dribeas over 14 years
    Not really free... but I guess you could find a test license for testing purposes.
  • Bob
    Bob over 14 years
    I'd defintitely recommend glowcode. I've used it in the past to find an memory leak within a dll being called by my app.
  • Calyth
    Calyth over 14 years
    There were complaints of major slowdowns while using DevPartner at my last workplace. They do everything to avoid using it because of how slow it would be.
  • Alex Budovski
    Alex Budovski over 14 years
    But will it work if a library function allocates? E.g. strdup.
  • John Dibling
    John Dibling over 14 years
    Because then you wouldn't be debugging a Windows app - you'd be debugging a Linux app.
  • Dan Kegel
    Dan Kegel about 14 years
    No need to recompile in Wine. Just transfer your .exe and .pdb over to a Linux box. And you wouldn't be debugging a Linux app; you're debugging your exact Windows app.
  • the_mandrill
    the_mandrill almost 14 years
    Pageheap/gflags have helped me get to the bottom of some nasty heap corruption problems.
  • C.J.
    C.J. almost 14 years
    The Debug CRT, which is what you are trying to describe is useful for C code. Getting it to work for C++ code is more problematic.
  • C.J.
    C.J. almost 14 years
    Insure++ takes forever to instrument your code, and forever to execute your code at runtime.
  • Synetech
    Synetech over 13 years
    It does not seem to work for me. I even tried creating a simple project that did basically nothing other than to allocated some memory and not free it. VLD did not detect it. :-|
  • dwj
    dwj over 13 years
    Dead link as of 2011-02-04 for BoundsChecker.
  • relaxxx
    relaxxx about 13 years
    @Synetech inc. I had the same problem in VS2010... Using the newest version of VLD solved my problem
  • ideasman42
    ideasman42 over 12 years
    Valdrind does a lot more then find memory leaks, I mainly use it to find use of freed and uninitialized stack and heap memory which can be incredibly hard to debug otherwise.
  • Crashworks
    Crashworks over 12 years
    That's how most games do it. But it's a huge undertaking and a lot of instrumentation.
  • alexr
    alexr about 12 years
    There's also gperftools (formerly Google PerfTools). It's not a valgrind replacement (what is really) but it has a new malloc, cpu profiler, heap profiler and checker. Worth a look as it's support on Linux and Windows (inc Mingw) and other unices.
  • KindDragon
    KindDragon about 12 years
    @user9665 Visual Leak Detector (vld.codeplex.com) provide full callstack for each memory leak with minimal souce code changes. Check example on site
  • Jarekczek
    Jarekczek over 11 years
    I found gflags + gdb (from mingw) helpful in diagnosis.