Massif: a heap profiler
--alloc-fn=<name>
Functions specified with this option will be treated as though they were a heap allocation function such as
malloc
.
This is useful for functions that are wrappers to
malloc
or
new
, which can fill up the allocation trees with
uninteresting information. This option can be specified multiple times on the command line, to name multiple
functions.
Note that the named function will only be treated this way if it is the top entry in a stack trace, or just below
another function treated this way.
For example, if you have a function
malloc1
that wraps
malloc
, and
malloc2
that wraps
malloc1
, just specifying
--alloc-fn=malloc2
will have no effect. You need to specify
--alloc-fn=malloc1
as well. This is a little inconvenient, but the reason is that checking for allocation functions
is slow, and it saves a lot of time if Massif can stop looking through the stack trace entries as soon as it finds one that
doesn’t match rather than having to continue through all the entries.
Note that C++ names are demangled. Note also that overloaded C++ names must be written in full. Single quotes
may be necessary to prevent the shell from breaking them up. For example:
--alloc-fn=’operator new(unsigned, std::nothrow_t const&)’
--ignore-fn=<name>
Any direct heap allocation (i.e. a call to
malloc
,
new
, etc, or a call to a function named by an
--alloc-fn
option)
that occurs in a function specified by this option will be ignored.
This is mostly useful for testing purposes.
This
option can be specified multiple times on the command line, to name multiple functions.
Any
realloc
of an ignored block will also be ignored, even if the
realloc
call does not occur in an ignored
function. This avoids the possibility of negative heap sizes if ignored blocks are shrunk with
realloc
.
The rules for writing C++ function names are the same as for
--alloc-fn
above.
--threshold=<m.n> [default:
1.0]
The significance threshold for heap allocations, as a percentage of total memory size.
Allocation tree entries that
account for less than this will be aggregated. Note that this should be specified in tandem with ms_print’s option of
the same name.
--peak-inaccuracy=<m.n> [default:
1.0]
Massif does not necessarily record the actual global memory allocation peak; by default it records a peak only when
the global memory allocation size exceeds the previous peak by at least 1.0%. This is because there can be many local
allocation peaks along the way, and doing a detailed snapshot for every one would be expensive and wasteful, as all
but one of them will be later discarded. This inaccuracy can be changed (even to 0.0%) via this option, but Massif
will run drastically slower as the number approaches zero.
--time-unit=<i|ms|B> [default:
i]
The time unit used for the profiling. There are three possibilities: instructions executed (i), which is good for most
cases; real (wallclock) time (ms, i.e. milliseconds), which is sometimes useful; and bytes allocated/deallocated on the
heap and/or stack (B), which is useful for very short-run programs, and for testing purposes, because it is the most
reproducible across different machines.
--detailed-freq=<n> [default:
10]
Frequency of detailed snapshots. With
--detailed-freq=1
, every snapshot is detailed.
--max-snapshots=<n> [default:
100]
The maximum number of snapshots recorded. If set to N, for all programs except very short-running ones, the final
number of snapshots will be between N/2 and N.
147