[c] Is there a good Valgrind substitute for Windows?

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.

This question is related to c windows debugging memory-leaks valgrind

The answer is


Try Intel's Inspector XE product which can help you detect both memory and threading issues: http://software.intel.com/en-us/articles/intel-inspector-xe/


I've been loving Memory Validator, from a company called Software Verification.


The Boost Test library can detect memory leaks.


More or less all Profilers include checking for memory leaks and show you the stack when the memory was allocated.

I can recommend Intels Parallel Inspector. Simple to use and no recompilation needed. The trial version runs for 30 days.

GlowCode and AtromatedQA also include such capabilites. They all offer free trials.

Compuware DevPartner (aka BoundsChecker) in Contrast needs a slowed down "instrumentation" recompile and the application also runs slower when checking for errors. And BoundsChecker can not work with 64 Bit evsrions at all. We gave up on that tool.


In combination with Visual Studio I generally use Visual Leak Detector or simply _CrtDumpMemoryLeaks() which is a win32 api call. Both are nothing fancy but they get the job done.


Viusual Studio can help detecting memory leaks itself. See Microsoft Visual C++ Tips and Tricks -> "Memory Leaks" section. See also this post in SO

Although real tracing is only possible with the Team Edtion of Visual Studio.


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/.


How about the Purify?


See the "Source Test Tools" link on the Software QA Testing and Test Tool Resources page for a list of similar tools.

I've used BoundsChecker,DevPartner Studio and Intel V-Tune in the past for profiling. I liked V-Tune the best; you could emulate various Intel chipsets and it would give you hints on how to optimize for that platform.


I had the chance to use Compuware DevPartner Studio in the past and that was really good, but it's quite expensive. A cheaper solution could be GlowCode, i just worked with a 5.x version and, despite some problems in attaching to a process i needed to debug, it worked quite well.


The best tool I ever used is DevPartner BoundsChecker - it's not free but it has an evaluation period.


There is Pageheap.exe part of the debugging tools for Windows. It's free and is basically a custom memory allocator/deallocator.

See http://support.microsoft.com/kb/286470


Perhaps CodeSnitch would be something you're after? http://www.entrek.com/codesnitch.html


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


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


Definitely Purify! I've used that to analyze some massive code bases (>3,000 kSLOC) and found it to be excellent.

You might like to look at this list at Wikipedia.

By the way, I've found memwatch to be useful. Thanks Johan!


Development environment for Windows you are using may contain its own tools. Visual Studio, for example, lets you detect and isolate memory leaks in your programs


If you're not afraid of mingw, here are some links (some might work with MSVC)... http://betterlogic.com/roger/?p=1140


Does Jochen Kalmbach's Memory Leak Detector qualify?

PS: The URL to the latest version is buried somewhere in the article's comment thread.


I found this SF project today:

http://sourceforge.net/p/valgrind4win/wiki/Home/

They are porting valgrind to Windows. Probably in several years we will have a reliable valgrind on windows.


Just an idea, you could also implement a memory allocator and track all calls to malloc and free. However this might be too much for some projects.


Perhaps CodeSnitch would be something you're after? http://www.entrek.com/codesnitch.html


Definitely Purify! I've used that to analyze some massive code bases (>3,000 kSLOC) and found it to be excellent.

You might like to look at this list at Wikipedia.

By the way, I've found memwatch to be useful. Thanks Johan!


I had the chance to use Compuware DevPartner Studio in the past and that was really good, but it's quite expensive. A cheaper solution could be GlowCode, i just worked with a 5.x version and, despite some problems in attaching to a process i needed to debug, it worked quite well.


Try DUMA


LeakDiag, UMDH, App Verifier, DebugDiag, are all useful tools to improve robustness of code and find memory leaks.


The Boost Test library can detect memory leaks.


The user-mode dump heap (UMDH) utility works with the operating system to analyze Windows heap allocations for a specific process. That's a pretty good tool for free from Microsoft. Here is a mini tutorial "How to use Umdh.exe to find memory leaks".


