first install valgrind, its newest ver is 3.11, and stops updating since 2015/12.

in centos, yum installs 3.10 ver.

using valgrind ./buggy.out to execute memcheck tool in valgrind, other useful tools can be found in the man page.

specify --leak-check=full before program will print verbose info about mem-leak's malloc info.

however, valgrind only uses binary file to scan mem-errors, so something like buffer-overrun near the address will likely to be missed.

some said specify -fsanitize=address while compiling using gcc/ver 4.8 or clang will discover this problem(or clang 3.1+..), but seems not working too..

the --tool=exp-sgcheck checks buffer-overrun problems.. from this page..

Monitor heap-profiler: using massif tool:

valgrind --tool=massif ./prog.out will produce massive.out.pid file. Using ms_print massive.out.pid to print the result in graph style.

04-15 08:28