Use valgrind to debug C/C++ applications

For simple debugging:

./valgrind program

To detect memory leaks:

./valgrind --leak-check=full program

Use the flag -g3 to compile the application with gcc (or g++)

After the compilation run your application with the following flags:

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

Leave a Reply