If you are developing with Borland/CodeGear/Embarcadero C++ Builder, you could use CodeGuard.


Development environment for Windows you are using may contain its own tools. Visual Studio, for example, lets you detect and isolate memory leaks in your programs


Check out this question: Is there a good Valgrind substitute for Windows? . Though general substitute for valgrind is asked, it mainly discusses memory leak detectors and not race conditions detections.


You might want to read what Mozilla is doing regarding memory leaks. One tool in their toolbox is the Hans Boehm garbage collector used as memory leak detector.


We are just completing a Memory Safety checking tool for Windows, that handles GCC and Micrsoft Visual C (not C++ yet), and are looking for Beta testers.

EDIT June 12, 2011: Not Beta anymore, now production for GCC and Microsoft Visual Studio C.


How about the Purify?


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++


I used Insure++ which does excellent job in finding c++ memory leaks/corruptions and many other bugs like uninitialized variables, pointer errors, strings etc., It also does visual "Code coverage" and run time memory usage etc.. which give more confident on your code.. You can try it for trail version..


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/.


I had the chance to use Compuware DevPartner Studio in the past and that was really good, but it's quite expensive. A cheaper solution could be GlowCode, i just worked with a 5.x version and, despite some problems in attaching to a process i needed to debug, it worked quite well.


Development environment for Windows you are using may contain its own tools. Visual Studio, for example, lets you detect and isolate memory leaks in your programs


Try Intel's Inspector XE product which can help you detect both memory and threading issues: http://software.intel.com/en-us/articles/intel-inspector-xe/


You can take a look to the article Design and Implementation of an In-Game Memory Profiler in the book "Game Programming Gems 8".

It shows how to implement a low overhead semi-intrusive real-time memory profiler, source code provided in the CD-ROM.

enter image description here


In combination with Visual Studio I generally use Visual Leak Detector or simply _CrtDumpMemoryLeaks() which is a win32 api call. Both are nothing fancy but they get the job done.


I had the chance to use Compuware DevPartner Studio in the past and that was really good, but it's quite expensive. A cheaper solution could be GlowCode, i just worked with a 5.x version and, despite some problems in attaching to a process i needed to debug, it worked quite well.


LeakDiag, UMDH, App Verifier, DebugDiag, are all useful tools to improve robustness of code and find memory leaks.


Parasoft Insure++ has always been reliable:

http://www.parasoft.com/jsp/products/insure.jsp?itemId=63


We are just completing a Memory Safety checking tool for Windows, that handles GCC and Micrsoft Visual C (not C++ yet), and are looking for Beta testers.

EDIT June 12, 2011: Not Beta anymore, now production for GCC and Microsoft Visual Studio C.



Another memory tool for your list: Memory Validator.

Not free, but nowhere near as expensive as Purify or Boundschecker.


Check out this question: Is there a good Valgrind substitute for Windows? . Though general substitute for valgrind is asked, it mainly discusses memory leak detectors and not race conditions detections.


Try DUMA


Clang supports the Address Sanitizer plugin (-faddress-sanitizer option), which can pretty much detect most bugs that Valgrind can find (does not support detection of uninitialised memory reads and memory leaks yet though). See this page for a comparison against Valgrind and other similar tools. An official Windows port is currently in progress, see Windows ASan port.

I attempted to build it myself on Windows a couple of months ago and gave up, see my related question. Things may have changed for the better now if you want to give it another go.


You can give a try to RuntimeChecker trial ot to IBM Purify trial..

A free solution would be to use the following code in Visual Studio:

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

Just write this in the top of all your cpp files. This will detect memory leaks of your application whenc stopping debug run and list them in the output window. Double clicking on a memory leaks line will higlight you the line where memory is allocated and never released. This may help you : http://www.flipcode.com/archives/How_To_Find_Memory_Leaks.shtml


See the "Source Test Tools" link on the Software QA Testing and Test Tool Resources page for a list of similar tools.

