Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

2.13. Valgrind

Valgrind provides a number of detection and profiling tools to help improve the performance of your applications. These tools can detect memory and thread-related errors, as well as heap, stack, and array overruns, letting you easily locate and correct errors in your application code. They can also profile the cache, the heap, and branch-prediction to identify factors that may increase application speed and minimize memory usage.
Valgrind analyzes your application by running it on a synthetic CPU and instrumenting existing application code as it is executed. It then prints commentary that clearly identifies each process involved in application execution to a user-specified file, file descriptor, or network socket. Note that executing instrumented code can take between four and fifty times longer than normal execution.
Valgrind can be used on your application as-is, without recompiling. However, because Valgrind uses debugging information to pinpoint issues in your code, if your application and support libraries were not compiled with debugging information enabled, Red Hat recommends recompiling to include this information.
Valgrind also integrates with the GNU Project Debugger (gdb) to improve debugging efficiency.
Valgrind and its subordinate tools are useful for memory profiling. For detailed information about using Valgrind to profile system memory, see Section 7.2.2, “Profiling Application Memory Usage with Valgrind”.
For detailed information about Valgrind, see the Red Hat Enterprise Linux 7 Developer Guide.
For detailed information about using Valgrind, see the man page:
$ man valgrind
Accompanying documentation can also be found in /usr/share/doc/valgrind-version when the valgrind package is installed.