Massif: a heap profiler
• Peak snapshots are only ever taken after a deallocation happens.
This avoids lots of unnecessary peak snapshot
recordings (imagine what happens if your program allocates a lot of heap blocks in succession, hitting a new peak
every time).
But it means that if your program never deallocates any blocks, no peak will be recorded.
It
also means that if your program does deallocate blocks but later allocates to a higher peak without subsequently
deallocating, the reported peak will be too low.
• Even with this behaviour, recording the peak accurately is slow. So by default Massif records a peak whose size
is within 1% of the size of the true peak.
This inaccuracy in the peak measurement can be changed with the
--peak-inaccuracy
option.
The following graph is from an execution of Konqueror, the KDE web browser.
It shows what graphs for larger
programs look like.
MB
3.952^
#
|
@#:
|
:@@#:
|
@@::::@@#:
|
@ :: :@@#::
|
@@@ :: :@@#::
|
@@:@@@ :: :@@#::
|
:::@ :@@@ :: :@@#::
|
: :@ :@@@ :: :@@#::
|
:@: :@ :@@@ :: :@@#::
|
@@:@: :@ :@@@ :: :@@#:::
|
:
::
::@@:@: :@ :@@@ :: :@@#:::
|
:@@:
::::: ::::@@@:::@@:@: :@ :@@@ :: :@@#:::
|
::::@@:
::: ::::::: @
:::@@:@: :@ :@@@ :: :@@#:::
|
@: ::@@:
::: ::::::: @
:::@@:@: :@ :@@@ :: :@@#:::
|
@: ::@@:
::: ::::::: @
:::@@:@: :@ :@@@ :: :@@#:::
|
@: ::@@:::::: ::::::: @
:::@@:@: :@ :@@@ :: :@@#:::
|
::@@@: ::@@:: ::: ::::::: @
:::@@:@: :@ :@@@ :: :@@#:::
|
:::::@ @: ::@@:: ::: ::::::: @
:::@@:@: :@ :@@@ :: :@@#:::
|
@@:::::@ @: ::@@:: ::: ::::::: @
:::@@:@: :@ :@@@ :: :@@#:::
0 +----------------------------------------------------------------------->Mi
0
626.4
Number of snapshots: 63
Detailed snapshots: [3, 4, 10, 11, 15, 16, 29, 33, 34, 36, 39, 41,
42, 43, 44, 49, 50, 51, 53, 55, 56, 57 (peak)]
Note that the larger size units are KB, MB, GB, etc. As is typical for memory measurements, these are based on a
multiplier of 1024, rather than the standard SI multiplier of 1000. Strictly speaking, they should be written KiB, MiB,
GiB, etc.
9.2.6. The Snapshot Details
Returning to our example, the graph is followed by the detailed information for each snapshot. The first nine snapshots
are normal, so only a small amount of information is recorded for each one:
141