DELAEMON BLOG

Live as if you were to die tomorrow. Learn as if you were to live forever.

valgrind on Fedora22

Valgrind is an instrumentation framework for building dynamic analysis tools.
Valgrind Home

インストール

$ sudo dnf install valgrind

メモリリーク検出

$ valgrind --leak-check=full ./fib
==4784== Memcheck, a memory error detector
==4784== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==4784== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==4784== Command: ./fib
==4784==
832040
==4784==
==4784== HEAP SUMMARY:
==4784==     in use at exit: 0 bytes in 0 blocks
==4784==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==4784==
==4784== All heap blocks were freed -- no leaks are possible
==4784==
==4784== For counts of detected and suppressed errors, rerun with: -v
==4784== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

ヒーププロファイラ

$ valgrind --tool=massif ./fib
==4805== Massif, a heap profiler
==4805== Copyright (C) 2003-2013, and GNU GPL'd, by Nicholas Nethercote
==4805== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==4805== Command: ./fib
==4805==
832040
==4805==
$ ls -la massif.out.4805
-rw------- 1 dela dela 144 Feb  8 08:48 massif.out.4805
$ cat massif.out.4805
desc: (none)
cmd: ./fib
time_unit: i
#-----------
snapshot=0
#-----------
time=0
mem_heap_B=0
mem_heap_extra_B=0
mem_stacks_B=0
heap_tree=empty

コールグラフ

$ valgrind --tool=callgrind ./fib
==4837== Callgrind, a call-graph generating cache profiler
==4837== Copyright (C) 2002-2013, and GNU GPL'd, by Josef Weidendorfer et al.
==4837== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==4837== Command: ./fib
==4837==
==4837== For interactive control, run 'callgrind_control -h'.
832040
==4837==
==4837== Events    : Ir
==4837== Collected : 45872890
==4837==
==4837== I   refs:      45,872,890
$ ls -la callgrind.out.4837
-rw------- 1 dela dela 12618 Feb  8 08:49 callgrind.out.4837