Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 725
Drake Avatar asked Oct 15 '22 00:10

Drake


People also ask

How do I find a memory leak without Valgrind?

In non-memory leak detection mode you pass through directly to malloc and free, and in memory leak detection mode you first log the alloc and free calls and then call through to malloc and free. When the program finishes you match up the allocations and frees, and you'll see where you're leaking memory.

Is Valgrind only for Linux?

Note: Valgrind is Linux only. If you aren't running Linux, or want a tool designed from the start to make debugging segfaults and memory issues easier, check out Cee Studio, a fully online C and C++ development environment from our sponsor.

Does Valgrind work on WSL?

Valgrind memcheck Valgrind Memcheck is a tool for detecting memory-usage problems such as leaks, invalid memory access, incorrect freeing, and referencing undefined values. Valgrind integration in CLion works on Linux, macOS, and Windows via WSL (see Valgrind on WSL).


1 Answers

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

like image 117
Lailin Chen Avatar answered Oct 16 '22 14:10

Lailin Chen