Development/Tools/Valgrind: Difference between revisions
< Development | Tools
(add some basic instructions about using valgrind for memleak checking) |
(use {{file}}) |
||
Line 9: | Line 9: | ||
As valgrind can produce a lot of output (and thus scroll out of your terminal), you can call valgrind redirecting its output to a file, so nothing gets lost. | As valgrind can produce a lot of output (and thus scroll out of your terminal), you can call valgrind redirecting its output to a file, so nothing gets lost. | ||
> valgrind --tool=memcheck --leak-check=yes -v ''appname'' 2>&1 | tee | > valgrind --tool=memcheck --leak-check=yes -v ''appname'' 2>&1 | tee valgrind.log | ||
This will call valgrind as seen above, and will redirect all the output coming from both our application and valgrind to a file in the current directory | This will call valgrind as seen above, and will redirect all the output coming from both our application and valgrind to a file in the current directory called {{file|valgrind.log}} (of course it is possible to use any file name of the log). | ||
=== Minor tweaks === | === Minor tweaks === |
Revision as of 14:11, 7 March 2007
Valgrind is a tool to analyze a program regarding memory leaks.
Leak Detection
One of the valgrind tools is the memcheck, that can be used to detect memory leaks during the execution of an application.
To do that, valgrind can be started as:
> valgrind --tool=memcheck --leak-check=yes -v appname
where appname is the application you want to run, including its parameters, if it have to be called with any.
As valgrind can produce a lot of output (and thus scroll out of your terminal), you can call valgrind redirecting its output to a file, so nothing gets lost.
> valgrind --tool=memcheck --leak-check=yes -v appname 2>&1 | tee valgrind.log
This will call valgrind as seen above, and will redirect all the output coming from both our application and valgrind to a file in the current directory called Template:File (of course it is possible to use any file name of the log).
Minor tweaks
- executing valgrind with --leak-check=full instead of --leak-check=yes can give a more detailed output, especially about the found leaks