System information

200 System Analysis and Tuning Guide
massif
A heap profiler. Heap is an area of memory used for dynamic memory allocation.
This tool helps you tune your program to use less memory.
lackey
An example tool showing instrumentation basics.
17.3.4 Default Options
Valgrind can read options at start-up. There are three places which Valgrind checks:
1. The file .valgrindrc in the home directory of the user who runs Valgrind.
2. The environment variable $VALGRIND_OPTS
3. The file .valgrindrc in the current directory where Valgrind is run from.
These resources are parsed exactly in this order, while later given options take
precedence over earlier processed options. Options specific to a particular Valgrind
tool must be prefixed with the tool name and a colon. For example, if you want
cachegrind to always write profile data to the /tmp/cachegrind_PID.log,
add the following line to the .valgrindrc file in your home directory:
--cachegrind:cachegrind-out-file=/tmp/cachegrind_%p.log
17.3.5 How Valgrind Works
Valgrind takes control of your executable before it starts. It reads debugging informa-
tion from the executable and related shared libraries. The executable's code is redi-
rected to the selected Valgrind tool, and the tool adds its own code to handle its de-
bugging. Then the code is handed back to the Valgrind core and the execution contin-
ues.
For example, memcheck adds its code, which checks every memory access. As a
consequence, the program runs much slower than in the native execution environ-
ment.
Valgrind simulates every instruction of your program. Therefore, it not only checks
the code of your program, but also all related libraries (including the C library), li-
braries used for graphical environment, and so on. If you try to detect errors with Val-