Alex Rivera | Logout

Memory leak detectors for C?

Asked 2008-09-10T04:47:57.697
35

What memory leak detectors have people had a good experience with?

Here is a summary of the answers so far:

Valgrind - Instrumentation framework for building dynamic analysis tools.

Electric Fence - A tool that works with GDB

Splint - Annotation-Assisted Lightweight Static Checking

Glow Code - This is a complete real-time performance and memory profiler for Windows and .NET programmers who develop applications with C++, C#, or any .NET Framework

Also see this stackoverflow post.

Edit
Report

2 Answers

2

Also worth using if you're on Linux using glibc is the built-in debug heap code. To use it, link with -lmcheck or define (and export) the MALLOC_CHECK_ environment variable with the value 1, 2, or 3. The glibc manual provides more information.

This mode is most useful for detecting double-frees, and it often finds writes outside the allocated memory area when doing a free. I don't think it reports leaked memory.

answered 2008-11-11T19:22:37.723
0

At university when I was doing most things under Unix Solaris I used gdb.

However I would go with valgrind under Linux.

answered 2008-09-10T05:46:47.197

Your Answer