Valgrind is a dynamic analysis tool for Linux, FreeBSD, macOS, Android, and Solaris systems. It can be used for execution and data profiling as well as for finding memory leaks, race conditions, and threading errors.
Valgrind is an open source instrumentation framework for building dynamic analysis tools. It was originally developed on Linux and has since been ported to other UNIX-like systems. There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail. You can also use Valgrind to build new tools.
Valgrind works by effectively running your code in a virtual machine where extra instrumentation is available to monitor the behavior of your code in detail.
When instrumenting your code you should compile with debug symbols, like -g2
or -g3
; and you should lower optimizations, like -O0
or -O1
. Higher optimizations sometimes produce false positives. Also see The Valgrind Quick Start Guide.
Available GUIs frontends:
- valkyrie
- KDevelop lets you use Valgrind as a plugin
- Eclipse has a GUI plugin to integrate Valgrind into its C++ Development Tools
- Qt Creator can use memcheck and callgrind.
There are several tools for visualizing the Valgrind output
- kcachegrind. This can be used with the performance profiling tools cachegrind and callgrind. It can also be used with the xtree output of memcheck and massif.
- massif visualizer Displays memory profiles generated by massif
- an online massif visualizer