Table of Contents

Valgrind

General options

Syntax: valgrind [options] <your-program> <args>

Tools

Memcheck

Memory checker (default tool).

Syntax: valgrind [–tool=memcheck] [options] <your-program> <args>

Massif

Memory profiling.

Syntax: valgrind –tool=massif [options] <your-program> <args> ; ms_print massif.<pid>

Callgrind

Performance profiling, to find time taken in functions and number of calls of functions.

Syntax: valgrind –tool=callgrind <program-compiled-O2> <args> ; kcachegrind callgrind.out.xxxx ; calgrind_control

Cachegrind

CPU cache profiling, to find cache misses.

Syntax: valgrind –tool=cachegrind <program-compiled-O2> <args>

Always do profiling with optimization options of compiler, or you could optimize things that the compiler already automatically does.