Nautilus Software

Valgrind

Category: Tools-Debugger

Description

Valgrind is an instrumentation framework for
building dynamic analysis tools. 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.

The Valgrind distribution currently includes five production-quality
tools: a memory error detector, a thread error detector, a cache and
branch-prediction profiler, a call-graph generating cache profiler,
and a heap profiler. It also includes two experimental tools: a data
race detector, and an instant memory leak detector.

The Valgrind tool suite provides a number of debugging and
profiling tools. The most popular is Memcheck, a memory checking tool
which can detect many common memory errors such as:

Note that programs running under Valgrind run significantly more
slowly, and use much more memory -- e.g. more than twice as much as
normal under the Memcheck tool.

Please consult the Valgrind FAQ and the
Valgrind
User Manual, which
have much more information. Note that the other tools in the Valgrind
distribution can be invoked with the --tool option.

Use

This package is unsupported.
The checks that come with the package do not pass.
If you run into problems, report them but please understand this
is unsupported.

To use valgrind, load the valgrind module.

module avail valgrind
module load valgrind/3.4.1

Once the valgrind module is loaded, you can check out the valgrind
manpage for usage information. What follows below is a simple use
case of valgrind.

Compile your program with "-g". Using -O0 is also a good idea, if
you can tolerate the slowdown. With -O1 line numbers in error messages
can be inaccurate, although generally speaking Memchecking code
compiled at -O1 works fairly well. Use of -O2 and above is not
recommended as Memcheck occasionally reports uninitialised-value
errors which don't really exist.

If you normally run your program like this:

myprog arg1 arg2

Use this command line:

valgrind --leak-check=yes myprog arg1 arg2

Memcheck is the default tool. The --leak-check option turns on the
detailed memory leak detector.