I've used BoundsChecker,DevPartner Studio and Intel V-Tune in the past for profiling. I liked V-Tune the best; you could emulate various Intel chipsets and it would give you hints on how to optimize for that platform.


I've been loving Memory Validator, from a company called Software Verification.


Just an idea, you could also implement a memory allocator and track all calls to malloc and free. However this might be too much for some projects.


I used Insure++ which does excellent job in finding c++ memory leaks/corruptions and many other bugs like uninitialized variables, pointer errors, strings etc., It also does visual "Code coverage" and run time memory usage etc.. which give more confident on your code.. You can try it for trail version..


See the "Source Test Tools" link on the Software QA Testing and Test Tool Resources page for a list of similar tools.

I've used BoundsChecker,DevPartner Studio and Intel V-Tune in the past for profiling. I liked V-Tune the best; you could emulate various Intel chipsets and it would give you hints on how to optimize for that platform.


You can give a try to RuntimeChecker trial ot to IBM Purify trial..

A free solution would be to use the following code in Visual Studio:

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

Just write this in the top of all your cpp files. This will detect memory leaks of your application whenc stopping debug run and list them in the output window. Double clicking on a memory leaks line will higlight you the line where memory is allocated and never released. This may help you : http://www.flipcode.com/archives/How_To_Find_Memory_Leaks.shtml


More or less all Profilers include checking for memory leaks and show you the stack when the memory was allocated.

I can recommend Intels Parallel Inspector. Simple to use and no recompilation needed. The trial version runs for 30 days.

GlowCode and AtromatedQA also include such capabilites. They all offer free trials.

Compuware DevPartner (aka BoundsChecker) in Contrast needs a slowed down "instrumentation" recompile and the application also runs slower when checking for errors. And BoundsChecker can not work with 64 Bit evsrions at all. We gave up on that tool.


Development environment for Windows you are using may contain its own tools. Visual Studio, for example, lets you detect and isolate memory leaks in your programs


Perhaps CodeSnitch would be something you're after? http://www.entrek.com/codesnitch.html


If you are developing with Borland/CodeGear/Embarcadero C++ Builder, you could use CodeGuard.


I found this SF project today:

http://sourceforge.net/p/valgrind4win/wiki/Home/

They are porting valgrind to Windows. Probably in several years we will have a reliable valgrind on windows.


There is Pageheap.exe part of the debugging tools for Windows. It's free and is basically a custom memory allocator/deallocator.

See http://support.microsoft.com/kb/286470


I've been loving Memory Validator, from a company called Software Verification.


See the "Source Test Tools" link on the Software QA Testing and Test Tool Resources page for a list of similar tools.

I've used BoundsChecker,DevPartner Studio and Intel V-Tune in the past for profiling. I liked V-Tune the best; you could emulate various Intel chipsets and it would give you hints on how to optimize for that platform.


Viusual Studio can help detecting memory leaks itself. See Microsoft Visual C++ Tips and Tricks -> "Memory Leaks" section. See also this post in SO

Although real tracing is only possible with the Team Edtion of Visual Studio.


If you're not afraid of mingw, here are some links (some might work with MSVC)... http://betterlogic.com/roger/?p=1140


The user-mode dump heap (UMDH) utility works with the operating system to analyze Windows heap allocations for a specific process. That's a pretty good tool for free from Microsoft. Here is a mini tutorial "How to use Umdh.exe to find memory leaks".


Another memory tool for your list: Memory Validator.

Not free, but nowhere near as expensive as Purify or Boundschecker.


The best tool I ever used is DevPartner BoundsChecker - it's not free but it has an evaluation period.


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++

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


I've been loving Memory Validator, from a company called Software Verification.


The free tool DebugDiag will help find memory and handle leaks.

You don't need to augument your program for DebugDiag to work.

http://www.microsoft.com/downloads/details.aspx?FamilyID=28BD5941-C458-46F1-B24D-F60151D875A3&displaylang=en

Although it is not the easiest or most intuitive program to use! Make sure you google for tutorials and instructions on how to use it.


