Memory checkers
DUMA
- Detect Unintended Memory Access
http://duma.sourceforge.net/
- Fork and replacement for Electric Fence
- Stops your program on the exact instruction that overruns or underruns a malloc() memory buffer.
- GDB will then display the source-code line that causes the bug.
- Works by using the virtual-memory hardware to create a red-zone at the border of each buffer - touch that, and your program stops.
- Works on any platform supported by Linux, whatever the CPU (provided virtual memory support is available).
Valgrind
http://valgrind.org/
- GNU GPL Software suite for debugging and profiling programs.
- Supported platforms: Linux on x86, x86_64, ppc32, ppc64 and arm (armv7 only: Cortex A8, A9 and A5)
- Can detect many memory management and threading bugs.
- Profiler: provides information helpful to speed up your program and reduce its memory usage.
- The most popular tool for this usage. Even used by projects with hundreds of programmers.
- Can be used to run any program, without the need to recompile it.
- Example usage
valgrind --leak-check=yes ls -la
- Works by adding its own instrumentation to your code and then running in on its own virtual cpu core.
Significantly slows down execution, but still fine for testing!
- More details on http://valgrind.org/info/ and http://valgrind.org/docs/manual/ coregrind_core.html#howworks