<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>9. Massif: a heap profiler</title>
-<link rel="stylesheet" href="vg_basic.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
+<link rel="stylesheet" type="text/css" href="vg_basic.css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="index.html" title="Valgrind Documentation">
<link rel="up" href="manual.html" title="Valgrind User Manual">
<link rel="prev" href="drd-manual.html" title="8. DRD: a thread error detector">
<th align="center" valign="middle">Valgrind User Manual</th>
<td width="22px" align="center" valign="middle"><a accesskey="n" href="dh-manual.html"><img src="images/next.png" width="18" height="21" border="0" alt="Next"></a></td>
</tr></table></div>
-<div class="chapter" title="9. Massif: a heap profiler">
-<div class="titlepage"><div><div><h2 class="title">
-<a name="ms-manual"></a>9. Massif: a heap profiler</h2></div></div></div>
+<div class="chapter">
+<div class="titlepage"><div><div><h1 class="title">
+<a name="ms-manual"></a>9. Massif: a heap profiler</h1></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
-<dl>
+<dl class="toc">
<dt><span class="sect1"><a href="ms-manual.html#ms-manual.overview">9.1. Overview</a></span></dt>
<dt><span class="sect1"><a href="ms-manual.html#ms-manual.using">9.2. Using Massif and ms_print</a></span></dt>
<dd><dl>
<p>To use this tool, you must specify
<code class="option">--tool=massif</code> on the Valgrind
command line.</p>
-<div class="sect1" title="9.1. Overview">
+<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="ms-manual.overview"></a>9.1. Overview</h2></div></div></div>
<p>Massif is a heap profiler. It measures how much heap memory your
<p>Heap profiling can help you reduce the amount of memory your program
uses. On modern machines with virtual memory, this provides the following
benefits:</p>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>It can speed up your program -- a smaller
program will interact better with your machine's caches and
avoid paging.</p></li>
which parts of your program are responsible for allocating the heap memory.
</p>
</div>
-<div class="sect1" title="9.2. Using Massif and ms_print">
+<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="ms-manual.using"></a>9.2. Using Massif and ms_print</h2></div></div></div>
<p>First off, as for the other Valgrind tools, you should compile with
is unlikely to affect the heap memory usage.</p>
<p>Then, you need to run Massif itself to gather the profiling
information, and then run ms_print to present it in a readable way.</p>
-<div class="sect2" title="9.2.1. An Example Program">
+<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="ms-manual.anexample"></a>9.2.1. An Example Program</h3></div></div></div>
<p>An example will make things clear. Consider the following C program
32 }
</pre>
</div>
-<div class="sect2" title="9.2.2. Running Massif">
+<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="ms-manual.running-massif"></a>9.2.2. Running Massif</h3></div></div></div>
<p>To gather heap profiling information about the program
<code class="filename"><pid></code> is the process ID, although this filename
can be changed with the <code class="option">--massif-out-file</code> option.</p>
</div>
-<div class="sect2" title="9.2.3. Running ms_print">
+<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="ms-manual.running-ms_print"></a>9.2.3. Running ms_print</h3></div></div></div>
<p>To see the information gathered by Massif in an easy-to-read form, use
presentation, and means that new methods of presenting the data can be added in
the future.</p>
</div>
-<div class="sect2" title="9.2.4. The Output Preamble">
+<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="ms-manual.theoutputpreamble"></a>9.2.4. The Output Preamble</h3></div></div></div>
<p>After running this program under Massif, the first part of ms_print's
--------------------------------------------------------------------------------
</pre>
</div>
-<div class="sect2" title="9.2.5. The Output Graph">
+<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="ms-manual.theoutputgraph"></a>9.2.5. The Output Graph</h3></div></div></div>
<p>The next part is the graph that shows how memory consumption occurred
that snapshot 14 was the peak.</p>
<p>Massif's determination of when the peak occurred can be wrong, for
two reasons.</p>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>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
than the standard SI multiplier of 1000. Strictly speaking, they should be
written KiB, MiB, GiB, etc.</p>
</div>
-<div class="sect2" title="9.2.6. The Snapshot Details">
+<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="ms-manual.thesnapshotdetails"></a>9.2.6. The Snapshot Details</h3></div></div></div>
<p>Returning to our example, the graph is followed by the detailed
8 8,064 8,064 8,000 64 0
</pre>
<p>Each normal snapshot records several things.</p>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>Its number.</p></li>
<li class="listitem"><p>The time it was taken. In this case, the time unit is
bytes, due to the use of
<code class="option">--threshold</code> option that both Massif and
ms_print support.</p>
</div>
-<div class="sect2" title="9.2.7. Forking Programs">
+<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="ms-manual.forkingprograms"></a>9.2.7. Forking Programs</h3></div></div></div>
<p>If your program forks, the child will inherit all the profiling data that
the outputs from the parent and child will be intermingled in a single output
file, which will almost certainly make it unreadable by ms_print.</p>
</div>
-<div class="sect2" title="9.2.8. Measuring All Memory in a Process">
+<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="ms-manual.not-measured"></a>9.2.8. Measuring All Memory in a Process</h3></div></div></div>
<p>
about memory usage can be very useful.
</p>
</div>
-<div class="sect2" title="9.2.9. Acting on Massif's Information">
+<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="ms-manual.acting"></a>9.2.9. Acting on Massif's Information</h3></div></div></div>
<p>Massif's information is generally fairly easy to act upon. The
</p>
</div>
</div>
-<div class="sect1" title="9.3. Massif Command-line Options">
+<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="ms-manual.options"></a>9.3. Massif Command-line Options</h2></div></div></div>
<p>Massif-specific command-line options are:</p>
<div class="variablelist">
-<a name="ms.opts.list"></a><dl>
+<a name="ms.opts.list"></a><dl class="variablelist">
<dt>
<a name="opt.heap"></a><span class="term">
<code class="option">--heap=<yes|no> [default: yes] </code>
</dl>
</div>
</div>
-<div class="sect1" title="9.4. Massif Monitor Commands">
+<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="ms-manual.monitor-commands"></a>9.4. Massif Monitor Commands</h2></div></div></div>
<p>The Massif tool provides monitor commands handled by the Valgrind
gdbserver (see <a class="xref" href="manual-core-adv.html#manual-core-adv.gdbserver-commandhandling" title="3.2.5. Monitor command handling by the Valgrind gdbserver">Monitor command handling by the Valgrind gdbserver</a>).
</p>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p><code class="varname">snapshot [<filename>]</code> requests
to take a snapshot and save it in the given <filename>
(default massif.vgdb.out).
</p></li>
</ul></div>
</div>
-<div class="sect1" title="9.5. Massif Client Requests">
+<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="ms-manual.clientreqs"></a>9.5. Massif Client Requests</h2></div></div></div>
<p>Massif does not have a <code class="filename">massif.h</code> file, but it does
<a class="xref" href="manual-core-adv.html#manual-core-adv.clientreq" title="3.1. The Client Request mechanism">The Client Request mechanism</a>.
</p>
</div>
-<div class="sect1" title="9.6. ms_print Command-line Options">
+<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="ms-manual.ms_print-options"></a>9.6. ms_print Command-line Options</h2></div></div></div>
<p>ms_print's options are:</p>
<div class="variablelist">
-<a name="ms_print.opts.list"></a><dl>
+<a name="ms_print.opts.list"></a><dl class="variablelist">
<dt><span class="term">
<code class="option">-h --help </code>
</span></dt>
</dl>
</div>
</div>
-<div class="sect1" title="9.7. Massif's Output File Format">
+<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="ms-manual.fileformat"></a>9.7. Massif's Output File Format</h2></div></div></div>
<p>Massif's file format is plain text (i.e. not binary) and deliberately