Valgrind is a programming tool for memory debugging, memory leak detection, and profiling. The default tool is Memcheck, which can detect many memory-related errors that are common in C and C++ programs and that can lead to crashes and unpredictable behaviour. If you wish to run your program through valgrind, you should make sure it has been built with the -g compiler option, so it includes al the necessary debug information, and without optimisations.
The most basic usage is:
No Format |
---|
valgrind --leak-check=yes <your program> |
...