Using Valgrind
Valgrind is a powerful toolset that can help to debug programs especially for memory-related issues.
A few references:
- Valgrind Official Site
- Kcachegrind Project Site
- How to profile C++ application with Callgrind / KCacheGrind
Frequently Used Commands
- Install the tool
# valgrind
$ sudo apt-get install valgrind
# useful tools that can be used together with valgrind
$ sudo apt-get install kcachegrind graphviz
- Memory error check
# quick check
$ valgrind <name-of-executable>
# full memory leak check
$ valgrind --leak-check=full <name-of-executable>
- Program profiling