vey-mimalloc-sys 0.3.2+3.7.0

Rust FFI binding to mimalloc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<!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">&#160;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&#160;</td><td class="memItemRight"><a class="el" href="#ga9783ebac45ef297ce1358cfd1f8e4080">mi_profiler_t</a></td></tr>
<tr class="memdesc:ga9783ebac45ef297ce1358cfd1f8e4080"><td class="mdescLeft">&#160;</td><td class="mdescRight">Profiler type. Custom profiler fields and callback types are defined in <span class="tt">&lt;mimalloc-profile.h&gt;</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> *&#160;</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">&#160;</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&#160;</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">&#160;</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&#160;</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">&#160;</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&#160;</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">&#160;</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&#160;</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">&#160;</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&#160;</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">&#160;</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&#160;</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">&#160;</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&#160;</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">&#160;</td><td class="mdescRight"><b>experimental</b>: Stop sampling.  <br /></td></tr>
<tr class="memitem:gaa3be0ee40c382b0633b10284857f4b1c" id="r_gaa3be0ee40c382b0633b10284857f4b1c"><td class="memItemLeft">void&#160;</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">&#160;</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">&lt;mimalloc-profile.h&gt;</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 &lt;mimalloc.h&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;mimalloc-profile.h&gt;</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">&quot;myprofile&quot;</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 &lt;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=&lt;basename&gt;</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">&#9670;&#160;</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">&lt;mimalloc-profile.h&gt;</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">&#9670;&#160;</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>&#160;)</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">&#9670;&#160;</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">&#9670;&#160;</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">&#9670;&#160;</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>&#160;)</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">&#9670;&#160;</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">&#9670;&#160;</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">&#9670;&#160;</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">&#9670;&#160;</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">&#9670;&#160;</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>&#160;)</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>