Using valgrind with daemons


#1

Valgrind is a great tool for memory leak detection and profiling. It also helps to find other possible problems in your program. Creating valgrind-free programs (without any important valgrind warnings) is a good practice to improve your coding skills.

It is possible to use valgrind against daemons. When you start a daemon through valgrind, valgrind process also becomes a daemon. In order to get outputs of valgrind, you need to give an output file name with –log-file parameter. It is also good to give –trace-children parameter to continue tracing forked childrens. You can start valgrind as below:

valgrind --log-file=/tmp/debug.log \
         --trace-children=yes \
         --track-origins=yes <daemon-path> <daemon-params>

See man page: http://manpages.org/valgrind