Clang supports the Address Sanitizer plugin (-faddress-sanitizer option), which can pretty much detect most bugs that Valgrind can find (does not support detection of uninitialised memory reads and memory leaks yet though). See this page for a comparison against Valgrind and other similar tools. An official Windows port is currently in progress, see Windows ASan port.

I attempted to build it myself on Windows a couple of months ago and gave up, see my related question. Things may have changed for the better now if you want to give it another go.


Parasoft Insure++ has always been reliable:

http://www.parasoft.com/jsp/products/insure.jsp?itemId=63


Does Jochen Kalmbach's Memory Leak Detector qualify?

PS: The URL to the latest version is buried somewhere in the article's comment thread.


You might want to read what Mozilla is doing regarding memory leaks. One tool in their toolbox is the Hans Boehm garbage collector used as memory leak detector.


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


You can take a look to the article Design and Implementation of an In-Game Memory Profiler in the book "Game Programming Gems 8".

It shows how to implement a low overhead semi-intrusive real-time memory profiler, source code provided in the CD-ROM.

enter image description here


The free tool DebugDiag will help find memory and handle leaks.

You don't need to augument your program for DebugDiag to work.

http://www.microsoft.com/downloads/details.aspx?FamilyID=28BD5941-C458-46F1-B24D-F60151D875A3&displaylang=en

Although it is not the easiest or most intuitive program to use! Make sure you google for tutorials and instructions on how to use it.


Perhaps CodeSnitch would be something you're after? http://www.entrek.com/codesnitch.html


Examples related to c

conflicting types for 'outchar' Can't compile C program on a Mac after upgrade to Mojave Program to find largest and second largest number in array Prime numbers between 1 to 100 in C Programming Language In c, in bool, true == 1 and false == 0? How I can print to stderr in C? Visual Studio Code includePath "error: assignment to expression with array type error" when I assign a struct field (C) Compiling an application for use in highly radioactive environments How can you print multiple variables inside a string using printf?

Examples related to windows

"Permission Denied" trying to run Python on Windows 10 A fatal error occurred while creating a TLS client credential. The internal error state is 10013 How to install OpenJDK 11 on Windows? I can't install pyaudio on Windows? How to solve "error: Microsoft Visual C++ 14.0 is required."? git clone: Authentication failed for <URL> How to avoid the "Windows Defender SmartScreen prevented an unrecognized app from starting warning" XCOPY: Overwrite all without prompt in BATCH Laravel 5 show ErrorException file_put_contents failed to open stream: No such file or directory how to open Jupyter notebook in chrome on windows Tensorflow import error: No module named 'tensorflow'

Examples related to debugging

How do I enable logging for Spring Security? How to run or debug php on Visual Studio Code (VSCode) How do you debug React Native? How do I debug "Error: spawn ENOENT" on node.js? How can I inspect the file system of a failed `docker build`? Swift: print() vs println() vs NSLog() JavaScript console.log causes error: "Synchronous XMLHttpRequest on the main thread is deprecated..." How to debug Spring Boot application with Eclipse? Unfortunately MyApp has stopped. How can I solve this? 500 internal server error, how to debug

Examples related to memory-leaks

AngularJS - Does $destroy remove event listeners? Implementing IDisposable correctly Best way to increase heap size in catalina.bat file If a DOM Element is removed, are its listeners also removed from memory? Resource leak: 'in' is never closed android activity has leaked window com.android.internal.policy.impl.phonewindow$decorview Issue This Handler class should be static or leaks might occur: IncomingHandler possible EventEmitter memory leak detected performSelector may cause a leak because its selector is unknown How can I create a memory leak in Java?

Examples related to valgrind

C free(): invalid pointer How to redirect Valgrind's output to a file? How to use the addr2line command in Linux? Proper way to initialize C++ structs How do I use valgrind to find memory leaks? Still Reachable Leak detected by Valgrind pinpointing "conditional jump or move depends on uninitialized value(s)" valgrind message Is there a good Valgrind substitute for Windows?