Use valgrind to debug C/C++ applications

To compile the program use the following flags:

  • -g3
  • -O0 (optional)

To execute the program once you have compiled it:

./valgrind program

For extensive testing you could also use the following flags:

--leak-check=full
--show-leak-kinds=all 
--leak-resolution=high
--track-origins=yes --vgdb=yes

If you are creating threads you could also use one of following tools:

--tool=drd

or

--tool=helgrind

Leave a Reply