| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> | |
| <meta http-equiv="X-UA-Compatible" content="IE=11"/> | |
| <meta name="generator" content="Doxygen 1.18.0"/> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"/> | |
| <title>mi-malloc: Heap Profiling</title> | |
| <link href="tabs.css" rel="stylesheet" type="text/css"/> | |
| <script type="text/javascript" src="codefolding.js"></script> | |
| <script type="text/javascript" src="clipboard.js"></script> | |
| <link href="navtree.css" rel="stylesheet" type="text/css"/> | |
| <script type="text/javascript" src="navtreedata.js"></script> | |
| <script type="text/javascript" src="navtree.js"></script> | |
| <script type="text/javascript" src="cookie.js"></script> | |
| <link href="search/search.css" rel="stylesheet" type="text/css"/> | |
| <script type="text/javascript" src="search/searchdata.js"></script> | |
| <script type="text/javascript" src="search/search.js"></script> | |
| <link href="doxygen.css" rel="stylesheet" type="text/css" /> | |
| <link href="mimalloc-doxygen.css" rel="stylesheet" type="text/css"/> | |
| </head> | |
| <body> | |
| <div id="top"><!-- do not remove this div, it is closed by doxygen! --> | |
| <div id="titlearea"> | |
| <table cellspacing="0" cellpadding="0"> | |
| <tbody> | |
| <tr id="projectrow"> | |
| <td id="projectlogo"><img alt="Logo" src="mimalloc-logo.svg"/></td> | |
| <td id="projectalign"> | |
| <div id="projectname">mi-malloc<span id="projectnumber"> 3.6/2.5/1.15</span> | |
| </div> | |
| </td> | |
| <td> <div id="MSearchBox" class="MSearchBoxInactive"> | |
| <span class="left"> | |
| <span id="MSearchSelect" class="search-icon"><span class="search-icon-dropdown"></span></span> | |
| <input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"/> | |
| </span><span class="right"> | |
| <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><div id="MSearchCloseImg" class="close-icon"></div></a> | |
| </span> | |
| </div> | |
| </td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| <!-- end header part --> | |
| <!-- Generated by Doxygen 1.18.0 --> | |
| <script type="text/javascript"> | |
| let searchBox = new SearchBox("searchBox", "search/",'.html'); | |
| </script> | |
| <script type="text/javascript"> | |
| document.addEventListener('DOMContentLoaded', codefold.init); | |
| </script> | |
| </div><!-- top --> | |
| <div id="side-nav" class="ui-resizable side-nav-resizable"> | |
| <div id="nav-tree"> | |
| <div id="nav-tree-contents"> | |
| <div id="nav-sync" class="sync"></div> | |
| </div> | |
| </div> | |
| <div id="splitbar" class="ui-resizable-handle"> | |
| </div> | |
| </div> | |
| <script type="text/javascript"> | |
| document.addEventListener('DOMContentLoaded',() => { initNavTree('group__profiling.html','',''); }); | |
| </script> | |
| <div id="container"> | |
| <div id="doc-content"> | |
| <!-- window showing the filter options --> | |
| <div id="MSearchSelectWindow"> | |
| </div> | |
| <!-- iframe showing the search results (closed by default) --> | |
| <div id="MSearchResultsWindow"> | |
| <div id="MSearchResults"> | |
| <div class="SRPage"> | |
| <div id="SRIndex"> | |
| <div id="SRResults"></div> | |
| <div class="SRStatus" id="Loading">Loading...</div> | |
| <div class="SRStatus" id="Searching">Searching...</div> | |
| <div class="SRStatus" id="NoMatches">No Matches</div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="header"> | |
| <div class="headertitle"><div class="title">Heap Profiling </div></div> | |
| </div><!--header--> | |
| <div class="contents"> | |
| <p><b>v3</b>: Sample allocations using the built-in pprof-compatible profiler or custom profiling hooks. | |
| <a href="#details">More...</a></p> | |
| <table class="memberdecls"> | |
| <tr class="heading"><td colspan="2"><h2 id="header-typedef-members" class="groupheader"><a id="typedef-members" name="typedef-members"></a> | |
| Typedefs</h2></td></tr> | |
| <tr class="memitem:ga9783ebac45ef297ce1358cfd1f8e4080" id="r_ga9783ebac45ef297ce1358cfd1f8e4080"><td class="memItemLeft">typedef struct mi_profiler_s </td><td class="memItemRight"><a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a></td></tr> | |
| <tr class="memdesc:ga9783ebac45ef297ce1358cfd1f8e4080"><td class="mdescLeft"> </td><td class="mdescRight">Profiler type. Custom profiler fields and callback types are defined in <span class="tt"><mimalloc-profile.h></span>. <br /></td></tr> | |
| </table><table class="memberdecls"> | |
| <tr class="heading"><td colspan="2"><h2 id="header-func-members" class="groupheader"><a id="func-members" name="func-members"></a> | |
| Functions</h2></td></tr> | |
| <tr class="memitem:ga22e300c5e486531efc88fd31ac08e9f9" id="r_ga22e300c5e486531efc88fd31ac08e9f9"><td class="memItemLeft"><a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> * </td><td class="memItemRight"><a class="el" href="#ga22e300c5e486531efc88fd31ac08e9f9">mi_pprof_profiler_new</a> (size_t initial_threshold, const char *base_file_name, size_t alloc_interval_size, size_t inuse_interval_size, size_t time_interval_secs)</td></tr> | |
| <tr class="memdesc:ga22e300c5e486531efc88fd31ac08e9f9"><td class="mdescLeft"> </td><td class="mdescRight"><b>experimental</b>: Create the built-in pprof-compatible profiler. <br /></td></tr> | |
| <tr class="memitem:gaef24d75e08cedc0018925908b51d7fb1" id="r_gaef24d75e08cedc0018925908b51d7fb1"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#gaef24d75e08cedc0018925908b51d7fb1">mi_pprof_profiler_delete</a> (<a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> *profiler)</td></tr> | |
| <tr class="memdesc:gaef24d75e08cedc0018925908b51d7fb1"><td class="mdescLeft"> </td><td class="mdescRight"><b>experimental</b>: Delete a built-in profiler created by <a class="el" href="#ga22e300c5e486531efc88fd31ac08e9f9" title="experimental: Create the built-in pprof-compatible profiler.">mi_pprof_profiler_new()</a>. <br /></td></tr> | |
| <tr class="memitem:ga36e950fb134eb95fd4669c3a3b85e212" id="r_ga36e950fb134eb95fd4669c3a3b85e212"><td class="memItemLeft">bool </td><td class="memItemRight"><a class="el" href="#ga36e950fb134eb95fd4669c3a3b85e212">mi_profile</a> (<a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> *profiler)</td></tr> | |
| <tr class="memdesc:ga36e950fb134eb95fd4669c3a3b85e212"><td class="mdescLeft"> </td><td class="mdescRight"><b>experimental</b>: Attach a profiler to the current and future heaps of the main subprocess. <br /></td></tr> | |
| <tr class="memitem:gac2b13c51ed12b1fe261290ba14826444" id="r_gac2b13c51ed12b1fe261290ba14826444"><td class="memItemLeft">bool </td><td class="memItemRight"><a class="el" href="#gac2b13c51ed12b1fe261290ba14826444">mi_subproc_profile</a> (<a class="el" href="group__subproc.html#ga8c0bcd1fee27c7641e9c3c0d991b3b7d">mi_subproc_id_t</a> subproc_id, <a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> *profiler)</td></tr> | |
| <tr class="memdesc:gac2b13c51ed12b1fe261290ba14826444"><td class="mdescLeft"> </td><td class="mdescRight"><b>experimental</b>: Attach a profiler to the current and future heaps of a particular subprocess. <br /></td></tr> | |
| <tr class="memitem:gace9a7225c5ce92054ec13ed649d8f963" id="r_gace9a7225c5ce92054ec13ed649d8f963"><td class="memItemLeft">bool </td><td class="memItemRight"><a class="el" href="#gace9a7225c5ce92054ec13ed649d8f963">mi_heap_profile</a> (<a class="el" href="group__heap.html#ga34a47cde5a5b38c29f1aa3c5e76943c2">mi_heap_t</a> *heap, <a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> *profiler)</td></tr> | |
| <tr class="memdesc:gace9a7225c5ce92054ec13ed649d8f963"><td class="mdescLeft"> </td><td class="mdescRight"><b>experimental</b>: Attach a profiler to a particular heap, or pass <em class="arg">NULL</em> as the profiler to detach. <br /></td></tr> | |
| <tr class="memitem:gab9a180271506d5c5fe80814179a5f568" id="r_gab9a180271506d5c5fe80814179a5f568"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#gab9a180271506d5c5fe80814179a5f568">mi_heap_profile_disable</a> (<a class="el" href="group__heap.html#ga34a47cde5a5b38c29f1aa3c5e76943c2">mi_heap_t</a> *heap)</td></tr> | |
| <tr class="memdesc:gab9a180271506d5c5fe80814179a5f568"><td class="mdescLeft"> </td><td class="mdescRight"><b>experimental</b>: Exclude a heap from profiling, even when a profiler is subsequently attached to its subprocess. <br /></td></tr> | |
| <tr class="memitem:ga759a5cad55bd9014bf7bde946ca2fa38" id="r_ga759a5cad55bd9014bf7bde946ca2fa38"><td class="memItemLeft">bool </td><td class="memItemRight"><a class="el" href="#ga759a5cad55bd9014bf7bde946ca2fa38">mi_profiler_start</a> (<a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> *profiler)</td></tr> | |
| <tr class="memdesc:ga759a5cad55bd9014bf7bde946ca2fa38"><td class="mdescLeft"> </td><td class="mdescRight"><b>experimental</b>: Start sampling with an attached profiler. <br /></td></tr> | |
| <tr class="memitem:gaa7e0a272b9157783b0b63bbe44070a5b" id="r_gaa7e0a272b9157783b0b63bbe44070a5b"><td class="memItemLeft">bool </td><td class="memItemRight"><a class="el" href="#gaa7e0a272b9157783b0b63bbe44070a5b">mi_profiler_stop</a> (<a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> *profiler)</td></tr> | |
| <tr class="memdesc:gaa7e0a272b9157783b0b63bbe44070a5b"><td class="mdescLeft"> </td><td class="mdescRight"><b>experimental</b>: Stop sampling. <br /></td></tr> | |
| <tr class="memitem:gaa3be0ee40c382b0633b10284857f4b1c" id="r_gaa3be0ee40c382b0633b10284857f4b1c"><td class="memItemLeft">void </td><td class="memItemRight"><a class="el" href="#gaa3be0ee40c382b0633b10284857f4b1c">mi_profiler_snapshot</a> (<a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> *profiler)</td></tr> | |
| <tr class="memdesc:gaa3be0ee40c382b0633b10284857f4b1c"><td class="mdescLeft"> </td><td class="mdescRight"><b>experimental</b>: Take a snapshot of the current profile. <br /></td></tr> | |
| </table> | |
| <a name="details" id="details"></a><h2 id="header-details" class="groupheader">Detailed Description</h2> | |
| <div class="textblock"><p><b>v3</b>: Sample allocations using the built-in pprof-compatible profiler or custom profiling hooks. </p> | |
| <p>Include <span class="tt"><mimalloc-profile.h></span> and build with profiling support (<span class="tt">-DMI_PROFILE=ON</span>). The profiling API is <b>experimental</b> and may still change.</p> | |
| <p><b>Programmatic profiling</b></p> | |
| <p>Explicit profiler APIs remain available in secure builds and when environment-based activation is disabled. Create a profiler, attach it, and then start sampling:</p> | |
| <div class="fragment"><div class="line"><span class="preprocessor">#include <mimalloc.h></span></div> | |
| <div class="line"><span class="preprocessor">#include <mimalloc-profile.h></span></div> | |
| <div class="line"> </div> | |
| <div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">void</span>) {</div> | |
| <div class="line"> <a class="code hl_typedef" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a>* prof = <a class="code hl_function" href="#ga22e300c5e486531efc88fd31ac08e9f9">mi_pprof_profiler_new</a>(</div> | |
| <div class="line"> 512 * 1024, <span class="comment">// sample roughly every 512 KiB</span></div> | |
| <div class="line"> <span class="stringliteral">"myprofile"</span>, <span class="comment">// output basename; protobuf format</span></div> | |
| <div class="line"> 0, 0, 0); <span class="comment">// no automatic snapshots</span></div> | |
| <div class="line"> <span class="keywordflow">if</span> (prof == NULL) <span class="keywordflow">return</span> 1;</div> | |
| <div class="line"> </div> | |
| <div class="line"> <span class="keywordflow">if</span> (!<a class="code hl_function" href="#ga36e950fb134eb95fd4669c3a3b85e212">mi_profile</a>(prof)) {</div> | |
| <div class="line"> <a class="code hl_function" href="#ga36e950fb134eb95fd4669c3a3b85e212">mi_profile</a>(NULL);</div> | |
| <div class="line"> <a class="code hl_function" href="#gaef24d75e08cedc0018925908b51d7fb1">mi_pprof_profiler_delete</a>(prof);</div> | |
| <div class="line"> <span class="keywordflow">return</span> 1;</div> | |
| <div class="line"> }</div> | |
| <div class="line"> <a class="code hl_function" href="#ga759a5cad55bd9014bf7bde946ca2fa38">mi_profiler_start</a>(prof);</div> | |
| <div class="line"> </div> | |
| <div class="line"> <span class="comment">// Run your workload here; join worker threads before cleanup.</span></div> | |
| <div class="line"> </div> | |
| <div class="line"> <a class="code hl_function" href="#gaa7e0a272b9157783b0b63bbe44070a5b">mi_profiler_stop</a>(prof);</div> | |
| <div class="line"> <a class="code hl_function" href="#gaa3be0ee40c382b0633b10284857f4b1c">mi_profiler_snapshot</a>(prof);</div> | |
| <div class="line"> <a class="code hl_function" href="#ga36e950fb134eb95fd4669c3a3b85e212">mi_profile</a>(NULL); <span class="comment">// detach before deleting</span></div> | |
| <div class="line"> <a class="code hl_function" href="#gaef24d75e08cedc0018925908b51d7fb1">mi_pprof_profiler_delete</a>(prof);</div> | |
| <div class="line"> <span class="keywordflow">return</span> 0;</div> | |
| <div class="line">}</div> | |
| <div class="ttc" id="agroup__profiling_html_ga22e300c5e486531efc88fd31ac08e9f9"><div class="ttname"><a href="#ga22e300c5e486531efc88fd31ac08e9f9">mi_pprof_profiler_new</a></div><div class="ttdeci">mi_profiler_t * mi_pprof_profiler_new(size_t initial_threshold, const char *base_file_name, size_t alloc_interval_size, size_t inuse_interval_size, size_t time_interval_secs)</div><div class="ttdoc">experimental: Create the built-in pprof-compatible profiler.</div></div> | |
| <div class="ttc" id="agroup__profiling_html_ga36e950fb134eb95fd4669c3a3b85e212"><div class="ttname"><a href="#ga36e950fb134eb95fd4669c3a3b85e212">mi_profile</a></div><div class="ttdeci">bool mi_profile(mi_profiler_t *profiler)</div><div class="ttdoc">experimental: Attach a profiler to the current and future heaps of the main subprocess.</div></div> | |
| <div class="ttc" id="agroup__profiling_html_ga759a5cad55bd9014bf7bde946ca2fa38"><div class="ttname"><a href="#ga759a5cad55bd9014bf7bde946ca2fa38">mi_profiler_start</a></div><div class="ttdeci">bool mi_profiler_start(mi_profiler_t *profiler)</div><div class="ttdoc">experimental: Start sampling with an attached profiler.</div></div> | |
| <div class="ttc" id="agroup__profiling_html_ga9783ebac45ef297ce1358cfd1f8e4080"><div class="ttname"><a href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a></div><div class="ttdeci">struct mi_profiler_s mi_profiler_t</div><div class="ttdoc">Profiler type. Custom profiler fields and callback types are defined in <mimalloc-profile....</div><div class="ttdef"><b>Definition</b> mimalloc-doc.h:1597</div></div> | |
| <div class="ttc" id="agroup__profiling_html_gaa3be0ee40c382b0633b10284857f4b1c"><div class="ttname"><a href="#gaa3be0ee40c382b0633b10284857f4b1c">mi_profiler_snapshot</a></div><div class="ttdeci">void mi_profiler_snapshot(mi_profiler_t *profiler)</div><div class="ttdoc">experimental: Take a snapshot of the current profile.</div></div> | |
| <div class="ttc" id="agroup__profiling_html_gaa7e0a272b9157783b0b63bbe44070a5b"><div class="ttname"><a href="#gaa7e0a272b9157783b0b63bbe44070a5b">mi_profiler_stop</a></div><div class="ttdeci">bool mi_profiler_stop(mi_profiler_t *profiler)</div><div class="ttdoc">experimental: Stop sampling.</div></div> | |
| <div class="ttc" id="agroup__profiling_html_gaef24d75e08cedc0018925908b51d7fb1"><div class="ttname"><a href="#gaef24d75e08cedc0018925908b51d7fb1">mi_pprof_profiler_delete</a></div><div class="ttdeci">void mi_pprof_profiler_delete(mi_profiler_t *profiler)</div><div class="ttdoc">experimental: Delete a built-in profiler created by mi_pprof_profiler_new().</div></div> | |
| </div><!-- fragment --><p>Stopping sampling does not detach the profiler: its <span class="tt">on_free</span> callback can still be invoked for sampled allocations. Before deleting a profiler, detach it from all associated heaps and subprocesses, and ensure no other thread can still invoke its callbacks.</p> | |
| <p><b>Environment-based profiling</b></p> | |
| <p>When both <span class="tt">MI_SECURE=0</span> and <span class="tt">MI_SECURE_ENV=0</span>, <span class="tt">MIMALLOC_PROFILE=<basename></span> activates the built-in profiler for the main subprocess. Elevated processes ignore this environment variable regardless of build settings.</p> | |
| <ul> | |
| <li><span class="tt">MIMALLOC_PROFILE_SAMPLE_RATE</span>: approximate number of allocated bytes between samples (default: <span class="tt">512KiB</span>).</li> | |
| <li><span class="tt">MIMALLOC_PROFILE_ALLOC_INTERVAL</span>: allocated bytes between automatic snapshots (default: <span class="tt">1GiB</span>; <span class="tt">0</span> disables).</li> | |
| <li><span class="tt">MIMALLOC_PROFILE_INUSE_INTERVAL</span>: growth in in-use bytes between automatic snapshots (default: <span class="tt">0</span>, disabled).</li> | |
| <li><span class="tt">MIMALLOC_PROFILE_TIME_INTERVAL</span>: seconds between automatic snapshots, checked on allocation events (default: <span class="tt">0</span>, disabled).</li> | |
| </ul> | |
| <p>Snapshots use protobuf format by default. A basename ending in <span class="tt">.<a class="el" href="group__heap.html" title="First-class heaps.">Heaps</a></span> or <span class="tt">.text</span> selects the text heap-profile format instead. </p> | |
| </div><a name="doc-typedef-members" id="doc-typedef-members"></a><h2 id="header-doc-typedef-members" class="groupheader">Typedef Documentation</h2> | |
| <a id="ga9783ebac45ef297ce1358cfd1f8e4080" name="ga9783ebac45ef297ce1358cfd1f8e4080"></a> | |
| <h2 class="memtitle"><span class="permalink"><a href="#ga9783ebac45ef297ce1358cfd1f8e4080">◆ </a></span>mi_profiler_t</h2> | |
| <div class="memitem"> | |
| <div class="memproto"> | |
| <table class="memname"> | |
| <tr> | |
| <td class="memname">typedef struct mi_profiler_s <a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a></td> | |
| </tr> | |
| </table> | |
| </div><div class="memdoc"> | |
| <p>Profiler type. Custom profiler fields and callback types are defined in <span class="tt"><mimalloc-profile.h></span>. </p> | |
| </div> | |
| </div> | |
| <a name="doc-func-members" id="doc-func-members"></a><h2 id="header-doc-func-members" class="groupheader">Function Documentation</h2> | |
| <a id="gace9a7225c5ce92054ec13ed649d8f963" name="gace9a7225c5ce92054ec13ed649d8f963"></a> | |
| <h2 class="memtitle"><span class="permalink"><a href="#gace9a7225c5ce92054ec13ed649d8f963">◆ </a></span>mi_heap_profile()</h2> | |
| <div class="memitem"> | |
| <div class="memproto"> | |
| <table class="memname"> | |
| <tr> | |
| <td class="memname">bool mi_heap_profile </td> | |
| <td>(</td> | |
| <td class="paramtype"><a class="el" href="group__heap.html#ga34a47cde5a5b38c29f1aa3c5e76943c2">mi_heap_t</a> *</td> <td class="paramname"><span class="paramname"><em>heap</em></span>, </td> | |
| </tr> | |
| <tr> | |
| <td class="paramkey"></td> | |
| <td></td> | |
| <td class="paramtype"><a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> *</td> <td class="paramname"><span class="paramname"><em>profiler</em></span> )</td> | |
| </tr> | |
| </table> | |
| </div><div class="memdoc"> | |
| <p><b>experimental</b>: Attach a profiler to a particular heap, or pass <em class="arg">NULL</em> as the profiler to detach. </p> | |
| <p>Attaching stops sampling. The <span class="tt">on_free</span> callback is only invoked for allocations sampled by this profiler since it was last attached. </p><dl class="section return"><dt>Returns</dt><dd><em class="arg">true</em> on success. </dd></dl> | |
| </div> | |
| </div> | |
| <a id="gab9a180271506d5c5fe80814179a5f568" name="gab9a180271506d5c5fe80814179a5f568"></a> | |
| <h2 class="memtitle"><span class="permalink"><a href="#gab9a180271506d5c5fe80814179a5f568">◆ </a></span>mi_heap_profile_disable()</h2> | |
| <div class="memitem"> | |
| <div class="memproto"> | |
| <table class="memname"> | |
| <tr> | |
| <td class="memname">void mi_heap_profile_disable </td> | |
| <td>(</td> | |
| <td class="paramtype"><a class="el" href="group__heap.html#ga34a47cde5a5b38c29f1aa3c5e76943c2">mi_heap_t</a> *</td> <td class="paramname"><span class="paramname"><em>heap</em></span></td><td>)</td> | |
| <td></td> | |
| </tr> | |
| </table> | |
| </div><div class="memdoc"> | |
| <p><b>experimental</b>: Exclude a heap from profiling, even when a profiler is subsequently attached to its subprocess. </p> | |
| <p>Useful for a heap used by a custom profiler to allocate its own metadata. </p> | |
| </div> | |
| </div> | |
| <a id="gaef24d75e08cedc0018925908b51d7fb1" name="gaef24d75e08cedc0018925908b51d7fb1"></a> | |
| <h2 class="memtitle"><span class="permalink"><a href="#gaef24d75e08cedc0018925908b51d7fb1">◆ </a></span>mi_pprof_profiler_delete()</h2> | |
| <div class="memitem"> | |
| <div class="memproto"> | |
| <table class="memname"> | |
| <tr> | |
| <td class="memname">void mi_pprof_profiler_delete </td> | |
| <td>(</td> | |
| <td class="paramtype"><a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> *</td> <td class="paramname"><span class="paramname"><em>profiler</em></span></td><td>)</td> | |
| <td></td> | |
| </tr> | |
| </table> | |
| </div><div class="memdoc"> | |
| <p><b>experimental</b>: Delete a built-in profiler created by <a class="el" href="#ga22e300c5e486531efc88fd31ac08e9f9" title="experimental: Create the built-in pprof-compatible profiler.">mi_pprof_profiler_new()</a>. </p> | |
| <p>First detach the profiler and ensure no other thread can still invoke its callbacks. Deleting a profiler does not take a final snapshot; use <a class="el" href="#gaa3be0ee40c382b0633b10284857f4b1c" title="experimental: Take a snapshot of the current profile.">mi_profiler_snapshot()</a> explicitly. </p> | |
| </div> | |
| </div> | |
| <a id="ga22e300c5e486531efc88fd31ac08e9f9" name="ga22e300c5e486531efc88fd31ac08e9f9"></a> | |
| <h2 class="memtitle"><span class="permalink"><a href="#ga22e300c5e486531efc88fd31ac08e9f9">◆ </a></span>mi_pprof_profiler_new()</h2> | |
| <div class="memitem"> | |
| <div class="memproto"> | |
| <table class="memname"> | |
| <tr> | |
| <td class="memname"><a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> * mi_pprof_profiler_new </td> | |
| <td>(</td> | |
| <td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>initial_threshold</em></span>, </td> | |
| </tr> | |
| <tr> | |
| <td class="paramkey"></td> | |
| <td></td> | |
| <td class="paramtype">const char *</td> <td class="paramname"><span class="paramname"><em>base_file_name</em></span>, </td> | |
| </tr> | |
| <tr> | |
| <td class="paramkey"></td> | |
| <td></td> | |
| <td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>alloc_interval_size</em></span>, </td> | |
| </tr> | |
| <tr> | |
| <td class="paramkey"></td> | |
| <td></td> | |
| <td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>inuse_interval_size</em></span>, </td> | |
| </tr> | |
| <tr> | |
| <td class="paramkey"></td> | |
| <td></td> | |
| <td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>time_interval_secs</em></span> )</td> | |
| </tr> | |
| </table> | |
| </div><div class="memdoc"> | |
| <p><b>experimental</b>: Create the built-in pprof-compatible profiler. </p> | |
| <dl class="params"><dt>Parameters</dt><dd> | |
| <table class="params"> | |
| <tr><td class="paramname">initial_threshold</td><td>Approximate number of allocated bytes between samples (for example, <span class="tt">512 * 1024</span>). </td></tr> | |
| <tr><td class="paramname">base_file_name</td><td>Output basename. A <span class="tt">.<a class="el" href="group__heap.html" title="First-class heaps.">Heaps</a></span> or <span class="tt">.text</span> extension selects text format; any other extension, or none, selects protobuf format. A filename extension is stripped. </td></tr> | |
| <tr><td class="paramname">alloc_interval_size</td><td>Allocated bytes between automatic snapshots, or <span class="tt">0</span> to disable. </td></tr> | |
| <tr><td class="paramname">inuse_interval_size</td><td>Growth in in-use bytes between automatic snapshots, or <span class="tt">0</span> to disable. </td></tr> | |
| <tr><td class="paramname">time_interval_secs</td><td>Seconds between automatic snapshots, or <span class="tt">0</span> to disable. Time intervals are checked on allocation events, not by a background timer. </td></tr> | |
| </table> | |
| </dd> | |
| </dl> | |
| <dl class="section return"><dt>Returns</dt><dd>A profiler, or <em class="arg">NULL</em> on failure. The returned profiler must be attached and started before it samples allocations. </dd></dl> | |
| <dl class="section see"><dt>See also</dt><dd><a class="el" href="#ga36e950fb134eb95fd4669c3a3b85e212" title="experimental: Attach a profiler to the current and future heaps of the main subprocess.">mi_profile()</a>, <a class="el" href="#ga759a5cad55bd9014bf7bde946ca2fa38" title="experimental: Start sampling with an attached profiler.">mi_profiler_start()</a>, <a class="el" href="#gaef24d75e08cedc0018925908b51d7fb1" title="experimental: Delete a built-in profiler created by mi_pprof_profiler_new().">mi_pprof_profiler_delete()</a> </dd></dl> | |
| </div> | |
| </div> | |
| <a id="ga36e950fb134eb95fd4669c3a3b85e212" name="ga36e950fb134eb95fd4669c3a3b85e212"></a> | |
| <h2 class="memtitle"><span class="permalink"><a href="#ga36e950fb134eb95fd4669c3a3b85e212">◆ </a></span>mi_profile()</h2> | |
| <div class="memitem"> | |
| <div class="memproto"> | |
| <table class="memname"> | |
| <tr> | |
| <td class="memname">bool mi_profile </td> | |
| <td>(</td> | |
| <td class="paramtype"><a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> *</td> <td class="paramname"><span class="paramname"><em>profiler</em></span></td><td>)</td> | |
| <td></td> | |
| </tr> | |
| </table> | |
| </div><div class="memdoc"> | |
| <p><b>experimental</b>: Attach a profiler to the current and future heaps of the main subprocess. </p> | |
| <p>Heaps excluded by <a class="el" href="#gab9a180271506d5c5fe80814179a5f568" title="experimental: Exclude a heap from profiling, even when a profiler is subsequently attached to its sub...">mi_heap_profile_disable()</a> remain excluded. Pass <em class="arg">NULL</em> to detach. Attaching stops sampling; use <a class="el" href="#ga759a5cad55bd9014bf7bde946ca2fa38" title="experimental: Start sampling with an attached profiler.">mi_profiler_start()</a> to start it. </p><dl class="section return"><dt>Returns</dt><dd><em class="arg">true</em> on success. </dd></dl> | |
| </div> | |
| </div> | |
| <a id="gaa3be0ee40c382b0633b10284857f4b1c" name="gaa3be0ee40c382b0633b10284857f4b1c"></a> | |
| <h2 class="memtitle"><span class="permalink"><a href="#gaa3be0ee40c382b0633b10284857f4b1c">◆ </a></span>mi_profiler_snapshot()</h2> | |
| <div class="memitem"> | |
| <div class="memproto"> | |
| <table class="memname"> | |
| <tr> | |
| <td class="memname">void mi_profiler_snapshot </td> | |
| <td>(</td> | |
| <td class="paramtype"><a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> *</td> <td class="paramname"><span class="paramname"><em>profiler</em></span></td><td>)</td> | |
| <td></td> | |
| </tr> | |
| </table> | |
| </div><div class="memdoc"> | |
| <p><b>experimental</b>: Take a snapshot of the current profile. </p> | |
| <p>May be called while sampling is stopped. Concurrent calls may skip a snapshot if another snapshot callback is already running. </p> | |
| </div> | |
| </div> | |
| <a id="ga759a5cad55bd9014bf7bde946ca2fa38" name="ga759a5cad55bd9014bf7bde946ca2fa38"></a> | |
| <h2 class="memtitle"><span class="permalink"><a href="#ga759a5cad55bd9014bf7bde946ca2fa38">◆ </a></span>mi_profiler_start()</h2> | |
| <div class="memitem"> | |
| <div class="memproto"> | |
| <table class="memname"> | |
| <tr> | |
| <td class="memname">bool mi_profiler_start </td> | |
| <td>(</td> | |
| <td class="paramtype"><a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> *</td> <td class="paramname"><span class="paramname"><em>profiler</em></span></td><td>)</td> | |
| <td></td> | |
| </tr> | |
| </table> | |
| </div><div class="memdoc"> | |
| <p><b>experimental</b>: Start sampling with an attached profiler. </p> | |
| <dl class="section return"><dt>Returns</dt><dd>Whether the profiler was already running; <em class="arg">false</em> on the first start is normal. </dd></dl> | |
| </div> | |
| </div> | |
| <a id="gaa7e0a272b9157783b0b63bbe44070a5b" name="gaa7e0a272b9157783b0b63bbe44070a5b"></a> | |
| <h2 class="memtitle"><span class="permalink"><a href="#gaa7e0a272b9157783b0b63bbe44070a5b">◆ </a></span>mi_profiler_stop()</h2> | |
| <div class="memitem"> | |
| <div class="memproto"> | |
| <table class="memname"> | |
| <tr> | |
| <td class="memname">bool mi_profiler_stop </td> | |
| <td>(</td> | |
| <td class="paramtype"><a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> *</td> <td class="paramname"><span class="paramname"><em>profiler</em></span></td><td>)</td> | |
| <td></td> | |
| </tr> | |
| </table> | |
| </div><div class="memdoc"> | |
| <p><b>experimental</b>: Stop sampling. </p> | |
| <p>The <span class="tt">on_free</span> callback can still run until the profiler is detached. </p><dl class="section return"><dt>Returns</dt><dd>Whether the profiler was running before this call. </dd></dl> | |
| </div> | |
| </div> | |
| <a id="gac2b13c51ed12b1fe261290ba14826444" name="gac2b13c51ed12b1fe261290ba14826444"></a> | |
| <h2 class="memtitle"><span class="permalink"><a href="#gac2b13c51ed12b1fe261290ba14826444">◆ </a></span>mi_subproc_profile()</h2> | |
| <div class="memitem"> | |
| <div class="memproto"> | |
| <table class="memname"> | |
| <tr> | |
| <td class="memname">bool mi_subproc_profile </td> | |
| <td>(</td> | |
| <td class="paramtype"><a class="el" href="group__subproc.html#ga8c0bcd1fee27c7641e9c3c0d991b3b7d">mi_subproc_id_t</a></td> <td class="paramname"><span class="paramname"><em>subproc_id</em></span>, </td> | |
| </tr> | |
| <tr> | |
| <td class="paramkey"></td> | |
| <td></td> | |
| <td class="paramtype"><a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a> *</td> <td class="paramname"><span class="paramname"><em>profiler</em></span> )</td> | |
| </tr> | |
| </table> | |
| </div><div class="memdoc"> | |
| <p><b>experimental</b>: Attach a profiler to the current and future heaps of a particular subprocess. </p> | |
| <p>Heaps excluded by <a class="el" href="#gab9a180271506d5c5fe80814179a5f568" title="experimental: Exclude a heap from profiling, even when a profiler is subsequently attached to its sub...">mi_heap_profile_disable()</a> remain excluded. Pass <em class="arg">NULL</em> as the profiler to detach. Attaching stops sampling. </p><dl class="section return"><dt>Returns</dt><dd><em class="arg">true</em> on success. </dd></dl> | |
| </div> | |
| </div> | |
| </div><!-- contents --> | |
| </div><!-- doc-content --> | |
| <div id="page-nav" class="page-nav-panel"> | |
| <div id="page-nav-resize-handle"></div> | |
| <div id="page-nav-tree"> | |
| <div id="page-nav-contents"> | |
| </div><!-- page-nav-contents --> | |
| </div><!-- page-nav-tree --> | |
| </div><!-- page-nav --> | |
| </div><!-- container --> | |
| <!-- start footer part --> | |
| <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> | |
| <ul> | |
| <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.18.0 </li> | |
| </ul> | |
| </div> | |
| </body> | |
| </html> |