Valgrind can be used to bebug and profile applications. A variety of tools are supported [ --tool=...]. Popular tools are memcheck (the default) to check for memory leaks, cachegrind reporting cache utilization, and callgrind profiling. Here is the basic usage information along with an example showing memcheck: # load the module module load valgrind
# target istanbul for cache matchup [ cachegrind ] cc -g -hcpu=istanbul stream.c
# run with valgrind ( --tool=cachegrind is also ok )
aprun -n 1 valgrind ./a.out
# output:
==28378== Memcheck, a memory error detector ==28378== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==28378== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info ==28378== Command: ./a.out ...
==28379== in use at exit: 0 bytes in 0 blocks ==28379== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==28379== ==28379== All heap blocks were freed -- no leaks are possible ==28379== ==28379== For counts of detected and suppressed errors, rerun with: -v ==28379== Use --track-origins=yes to see where uninitialised values come from ==28379== ERROR SUMMARY: 2183 errors from 89 contexts (suppressed: 0 from 0) ==28378== Use of uninitialised value of size 8 ==28378== at 0x201D51CB: __run_exit_handlers (exit.c:78) ==28378== ==28378== ==28378== HEAP SUMMARY: ==28378== in use at exit: 0 bytes in 0 blocks ==28378== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==28378== ==28378== All heap blocks were freed -- no leaks are possible ==28378== ==28378== For counts of detected and suppressed errors, rerun with: -v ==28378== Use --track-origins=yes to see where uninitialised values come from ==28378== ERROR SUMMARY: 185 errors from 7 contexts (suppressed: 0 from 0) Application 5648105 resources: utime ~11s, stime ~0s, Rss ~106824, inblocks ~114 34, outblocks ~223 |