Skip to content
Chris Hunt edited this page Sep 24, 2013 · 4 revisions

an instrumentation framework for building dynamic analysis tools

Designed to help debug memory, cache and threading errors through run time analysis of your executables. Actually a set of 6 tools, the default is Memcheck - the one most commonly used and perfect for finding Segfaults!

Links

Hints and Tips

  • Don't use Memcheck with python! It is possible but it involves recompiling the python binaries with different options, and a suppression file with to clean up the errors. Python runs everything on the heap and does not use the standard new or delete functions, hence Valgrind struggles to track the memory usage.
  • There are multiple tools within Valgrind. Give 'em a go! (Memcheck, Cachegrind, Callgrind, Massif, Helgrind, DRD)
  • !!ROOT!!: Root has many issues with memory leaks. The option --supress= allows you to specify a file that defines a bunch of rules to suppress output from valgrind for known issues. This file can be found at $ROOTSYS/etc/valgrind-root.supp of your ROOT distribution.

Using Memcheck

  • To run, do:
valgrind [VALGRIND-OPTIONS] EXECUTABLE-NAME [EXECUTABLE-OPTIONS]
  • Memcheck can:
    • Inform you of issues with use of the heap (dynamically allocated memory, arrays going off the end)
    • Pinpoint memory leaks (for example, new a pointer but never call delete on it)
  • Useful options for valgrind:
    • --track-origins=yes Shows the origins of the allocated memory associated with the errors
    • --leak-check=full More detailed description of the heap in use at the end of program
    • --tool=<name> Choose your debugging tool
Clone this wiki locally