blob: 3d2e721d3904b8a02f5f897c9223ecf45e57301f [file] [log] [blame]
Jason Evansaee7fd22010-11-24 22:00:02 -08001<?xml version='1.0' encoding='UTF-8'?>
2<?xml-stylesheet type="text/xsl"
3 href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
4<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
5 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
6]>
7
8<refentry>
9 <refentryinfo>
10 <title>User Manual</title>
11 <productname>jemalloc</productname>
12 <releaseinfo role="version">@jemalloc_version@</releaseinfo>
13 <authorgroup>
14 <author>
15 <firstname>Jason</firstname>
16 <surname>Evans</surname>
17 <personblurb>Author</personblurb>
18 </author>
19 </authorgroup>
20 </refentryinfo>
21 <refmeta>
22 <refentrytitle>JEMALLOC</refentrytitle>
23 <manvolnum>3</manvolnum>
24 </refmeta>
25 <refnamediv>
26 <refdescriptor>jemalloc</refdescriptor>
27 <refname>jemalloc</refname>
28 <!-- Each refname causes a man page file to be created. Only if this were
29 the system malloc(3) implementation would these files be appropriate.
30 <refname>malloc</refname>
31 <refname>calloc</refname>
32 <refname>posix_memalign</refname>
Jason Evans0a0bbf62012-03-13 12:55:21 -070033 <refname>aligned_alloc</refname>
Jason Evansaee7fd22010-11-24 22:00:02 -080034 <refname>realloc</refname>
35 <refname>free</refname>
Jason Evansd82a5e62013-12-12 22:35:52 -080036 <refname>mallocx</refname>
37 <refname>rallocx</refname>
38 <refname>xallocx</refname>
39 <refname>sallocx</refname>
40 <refname>dallocx</refname>
Daniel Micay4cfe5512014-08-28 15:41:48 -040041 <refname>sdallocx</refname>
Jason Evansd82a5e62013-12-12 22:35:52 -080042 <refname>nallocx</refname>
Jason Evansaee7fd22010-11-24 22:00:02 -080043 <refname>mallctl</refname>
44 <refname>mallctlnametomib</refname>
45 <refname>mallctlbymib</refname>
Jason Evansd82a5e62013-12-12 22:35:52 -080046 <refname>malloc_stats_print</refname>
47 <refname>malloc_usable_size</refname>
Jason Evansaee7fd22010-11-24 22:00:02 -080048 -->
49 <refpurpose>general purpose memory allocation functions</refpurpose>
50 </refnamediv>
51 <refsect1 id="library">
52 <title>LIBRARY</title>
53 <para>This manual describes jemalloc @jemalloc_version@. More information
54 can be found at the <ulink
Jason Evans62de7682016-09-12 11:56:24 -070055 url="http://jemalloc.net/">jemalloc website</ulink>.</para>
Jason Evansaee7fd22010-11-24 22:00:02 -080056 </refsect1>
57 <refsynopsisdiv>
58 <title>SYNOPSIS</title>
59 <funcsynopsis>
Jason Evanse9a3fa22014-10-05 12:05:37 -070060 <funcsynopsisinfo>#include &lt;<filename class="headerfile">jemalloc/jemalloc.h</filename>&gt;</funcsynopsisinfo>
Jason Evansaee7fd22010-11-24 22:00:02 -080061 <refsect2>
62 <title>Standard API</title>
63 <funcprototype>
64 <funcdef>void *<function>malloc</function></funcdef>
65 <paramdef>size_t <parameter>size</parameter></paramdef>
66 </funcprototype>
67 <funcprototype>
68 <funcdef>void *<function>calloc</function></funcdef>
69 <paramdef>size_t <parameter>number</parameter></paramdef>
70 <paramdef>size_t <parameter>size</parameter></paramdef>
71 </funcprototype>
72 <funcprototype>
73 <funcdef>int <function>posix_memalign</function></funcdef>
74 <paramdef>void **<parameter>ptr</parameter></paramdef>
75 <paramdef>size_t <parameter>alignment</parameter></paramdef>
76 <paramdef>size_t <parameter>size</parameter></paramdef>
77 </funcprototype>
78 <funcprototype>
Jason Evans0a0bbf62012-03-13 12:55:21 -070079 <funcdef>void *<function>aligned_alloc</function></funcdef>
80 <paramdef>size_t <parameter>alignment</parameter></paramdef>
81 <paramdef>size_t <parameter>size</parameter></paramdef>
82 </funcprototype>
83 <funcprototype>
Jason Evansaee7fd22010-11-24 22:00:02 -080084 <funcdef>void *<function>realloc</function></funcdef>
85 <paramdef>void *<parameter>ptr</parameter></paramdef>
86 <paramdef>size_t <parameter>size</parameter></paramdef>
87 </funcprototype>
88 <funcprototype>
89 <funcdef>void <function>free</function></funcdef>
90 <paramdef>void *<parameter>ptr</parameter></paramdef>
91 </funcprototype>
92 </refsect2>
93 <refsect2>
94 <title>Non-standard API</title>
95 <funcprototype>
Jason Evansd82a5e62013-12-12 22:35:52 -080096 <funcdef>void *<function>mallocx</function></funcdef>
97 <paramdef>size_t <parameter>size</parameter></paramdef>
98 <paramdef>int <parameter>flags</parameter></paramdef>
Jason Evansaee7fd22010-11-24 22:00:02 -080099 </funcprototype>
100 <funcprototype>
Jason Evansd82a5e62013-12-12 22:35:52 -0800101 <funcdef>void *<function>rallocx</function></funcdef>
102 <paramdef>void *<parameter>ptr</parameter></paramdef>
103 <paramdef>size_t <parameter>size</parameter></paramdef>
104 <paramdef>int <parameter>flags</parameter></paramdef>
105 </funcprototype>
106 <funcprototype>
107 <funcdef>size_t <function>xallocx</function></funcdef>
108 <paramdef>void *<parameter>ptr</parameter></paramdef>
109 <paramdef>size_t <parameter>size</parameter></paramdef>
110 <paramdef>size_t <parameter>extra</parameter></paramdef>
111 <paramdef>int <parameter>flags</parameter></paramdef>
112 </funcprototype>
113 <funcprototype>
114 <funcdef>size_t <function>sallocx</function></funcdef>
115 <paramdef>void *<parameter>ptr</parameter></paramdef>
116 <paramdef>int <parameter>flags</parameter></paramdef>
117 </funcprototype>
118 <funcprototype>
119 <funcdef>void <function>dallocx</function></funcdef>
120 <paramdef>void *<parameter>ptr</parameter></paramdef>
121 <paramdef>int <parameter>flags</parameter></paramdef>
122 </funcprototype>
123 <funcprototype>
Daniel Micay4cfe5512014-08-28 15:41:48 -0400124 <funcdef>void <function>sdallocx</function></funcdef>
125 <paramdef>void *<parameter>ptr</parameter></paramdef>
126 <paramdef>size_t <parameter>size</parameter></paramdef>
127 <paramdef>int <parameter>flags</parameter></paramdef>
128 </funcprototype>
129 <funcprototype>
Jason Evansd82a5e62013-12-12 22:35:52 -0800130 <funcdef>size_t <function>nallocx</function></funcdef>
131 <paramdef>size_t <parameter>size</parameter></paramdef>
132 <paramdef>int <parameter>flags</parameter></paramdef>
Jason Evansaee7fd22010-11-24 22:00:02 -0800133 </funcprototype>
134 <funcprototype>
135 <funcdef>int <function>mallctl</function></funcdef>
136 <paramdef>const char *<parameter>name</parameter></paramdef>
137 <paramdef>void *<parameter>oldp</parameter></paramdef>
138 <paramdef>size_t *<parameter>oldlenp</parameter></paramdef>
139 <paramdef>void *<parameter>newp</parameter></paramdef>
140 <paramdef>size_t <parameter>newlen</parameter></paramdef>
141 </funcprototype>
142 <funcprototype>
143 <funcdef>int <function>mallctlnametomib</function></funcdef>
144 <paramdef>const char *<parameter>name</parameter></paramdef>
145 <paramdef>size_t *<parameter>mibp</parameter></paramdef>
146 <paramdef>size_t *<parameter>miblenp</parameter></paramdef>
147 </funcprototype>
148 <funcprototype>
149 <funcdef>int <function>mallctlbymib</function></funcdef>
150 <paramdef>const size_t *<parameter>mib</parameter></paramdef>
151 <paramdef>size_t <parameter>miblen</parameter></paramdef>
152 <paramdef>void *<parameter>oldp</parameter></paramdef>
153 <paramdef>size_t *<parameter>oldlenp</parameter></paramdef>
154 <paramdef>void *<parameter>newp</parameter></paramdef>
155 <paramdef>size_t <parameter>newlen</parameter></paramdef>
156 </funcprototype>
157 <funcprototype>
Jason Evansd82a5e62013-12-12 22:35:52 -0800158 <funcdef>void <function>malloc_stats_print</function></funcdef>
159 <paramdef>void <parameter>(*write_cb)</parameter>
160 <funcparams>void *, const char *</funcparams>
161 </paramdef>
162 <paramdef>void *<parameter>cbopaque</parameter></paramdef>
163 <paramdef>const char *<parameter>opts</parameter></paramdef>
164 </funcprototype>
165 <funcprototype>
166 <funcdef>size_t <function>malloc_usable_size</function></funcdef>
167 <paramdef>const void *<parameter>ptr</parameter></paramdef>
168 </funcprototype>
169 <funcprototype>
Jason Evansaee7fd22010-11-24 22:00:02 -0800170 <funcdef>void <function>(*malloc_message)</function></funcdef>
171 <paramdef>void *<parameter>cbopaque</parameter></paramdef>
172 <paramdef>const char *<parameter>s</parameter></paramdef>
173 </funcprototype>
174 <para><type>const char *</type><varname>malloc_conf</varname>;</para>
175 </refsect2>
Jason Evansaee7fd22010-11-24 22:00:02 -0800176 </funcsynopsis>
177 </refsynopsisdiv>
178 <refsect1 id="description">
179 <title>DESCRIPTION</title>
180 <refsect2>
181 <title>Standard API</title>
182
Jason Evans9ebbfca92016-09-12 16:44:33 -0700183 <para>The <function>malloc()</function> function allocates
Jason Evansaee7fd22010-11-24 22:00:02 -0800184 <parameter>size</parameter> bytes of uninitialized memory. The allocated
185 space is suitably aligned (after possible pointer coercion) for storage
186 of any type of object.</para>
187
Jason Evans9ebbfca92016-09-12 16:44:33 -0700188 <para>The <function>calloc()</function> function allocates
Jason Evansaee7fd22010-11-24 22:00:02 -0800189 space for <parameter>number</parameter> objects, each
190 <parameter>size</parameter> bytes in length. The result is identical to
Jason Evans9ebbfca92016-09-12 16:44:33 -0700191 calling <function>malloc()</function> with an argument of
Jason Evansaee7fd22010-11-24 22:00:02 -0800192 <parameter>number</parameter> * <parameter>size</parameter>, with the
193 exception that the allocated memory is explicitly initialized to zero
194 bytes.</para>
195
Jason Evans9ebbfca92016-09-12 16:44:33 -0700196 <para>The <function>posix_memalign()</function> function
Jason Evansaee7fd22010-11-24 22:00:02 -0800197 allocates <parameter>size</parameter> bytes of memory such that the
Jason Evansb4d62cd2014-05-15 22:46:24 -0700198 allocation's base address is a multiple of
Jason Evansaee7fd22010-11-24 22:00:02 -0800199 <parameter>alignment</parameter>, and returns the allocation in the value
200 pointed to by <parameter>ptr</parameter>. The requested
Jason Evansb4d62cd2014-05-15 22:46:24 -0700201 <parameter>alignment</parameter> must be a power of 2 at least as large as
202 <code language="C">sizeof(<type>void *</type>)</code>.</para>
Jason Evansaee7fd22010-11-24 22:00:02 -0800203
Jason Evans9ebbfca92016-09-12 16:44:33 -0700204 <para>The <function>aligned_alloc()</function> function
Jason Evans0a0bbf62012-03-13 12:55:21 -0700205 allocates <parameter>size</parameter> bytes of memory such that the
Jason Evansb4d62cd2014-05-15 22:46:24 -0700206 allocation's base address is a multiple of
Jason Evans0a0bbf62012-03-13 12:55:21 -0700207 <parameter>alignment</parameter>. The requested
208 <parameter>alignment</parameter> must be a power of 2. Behavior is
209 undefined if <parameter>size</parameter> is not an integral multiple of
210 <parameter>alignment</parameter>.</para>
211
Jason Evans9ebbfca92016-09-12 16:44:33 -0700212 <para>The <function>realloc()</function> function changes the
Jason Evansaee7fd22010-11-24 22:00:02 -0800213 size of the previously allocated memory referenced by
214 <parameter>ptr</parameter> to <parameter>size</parameter> bytes. The
215 contents of the memory are unchanged up to the lesser of the new and old
216 sizes. If the new size is larger, the contents of the newly allocated
217 portion of the memory are undefined. Upon success, the memory referenced
218 by <parameter>ptr</parameter> is freed and a pointer to the newly
219 allocated memory is returned. Note that
Jason Evans9ebbfca92016-09-12 16:44:33 -0700220 <function>realloc()</function> may move the memory allocation,
Jason Evansaee7fd22010-11-24 22:00:02 -0800221 resulting in a different return value than <parameter>ptr</parameter>.
222 If <parameter>ptr</parameter> is <constant>NULL</constant>, the
Jason Evans9ebbfca92016-09-12 16:44:33 -0700223 <function>realloc()</function> function behaves identically to
224 <function>malloc()</function> for the specified size.</para>
Jason Evansaee7fd22010-11-24 22:00:02 -0800225
Jason Evans9ebbfca92016-09-12 16:44:33 -0700226 <para>The <function>free()</function> function causes the
Jason Evansaee7fd22010-11-24 22:00:02 -0800227 allocated memory referenced by <parameter>ptr</parameter> to be made
228 available for future allocations. If <parameter>ptr</parameter> is
229 <constant>NULL</constant>, no action occurs.</para>
230 </refsect2>
231 <refsect2>
232 <title>Non-standard API</title>
Jason Evans9ebbfca92016-09-12 16:44:33 -0700233 <para>The <function>mallocx()</function>,
234 <function>rallocx()</function>,
235 <function>xallocx()</function>,
236 <function>sallocx()</function>,
237 <function>dallocx()</function>,
238 <function>sdallocx()</function>, and
239 <function>nallocx()</function> functions all have a
Jason Evansd82a5e62013-12-12 22:35:52 -0800240 <parameter>flags</parameter> argument that can be used to specify
241 options. The functions only check the options that are contextually
242 relevant. Use bitwise or (<code language="C">|</code>) operations to
243 specify one or more of the following:
244 <variablelist>
Jason Evans1cb181e2015-01-29 15:30:47 -0800245 <varlistentry id="MALLOCX_LG_ALIGN">
Jason Evansd82a5e62013-12-12 22:35:52 -0800246 <term><constant>MALLOCX_LG_ALIGN(<parameter>la</parameter>)
247 </constant></term>
Jason Evansaee7fd22010-11-24 22:00:02 -0800248
Jason Evansd82a5e62013-12-12 22:35:52 -0800249 <listitem><para>Align the memory allocation to start at an address
250 that is a multiple of <code language="C">(1 &lt;&lt;
251 <parameter>la</parameter>)</code>. This macro does not validate
252 that <parameter>la</parameter> is within the valid
253 range.</para></listitem>
254 </varlistentry>
Jason Evans1cb181e2015-01-29 15:30:47 -0800255 <varlistentry id="MALLOCX_ALIGN">
Jason Evansd82a5e62013-12-12 22:35:52 -0800256 <term><constant>MALLOCX_ALIGN(<parameter>a</parameter>)
257 </constant></term>
258
259 <listitem><para>Align the memory allocation to start at an address
260 that is a multiple of <parameter>a</parameter>, where
261 <parameter>a</parameter> is a power of two. This macro does not
262 validate that <parameter>a</parameter> is a power of 2.
263 </para></listitem>
264 </varlistentry>
Jason Evans1cb181e2015-01-29 15:30:47 -0800265 <varlistentry id="MALLOCX_ZERO">
Jason Evansd82a5e62013-12-12 22:35:52 -0800266 <term><constant>MALLOCX_ZERO</constant></term>
267
268 <listitem><para>Initialize newly allocated memory to contain zero
269 bytes. In the growing reallocation case, the real size prior to
270 reallocation defines the boundary between untouched bytes and those
271 that are initialized to contain zero bytes. If this macro is
272 absent, newly allocated memory is uninitialized.</para></listitem>
273 </varlistentry>
Jason Evans1cb181e2015-01-29 15:30:47 -0800274 <varlistentry id="MALLOCX_TCACHE">
275 <term><constant>MALLOCX_TCACHE(<parameter>tc</parameter>)
276 </constant></term>
277
278 <listitem><para>Use the thread-specific cache (tcache) specified by
279 the identifier <parameter>tc</parameter>, which must have been
280 acquired via the <link
281 linkend="tcache.create"><mallctl>tcache.create</mallctl></link>
282 mallctl. This macro does not validate that
283 <parameter>tc</parameter> specifies a valid
284 identifier.</para></listitem>
285 </varlistentry>
286 <varlistentry id="MALLOC_TCACHE_NONE">
287 <term><constant>MALLOCX_TCACHE_NONE</constant></term>
288
289 <listitem><para>Do not use a thread-specific cache (tcache). Unless
290 <constant>MALLOCX_TCACHE(<parameter>tc</parameter>)</constant> or
291 <constant>MALLOCX_TCACHE_NONE</constant> is specified, an
292 automatically managed tcache will be used under many circumstances.
293 This macro cannot be used in the same <parameter>flags</parameter>
294 argument as
295 <constant>MALLOCX_TCACHE(<parameter>tc</parameter>)</constant>.</para></listitem>
296 </varlistentry>
297 <varlistentry id="MALLOCX_ARENA">
Jason Evansd82a5e62013-12-12 22:35:52 -0800298 <term><constant>MALLOCX_ARENA(<parameter>a</parameter>)
299 </constant></term>
300
301 <listitem><para>Use the arena specified by the index
Jason Evans1cb181e2015-01-29 15:30:47 -0800302 <parameter>a</parameter>. This macro has no effect for regions that
303 were allocated via an arena other than the one specified. This
304 macro does not validate that <parameter>a</parameter> specifies an
305 arena index in the valid range.</para></listitem>
Jason Evansd82a5e62013-12-12 22:35:52 -0800306 </varlistentry>
307 </variablelist>
Jason Evansaee7fd22010-11-24 22:00:02 -0800308 </para>
309
Jason Evans9ebbfca92016-09-12 16:44:33 -0700310 <para>The <function>mallocx()</function> function allocates at
Jason Evansd82a5e62013-12-12 22:35:52 -0800311 least <parameter>size</parameter> bytes of memory, and returns a pointer
312 to the base address of the allocation. Behavior is undefined if
Jason Evans0c516a02016-02-25 15:29:49 -0800313 <parameter>size</parameter> is <constant>0</constant>.</para>
Jason Evansd82a5e62013-12-12 22:35:52 -0800314
Jason Evans9ebbfca92016-09-12 16:44:33 -0700315 <para>The <function>rallocx()</function> function resizes the
Jason Evansd82a5e62013-12-12 22:35:52 -0800316 allocation at <parameter>ptr</parameter> to be at least
317 <parameter>size</parameter> bytes, and returns a pointer to the base
318 address of the resulting allocation, which may or may not have moved from
319 its original location. Behavior is undefined if
Jason Evans0c516a02016-02-25 15:29:49 -0800320 <parameter>size</parameter> is <constant>0</constant>.</para>
Jason Evansd82a5e62013-12-12 22:35:52 -0800321
Jason Evans9ebbfca92016-09-12 16:44:33 -0700322 <para>The <function>xallocx()</function> function resizes the
Jason Evansd82a5e62013-12-12 22:35:52 -0800323 allocation at <parameter>ptr</parameter> in place to be at least
324 <parameter>size</parameter> bytes, and returns the real size of the
325 allocation. If <parameter>extra</parameter> is non-zero, an attempt is
326 made to resize the allocation to be at least <code
327 language="C">(<parameter>size</parameter> +
328 <parameter>extra</parameter>)</code> bytes, though inability to allocate
329 the extra byte(s) will not by itself result in failure to resize.
330 Behavior is undefined if <parameter>size</parameter> is
331 <constant>0</constant>, or if <code
332 language="C">(<parameter>size</parameter> + <parameter>extra</parameter>
333 &gt; <constant>SIZE_T_MAX</constant>)</code>.</para>
334
Jason Evans9ebbfca92016-09-12 16:44:33 -0700335 <para>The <function>sallocx()</function> function returns the
Jason Evansd82a5e62013-12-12 22:35:52 -0800336 real size of the allocation at <parameter>ptr</parameter>.</para>
337
Jason Evans9ebbfca92016-09-12 16:44:33 -0700338 <para>The <function>dallocx()</function> function causes the
Jason Evansd82a5e62013-12-12 22:35:52 -0800339 memory referenced by <parameter>ptr</parameter> to be made available for
340 future allocations.</para>
341
Jason Evans9ebbfca92016-09-12 16:44:33 -0700342 <para>The <function>sdallocx()</function> function is an
343 extension of <function>dallocx()</function> with a
Daniel Micay4cfe5512014-08-28 15:41:48 -0400344 <parameter>size</parameter> parameter to allow the caller to pass in the
345 allocation size as an optimization. The minimum valid input size is the
346 original requested size of the allocation, and the maximum valid input
347 size is the corresponding value returned by
Jason Evans9ebbfca92016-09-12 16:44:33 -0700348 <function>nallocx()</function> or
349 <function>sallocx()</function>.</para>
Daniel Micay4cfe5512014-08-28 15:41:48 -0400350
Jason Evans9ebbfca92016-09-12 16:44:33 -0700351 <para>The <function>nallocx()</function> function allocates no
Jason Evansd82a5e62013-12-12 22:35:52 -0800352 memory, but it performs the same size computation as the
Jason Evans9ebbfca92016-09-12 16:44:33 -0700353 <function>mallocx()</function> function, and returns the real
Jason Evansd82a5e62013-12-12 22:35:52 -0800354 size of the allocation that would result from the equivalent
Jason Evans9ebbfca92016-09-12 16:44:33 -0700355 <function>mallocx()</function> function call, or
Jason Evans0c516a02016-02-25 15:29:49 -0800356 <constant>0</constant> if the inputs exceed the maximum supported size
357 class and/or alignment. Behavior is undefined if
358 <parameter>size</parameter> is <constant>0</constant>.</para>
Jason Evansaee7fd22010-11-24 22:00:02 -0800359
Jason Evans9ebbfca92016-09-12 16:44:33 -0700360 <para>The <function>mallctl()</function> function provides a
Jason Evansaee7fd22010-11-24 22:00:02 -0800361 general interface for introspecting the memory allocator, as well as
362 setting modifiable parameters and triggering actions. The
363 period-separated <parameter>name</parameter> argument specifies a
364 location in a tree-structured namespace; see the <xref
365 linkend="mallctl_namespace" xrefstyle="template:%t"/> section for
366 documentation on the tree contents. To read a value, pass a pointer via
367 <parameter>oldp</parameter> to adequate space to contain the value, and a
368 pointer to its length via <parameter>oldlenp</parameter>; otherwise pass
369 <constant>NULL</constant> and <constant>NULL</constant>. Similarly, to
370 write a value, pass a pointer to the value via
371 <parameter>newp</parameter>, and its length via
372 <parameter>newlen</parameter>; otherwise pass <constant>NULL</constant>
373 and <constant>0</constant>.</para>
374
Jason Evans9ebbfca92016-09-12 16:44:33 -0700375 <para>The <function>mallctlnametomib()</function> function
Jason Evansaee7fd22010-11-24 22:00:02 -0800376 provides a way to avoid repeated name lookups for applications that
377 repeatedly query the same portion of the namespace, by translating a name
Jason Evansf19bedb2016-11-01 13:25:42 -0700378 to a <quote>Management Information Base</quote> (MIB) that can be passed
Jason Evans9ebbfca92016-09-12 16:44:33 -0700379 repeatedly to <function>mallctlbymib()</function>. Upon
380 successful return from <function>mallctlnametomib()</function>,
Jason Evansaee7fd22010-11-24 22:00:02 -0800381 <parameter>mibp</parameter> contains an array of
382 <parameter>*miblenp</parameter> integers, where
383 <parameter>*miblenp</parameter> is the lesser of the number of components
384 in <parameter>name</parameter> and the input value of
385 <parameter>*miblenp</parameter>. Thus it is possible to pass a
386 <parameter>*miblenp</parameter> that is smaller than the number of
387 period-separated name components, which results in a partial MIB that can
388 be used as the basis for constructing a complete MIB. For name
389 components that are integers (e.g. the 2 in
390 <link
391 linkend="arenas.bin.i.size"><mallctl>arenas.bin.2.size</mallctl></link>),
392 the corresponding MIB component will always be that integer. Therefore,
393 it is legitimate to construct code like the following: <programlisting
394 language="C"><![CDATA[
395unsigned nbins, i;
Jason Evansde732962013-12-18 23:21:42 -0800396size_t mib[4];
Jason Evansaee7fd22010-11-24 22:00:02 -0800397size_t len, miblen;
398
399len = sizeof(nbins);
400mallctl("arenas.nbins", &nbins, &len, NULL, 0);
401
402miblen = 4;
Jason Evansde732962013-12-18 23:21:42 -0800403mallctlnametomib("arenas.bin.0.size", mib, &miblen);
Jason Evansaee7fd22010-11-24 22:00:02 -0800404for (i = 0; i < nbins; i++) {
405 size_t bin_size;
406
407 mib[2] = i;
408 len = sizeof(bin_size);
409 mallctlbymib(mib, miblen, &bin_size, &len, NULL, 0);
410 /* Do something with bin_size... */
411}]]></programlisting></para>
Jason Evansd82a5e62013-12-12 22:35:52 -0800412
Jason Evansb599b322016-11-01 15:28:54 -0700413 <para>The <function>malloc_stats_print()</function> function writes
414 summary statistics via the <parameter>write_cb</parameter> callback
415 function pointer and <parameter>cbopaque</parameter> data passed to
416 <parameter>write_cb</parameter>, or <function>malloc_message()</function>
417 if <parameter>write_cb</parameter> is <constant>NULL</constant>. The
418 statistics are presented in human-readable form unless <quote>J</quote> is
419 specified as a character within the <parameter>opts</parameter> string, in
420 which case the statistics are presented in <ulink
421 url="http://www.json.org/">JSON format</ulink>. This function can be
422 called repeatedly. General information that never changes during
423 execution can be omitted by specifying <quote>g</quote> as a character
Jason Evansd82a5e62013-12-12 22:35:52 -0800424 within the <parameter>opts</parameter> string. Note that
Jason Evans9ebbfca92016-09-12 16:44:33 -0700425 <function>malloc_message()</function> uses the
Jason Evansb599b322016-11-01 15:28:54 -0700426 <function>mallctl*()</function> functions internally, so inconsistent
427 statistics can be reported if multiple threads use these functions
428 simultaneously. If <option>--enable-stats</option> is specified during
429 configuration, <quote>m</quote> and <quote>a</quote> can be specified to
430 omit merged arena and per arena statistics, respectively;
431 <quote>b</quote>, <quote>l</quote>, and <quote>h</quote> can be specified
432 to omit per size class statistics for bins, large objects, and huge
433 objects, respectively. Unrecognized characters are silently ignored.
434 Note that thread caching may prevent some statistics from being completely
435 up to date, since extra locking would be required to merge counters that
436 track thread cache operations.</para>
Jason Evansd82a5e62013-12-12 22:35:52 -0800437
Jason Evans9ebbfca92016-09-12 16:44:33 -0700438 <para>The <function>malloc_usable_size()</function> function
Jason Evansd82a5e62013-12-12 22:35:52 -0800439 returns the usable size of the allocation pointed to by
440 <parameter>ptr</parameter>. The return value may be larger than the size
441 that was requested during allocation. The
Jason Evans9ebbfca92016-09-12 16:44:33 -0700442 <function>malloc_usable_size()</function> function is not a
443 mechanism for in-place <function>realloc()</function>; rather
Jason Evansd82a5e62013-12-12 22:35:52 -0800444 it is provided solely as a tool for introspection purposes. Any
445 discrepancy between the requested allocation size and the size reported
Jason Evans9ebbfca92016-09-12 16:44:33 -0700446 by <function>malloc_usable_size()</function> should not be
Jason Evansd82a5e62013-12-12 22:35:52 -0800447 depended on, since such behavior is entirely implementation-dependent.
448 </para>
Jason Evansaee7fd22010-11-24 22:00:02 -0800449 </refsect2>
Jason Evansaee7fd22010-11-24 22:00:02 -0800450 </refsect1>
451 <refsect1 id="tuning">
452 <title>TUNING</title>
453 <para>Once, when the first call is made to one of the memory allocation
454 routines, the allocator initializes its internals based in part on various
455 options that can be specified at compile- or run-time.</para>
456
Jason Evansf8290092016-02-07 14:23:22 -0800457 <para>The string specified via <option>--with-malloc-conf</option>, the
458 string pointed to by the global variable <varname>malloc_conf</varname>, the
Jason Evansf19bedb2016-11-01 13:25:42 -0700459 <quote>name</quote> of the file referenced by the symbolic link named
Jason Evansf8290092016-02-07 14:23:22 -0800460 <filename class="symlink">/etc/malloc.conf</filename>, and the value of the
Jason Evansaee7fd22010-11-24 22:00:02 -0800461 environment variable <envar>MALLOC_CONF</envar>, will be interpreted, in
Jason Evans705328c2013-03-19 16:28:41 -0700462 that order, from left to right as options. Note that
463 <varname>malloc_conf</varname> may be read before
Jason Evans9ebbfca92016-09-12 16:44:33 -0700464 <function>main()</function> is entered, so the declaration of
Jason Evans705328c2013-03-19 16:28:41 -0700465 <varname>malloc_conf</varname> should specify an initializer that contains
Jason Evansf8290092016-02-07 14:23:22 -0800466 the final value to be read by jemalloc. <option>--with-malloc-conf</option>
467 and <varname>malloc_conf</varname> are compile-time mechanisms, whereas
468 <filename class="symlink">/etc/malloc.conf</filename> and
469 <envar>MALLOC_CONF</envar> can be safely set any time prior to program
470 invocation.</para>
Jason Evansaee7fd22010-11-24 22:00:02 -0800471
472 <para>An options string is a comma-separated list of option:value pairs.
473 There is one key corresponding to each <link
474 linkend="opt.abort"><mallctl>opt.*</mallctl></link> mallctl (see the <xref
475 linkend="mallctl_namespace" xrefstyle="template:%t"/> section for options
476 documentation). For example, <literal>abort:true,narenas:1</literal> sets
477 the <link linkend="opt.abort"><mallctl>opt.abort</mallctl></link> and <link
478 linkend="opt.narenas"><mallctl>opt.narenas</mallctl></link> options. Some
479 options have boolean values (true/false), others have integer values (base
480 8, 10, or 16, depending on prefix), and yet others have raw string
481 values.</para>
482 </refsect1>
483 <refsect1 id="implementation_notes">
484 <title>IMPLEMENTATION NOTES</title>
485 <para>Traditionally, allocators have used
486 <citerefentry><refentrytitle>sbrk</refentrytitle>
487 <manvolnum>2</manvolnum></citerefentry> to obtain memory, which is
488 suboptimal for several reasons, including race conditions, increased
489 fragmentation, and artificial limitations on maximum usable memory. If
Jason Evans4d434ad2014-04-15 12:09:48 -0700490 <citerefentry><refentrytitle>sbrk</refentrytitle>
491 <manvolnum>2</manvolnum></citerefentry> is supported by the operating
492 system, this allocator uses both
493 <citerefentry><refentrytitle>mmap</refentrytitle>
Jason Evansaee7fd22010-11-24 22:00:02 -0800494 <manvolnum>2</manvolnum></citerefentry> and
Jason Evans8f0e0eb2012-04-21 13:33:48 -0700495 <citerefentry><refentrytitle>sbrk</refentrytitle>
Jason Evansaee7fd22010-11-24 22:00:02 -0800496 <manvolnum>2</manvolnum></citerefentry>, in that order of preference;
497 otherwise only <citerefentry><refentrytitle>mmap</refentrytitle>
498 <manvolnum>2</manvolnum></citerefentry> is used.</para>
499
500 <para>This allocator uses multiple arenas in order to reduce lock
501 contention for threaded programs on multi-processor systems. This works
502 well with regard to threading scalability, but incurs some costs. There is
503 a small fixed per-arena overhead, and additionally, arenas manage memory
504 completely independently of each other, which means a small fixed increase
505 in overall memory fragmentation. These overheads are not generally an
506 issue, given the number of arenas normally used. Note that using
507 substantially more arenas than the default is not likely to improve
508 performance, mainly due to reduced cache performance. However, it may make
509 sense to reduce the number of arenas if an application does not make much
510 use of the allocation functions.</para>
511
512 <para>In addition to multiple arenas, unless
513 <option>--disable-tcache</option> is specified during configuration, this
514 allocator supports thread-specific caching for small and large objects, in
515 order to make it possible to completely avoid synchronization for most
516 allocation requests. Such caching allows very fast allocation in the
517 common case, but it increases memory usage and fragmentation, since a
518 bounded number of objects can remain allocated in each thread cache.</para>
519
Jason Evansf591d262016-02-24 14:36:58 -0800520 <para>Memory is conceptually broken into equal-sized chunks, where the chunk
521 size is a power of two that is greater than the page size. Chunks are
522 always aligned to multiples of the chunk size. This alignment makes it
523 possible to find metadata for user objects very quickly. User objects are
524 broken into three categories according to size: small, large, and huge.
525 Multiple small and large objects can reside within a single chunk, whereas
526 huge objects each have one or more chunks backing them. Each chunk that
527 contains small and/or large objects tracks its contents as runs of
Jason Evansaee7fd22010-11-24 22:00:02 -0800528 contiguous pages (unused, backing a set of small objects, or backing one
Jason Evansf591d262016-02-24 14:36:58 -0800529 large object). The combination of chunk alignment and chunk page maps makes
530 it possible to determine all metadata regarding small and large allocations
531 in constant time.</para>
Jason Evansaee7fd22010-11-24 22:00:02 -0800532
533 <para>Small objects are managed in groups by page runs. Each run maintains
Jason Evans0cdabd22014-10-14 22:19:21 -0700534 a bitmap to track which regions are in use. Allocation requests that are no
535 more than half the quantum (8 or 16, depending on architecture) are rounded
536 up to the nearest power of two that is at least <code
537 language="C">sizeof(<type>double</type>)</code>. All other object size
538 classes are multiples of the quantum, spaced such that there are four size
539 classes for each doubling in size, which limits internal fragmentation to
540 approximately 20% for all but the smallest size classes. Small size classes
541 are smaller than four times the page size, large size classes are smaller
542 than the chunk size (see the <link
543 linkend="opt.lg_chunk"><mallctl>opt.lg_chunk</mallctl></link> option), and
Jason Evansb582d2a2016-03-31 12:31:10 -0700544 huge size classes extend from the chunk size up to the largest size class
545 that does not exceed <constant>PTRDIFF_MAX</constant>.</para>
Jason Evansaee7fd22010-11-24 22:00:02 -0800546
547 <para>Allocations are packed tightly together, which can be an issue for
548 multi-threaded applications. If you need to assure that allocations do not
549 suffer from cacheline sharing, round your allocation requests up to the
550 nearest multiple of the cacheline size, or specify cacheline alignment when
551 allocating.</para>
552
Jason Evans9ebbfca92016-09-12 16:44:33 -0700553 <para>The <function>realloc()</function>,
554 <function>rallocx()</function>, and
555 <function>xallocx()</function> functions may resize allocations
Jason Evans228b2e92015-01-22 15:28:25 -0800556 without moving them under limited circumstances. Unlike the
Jason Evans9ebbfca92016-09-12 16:44:33 -0700557 <function>*allocx()</function> API, the standard API does not
Jason Evans228b2e92015-01-22 15:28:25 -0800558 officially round up the usable size of an allocation to the nearest size
559 class, so technically it is necessary to call
Jason Evans9ebbfca92016-09-12 16:44:33 -0700560 <function>realloc()</function> to grow e.g. a 9-byte allocation to
Jason Evans228b2e92015-01-22 15:28:25 -0800561 16 bytes, or shrink a 16-byte allocation to 9 bytes. Growth and shrinkage
562 trivially succeeds in place as long as the pre-size and post-size both round
563 up to the same size class. No other API guarantees are made regarding
564 in-place resizing, but the current implementation also tries to resize large
565 and huge allocations in place, as long as the pre-size and post-size are
Jason Evans38f86492015-08-14 00:55:44 -0700566 both large or both huge. In such cases shrinkage always succeeds for large
567 size classes, but for huge size classes the chunk allocator must support
568 splitting (see <link
569 linkend="arena.i.chunk_hooks"><mallctl>arena.&lt;i&gt;.chunk_hooks</mallctl></link>).
570 Growth only succeeds if the trailing memory is currently available, and
571 additionally for huge size classes the chunk allocator must support
572 merging.</para>
Jason Evans228b2e92015-01-22 15:28:25 -0800573
Jason Evansa5dbaef2015-08-14 00:35:11 -0700574 <para>Assuming 2 MiB chunks, 4 KiB pages, and a 16-byte quantum on a
Jason Evansf044bb22015-03-06 20:05:16 -0800575 64-bit system, the size classes in each category are as shown in <xref
Jason Evansaee7fd22010-11-24 22:00:02 -0800576 linkend="size_classes" xrefstyle="template:Table %n"/>.</para>
577
578 <table xml:id="size_classes" frame="all">
579 <title>Size classes</title>
Jason Evans7091b412012-03-19 09:36:44 -0700580 <tgroup cols="3" colsep="1" rowsep="1">
581 <colspec colname="c1" align="left"/>
582 <colspec colname="c2" align="right"/>
583 <colspec colname="c3" align="left"/>
Jason Evansaee7fd22010-11-24 22:00:02 -0800584 <thead>
585 <row>
586 <entry>Category</entry>
Jason Evans7091b412012-03-19 09:36:44 -0700587 <entry>Spacing</entry>
Jason Evansaee7fd22010-11-24 22:00:02 -0800588 <entry>Size</entry>
589 </row>
590 </thead>
591 <tbody>
592 <row>
Jason Evans0cdabd22014-10-14 22:19:21 -0700593 <entry morerows="8">Small</entry>
Jason Evans7091b412012-03-19 09:36:44 -0700594 <entry>lg</entry>
Jason Evansaee7fd22010-11-24 22:00:02 -0800595 <entry>[8]</entry>
596 </row>
597 <row>
Jason Evans7091b412012-03-19 09:36:44 -0700598 <entry>16</entry>
Jason Evans0cdabd22014-10-14 22:19:21 -0700599 <entry>[16, 32, 48, 64, 80, 96, 112, 128]</entry>
Jason Evansaee7fd22010-11-24 22:00:02 -0800600 </row>
601 <row>
Jason Evans7091b412012-03-19 09:36:44 -0700602 <entry>32</entry>
Jason Evansb1726102012-02-28 16:50:47 -0800603 <entry>[160, 192, 224, 256]</entry>
Jason Evansaee7fd22010-11-24 22:00:02 -0800604 </row>
605 <row>
Jason Evans7091b412012-03-19 09:36:44 -0700606 <entry>64</entry>
Jason Evansb1726102012-02-28 16:50:47 -0800607 <entry>[320, 384, 448, 512]</entry>
608 </row>
609 <row>
Jason Evans7091b412012-03-19 09:36:44 -0700610 <entry>128</entry>
Jason Evansb1726102012-02-28 16:50:47 -0800611 <entry>[640, 768, 896, 1024]</entry>
612 </row>
613 <row>
Jason Evans7091b412012-03-19 09:36:44 -0700614 <entry>256</entry>
Jason Evansb1726102012-02-28 16:50:47 -0800615 <entry>[1280, 1536, 1792, 2048]</entry>
616 </row>
617 <row>
Jason Evans7091b412012-03-19 09:36:44 -0700618 <entry>512</entry>
Jason Evans0cdabd22014-10-14 22:19:21 -0700619 <entry>[2560, 3072, 3584, 4096]</entry>
Jason Evansaee7fd22010-11-24 22:00:02 -0800620 </row>
621 <row>
Jason Evans0cdabd22014-10-14 22:19:21 -0700622 <entry>1 KiB</entry>
623 <entry>[5 KiB, 6 KiB, 7 KiB, 8 KiB]</entry>
624 </row>
625 <row>
626 <entry>2 KiB</entry>
627 <entry>[10 KiB, 12 KiB, 14 KiB]</entry>
628 </row>
629 <row>
Jason Evansa5dbaef2015-08-14 00:35:11 -0700630 <entry morerows="7">Large</entry>
Jason Evans0cdabd22014-10-14 22:19:21 -0700631 <entry>2 KiB</entry>
632 <entry>[16 KiB]</entry>
633 </row>
634 <row>
Jason Evans7091b412012-03-19 09:36:44 -0700635 <entry>4 KiB</entry>
Jason Evans0cdabd22014-10-14 22:19:21 -0700636 <entry>[20 KiB, 24 KiB, 28 KiB, 32 KiB]</entry>
Jason Evansaee7fd22010-11-24 22:00:02 -0800637 </row>
638 <row>
Jason Evans0cdabd22014-10-14 22:19:21 -0700639 <entry>8 KiB</entry>
640 <entry>[40 KiB, 48 KiB, 54 KiB, 64 KiB]</entry>
641 </row>
642 <row>
643 <entry>16 KiB</entry>
644 <entry>[80 KiB, 96 KiB, 112 KiB, 128 KiB]</entry>
645 </row>
646 <row>
647 <entry>32 KiB</entry>
Jason Evansa5dbaef2015-08-14 00:35:11 -0700648 <entry>[160 KiB, 192 KiB, 224 KiB, 256 KiB]</entry>
Jason Evans0cdabd22014-10-14 22:19:21 -0700649 </row>
650 <row>
651 <entry>64 KiB</entry>
652 <entry>[320 KiB, 384 KiB, 448 KiB, 512 KiB]</entry>
653 </row>
654 <row>
655 <entry>128 KiB</entry>
Jason Evansf044bb22015-03-06 20:05:16 -0800656 <entry>[640 KiB, 768 KiB, 896 KiB, 1 MiB]</entry>
Jason Evans0cdabd22014-10-14 22:19:21 -0700657 </row>
658 <row>
659 <entry>256 KiB</entry>
Jason Evansa5dbaef2015-08-14 00:35:11 -0700660 <entry>[1280 KiB, 1536 KiB, 1792 KiB]</entry>
661 </row>
662 <row>
Jason Evansb582d2a2016-03-31 12:31:10 -0700663 <entry morerows="8">Huge</entry>
Jason Evansa5dbaef2015-08-14 00:35:11 -0700664 <entry>256 KiB</entry>
665 <entry>[2 MiB]</entry>
Jason Evans0cdabd22014-10-14 22:19:21 -0700666 </row>
667 <row>
668 <entry>512 KiB</entry>
Jason Evansf044bb22015-03-06 20:05:16 -0800669 <entry>[2560 KiB, 3 MiB, 3584 KiB, 4 MiB]</entry>
Jason Evans0cdabd22014-10-14 22:19:21 -0700670 </row>
671 <row>
672 <entry>1 MiB</entry>
673 <entry>[5 MiB, 6 MiB, 7 MiB, 8 MiB]</entry>
674 </row>
675 <row>
676 <entry>2 MiB</entry>
677 <entry>[10 MiB, 12 MiB, 14 MiB, 16 MiB]</entry>
678 </row>
679 <row>
Jason Evans7091b412012-03-19 09:36:44 -0700680 <entry>4 MiB</entry>
Jason Evans0cdabd22014-10-14 22:19:21 -0700681 <entry>[20 MiB, 24 MiB, 28 MiB, 32 MiB]</entry>
682 </row>
683 <row>
684 <entry>8 MiB</entry>
685 <entry>[40 MiB, 48 MiB, 56 MiB, 64 MiB]</entry>
686 </row>
687 <row>
688 <entry>...</entry>
689 <entry>...</entry>
Jason Evansaee7fd22010-11-24 22:00:02 -0800690 </row>
Jason Evansb582d2a2016-03-31 12:31:10 -0700691 <row>
692 <entry>512 PiB</entry>
693 <entry>[2560 PiB, 3 EiB, 3584 PiB, 4 EiB]</entry>
694 </row>
695 <row>
696 <entry>1 EiB</entry>
697 <entry>[5 EiB, 6 EiB, 7 EiB]</entry>
698 </row>
Jason Evansaee7fd22010-11-24 22:00:02 -0800699 </tbody>
700 </tgroup>
701 </table>
702 </refsect1>
703 <refsect1 id="mallctl_namespace">
704 <title>MALLCTL NAMESPACE</title>
705 <para>The following names are defined in the namespace accessible via the
Jason Evans9ebbfca92016-09-12 16:44:33 -0700706 <function>mallctl*()</function> functions. Value types are
Jason Evansaee7fd22010-11-24 22:00:02 -0800707 specified in parentheses, their readable/writable statuses are encoded as
708 <literal>rw</literal>, <literal>r-</literal>, <literal>-w</literal>, or
709 <literal>--</literal>, and required build configuration flags follow, if
710 any. A name element encoded as <literal>&lt;i&gt;</literal> or
711 <literal>&lt;j&gt;</literal> indicates an integer component, where the
712 integer varies from 0 to some upper value that must be determined via
713 introspection. In the case of <mallctl>stats.arenas.&lt;i&gt;.*</mallctl>,
714 <literal>&lt;i&gt;</literal> equal to <link
715 linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link> can be
716 used to access the summation of statistics from all arenas. Take special
717 note of the <link linkend="epoch"><mallctl>epoch</mallctl></link> mallctl,
718 which controls refreshing of cached dynamic statistics.</para>
719
720 <variablelist>
Jason Evansaabaf852013-10-30 14:52:09 -0700721 <varlistentry id="version">
Jason Evansaee7fd22010-11-24 22:00:02 -0800722 <term>
723 <mallctl>version</mallctl>
724 (<type>const char *</type>)
725 <literal>r-</literal>
726 </term>
727 <listitem><para>Return the jemalloc version string.</para></listitem>
728 </varlistentry>
729
730 <varlistentry id="epoch">
731 <term>
732 <mallctl>epoch</mallctl>
733 (<type>uint64_t</type>)
734 <literal>rw</literal>
735 </term>
736 <listitem><para>If a value is passed in, refresh the data from which
Jason Evans9ebbfca92016-09-12 16:44:33 -0700737 the <function>mallctl*()</function> functions report values,
Jason Evansaee7fd22010-11-24 22:00:02 -0800738 and increment the epoch. Return the current epoch. This is useful for
739 detecting whether another thread caused a refresh.</para></listitem>
740 </varlistentry>
741
Jason Evansf2bc8522015-07-17 16:38:25 -0700742 <varlistentry id="config.cache_oblivious">
743 <term>
744 <mallctl>config.cache_oblivious</mallctl>
745 (<type>bool</type>)
746 <literal>r-</literal>
747 </term>
748 <listitem><para><option>--enable-cache-oblivious</option> was specified
749 during build configuration.</para></listitem>
750 </varlistentry>
751
Jason Evansaabaf852013-10-30 14:52:09 -0700752 <varlistentry id="config.debug">
Jason Evansaee7fd22010-11-24 22:00:02 -0800753 <term>
754 <mallctl>config.debug</mallctl>
755 (<type>bool</type>)
756 <literal>r-</literal>
757 </term>
758 <listitem><para><option>--enable-debug</option> was specified during
759 build configuration.</para></listitem>
760 </varlistentry>
761
Jason Evansaabaf852013-10-30 14:52:09 -0700762 <varlistentry id="config.fill">
Jason Evansaee7fd22010-11-24 22:00:02 -0800763 <term>
Jason Evansaee7fd22010-11-24 22:00:02 -0800764 <mallctl>config.fill</mallctl>
765 (<type>bool</type>)
766 <literal>r-</literal>
767 </term>
768 <listitem><para><option>--enable-fill</option> was specified during
769 build configuration.</para></listitem>
770 </varlistentry>
771
Jason Evansaabaf852013-10-30 14:52:09 -0700772 <varlistentry id="config.lazy_lock">
Jason Evansaee7fd22010-11-24 22:00:02 -0800773 <term>
774 <mallctl>config.lazy_lock</mallctl>
775 (<type>bool</type>)
776 <literal>r-</literal>
777 </term>
778 <listitem><para><option>--enable-lazy-lock</option> was specified
779 during build configuration.</para></listitem>
780 </varlistentry>
781
Jason Evansf8290092016-02-07 14:23:22 -0800782 <varlistentry id="config.malloc_conf">
783 <term>
784 <mallctl>config.malloc_conf</mallctl>
785 (<type>const char *</type>)
786 <literal>r-</literal>
787 </term>
788 <listitem><para>Embedded configure-time-specified run-time options
789 string, empty unless <option>--with-malloc-conf</option> was specified
790 during build configuration.</para></listitem>
791 </varlistentry>
792
Jason Evansaabaf852013-10-30 14:52:09 -0700793 <varlistentry id="config.munmap">
Jason Evans2e671ff2012-05-09 16:12:00 -0700794 <term>
Jason Evans59ae2762012-04-16 17:52:27 -0700795 <mallctl>config.munmap</mallctl>
796 (<type>bool</type>)
797 <literal>r-</literal>
798 </term>
799 <listitem><para><option>--enable-munmap</option> was specified during
800 build configuration.</para></listitem>
801 </varlistentry>
802
Jason Evansaabaf852013-10-30 14:52:09 -0700803 <varlistentry id="config.prof">
Jason Evans59ae2762012-04-16 17:52:27 -0700804 <term>
Jason Evansaee7fd22010-11-24 22:00:02 -0800805 <mallctl>config.prof</mallctl>
806 (<type>bool</type>)
807 <literal>r-</literal>
808 </term>
809 <listitem><para><option>--enable-prof</option> was specified during
810 build configuration.</para></listitem>
811 </varlistentry>
812
Jason Evansaabaf852013-10-30 14:52:09 -0700813 <varlistentry id="config.prof_libgcc">
Jason Evansaee7fd22010-11-24 22:00:02 -0800814 <term>
815 <mallctl>config.prof_libgcc</mallctl>
816 (<type>bool</type>)
817 <literal>r-</literal>
818 </term>
819 <listitem><para><option>--disable-prof-libgcc</option> was not
820 specified during build configuration.</para></listitem>
821 </varlistentry>
822
Jason Evansaabaf852013-10-30 14:52:09 -0700823 <varlistentry id="config.prof_libunwind">
Jason Evansaee7fd22010-11-24 22:00:02 -0800824 <term>
825 <mallctl>config.prof_libunwind</mallctl>
826 (<type>bool</type>)
827 <literal>r-</literal>
828 </term>
829 <listitem><para><option>--enable-prof-libunwind</option> was specified
830 during build configuration.</para></listitem>
831 </varlistentry>
832
Jason Evansaabaf852013-10-30 14:52:09 -0700833 <varlistentry id="config.stats">
Jason Evansaee7fd22010-11-24 22:00:02 -0800834 <term>
835 <mallctl>config.stats</mallctl>
836 (<type>bool</type>)
837 <literal>r-</literal>
838 </term>
839 <listitem><para><option>--enable-stats</option> was specified during
840 build configuration.</para></listitem>
841 </varlistentry>
842
Jason Evansaabaf852013-10-30 14:52:09 -0700843 <varlistentry id="config.tcache">
Jason Evansaee7fd22010-11-24 22:00:02 -0800844 <term>
Jason Evansaee7fd22010-11-24 22:00:02 -0800845 <mallctl>config.tcache</mallctl>
846 (<type>bool</type>)
847 <literal>r-</literal>
848 </term>
849 <listitem><para><option>--disable-tcache</option> was not specified
850 during build configuration.</para></listitem>
851 </varlistentry>
852
Jason Evansaabaf852013-10-30 14:52:09 -0700853 <varlistentry id="config.tls">
Jason Evansaee7fd22010-11-24 22:00:02 -0800854 <term>
Jason Evansaee7fd22010-11-24 22:00:02 -0800855 <mallctl>config.tls</mallctl>
856 (<type>bool</type>)
857 <literal>r-</literal>
858 </term>
859 <listitem><para><option>--disable-tls</option> was not specified during
860 build configuration.</para></listitem>
861 </varlistentry>
862
Jason Evansaabaf852013-10-30 14:52:09 -0700863 <varlistentry id="config.utrace">
Jason Evansaee7fd22010-11-24 22:00:02 -0800864 <term>
Jason Evansb1476112012-04-05 13:36:17 -0700865 <mallctl>config.utrace</mallctl>
866 (<type>bool</type>)
867 <literal>r-</literal>
868 </term>
869 <listitem><para><option>--enable-utrace</option> was specified during
870 build configuration.</para></listitem>
871 </varlistentry>
872
Jason Evansaabaf852013-10-30 14:52:09 -0700873 <varlistentry id="config.valgrind">
Jason Evansb1476112012-04-05 13:36:17 -0700874 <term>
Jason Evans122449b2012-04-06 00:35:09 -0700875 <mallctl>config.valgrind</mallctl>
876 (<type>bool</type>)
877 <literal>r-</literal>
878 </term>
879 <listitem><para><option>--enable-valgrind</option> was specified during
880 build configuration.</para></listitem>
881 </varlistentry>
882
Jason Evansaabaf852013-10-30 14:52:09 -0700883 <varlistentry id="config.xmalloc">
Jason Evans122449b2012-04-06 00:35:09 -0700884 <term>
Jason Evansaee7fd22010-11-24 22:00:02 -0800885 <mallctl>config.xmalloc</mallctl>
886 (<type>bool</type>)
887 <literal>r-</literal>
888 </term>
889 <listitem><para><option>--enable-xmalloc</option> was specified during
890 build configuration.</para></listitem>
891 </varlistentry>
892
893 <varlistentry id="opt.abort">
894 <term>
895 <mallctl>opt.abort</mallctl>
896 (<type>bool</type>)
897 <literal>r-</literal>
898 </term>
899 <listitem><para>Abort-on-warning enabled/disabled. If true, most
900 warnings are fatal. The process will call
901 <citerefentry><refentrytitle>abort</refentrytitle>
902 <manvolnum>3</manvolnum></citerefentry> in these cases. This option is
903 disabled by default unless <option>--enable-debug</option> is
904 specified during configuration, in which case it is enabled by default.
905 </para></listitem>
906 </varlistentry>
907
Jason Evans609ae592012-10-11 13:53:15 -0700908 <varlistentry id="opt.dss">
909 <term>
910 <mallctl>opt.dss</mallctl>
911 (<type>const char *</type>)
912 <literal>r-</literal>
913 </term>
914 <listitem><para>dss (<citerefentry><refentrytitle>sbrk</refentrytitle>
915 <manvolnum>2</manvolnum></citerefentry>) allocation precedence as
916 related to <citerefentry><refentrytitle>mmap</refentrytitle>
917 <manvolnum>2</manvolnum></citerefentry> allocation. The following
Jason Evans4d434ad2014-04-15 12:09:48 -0700918 settings are supported if
919 <citerefentry><refentrytitle>sbrk</refentrytitle>
920 <manvolnum>2</manvolnum></citerefentry> is supported by the operating
Jason Evansf19bedb2016-11-01 13:25:42 -0700921 system: <quote>disabled</quote>, <quote>primary</quote>, and
922 <quote>secondary</quote>; otherwise only <quote>disabled</quote> is
923 supported. The default is <quote>secondary</quote> if
Jason Evans4d434ad2014-04-15 12:09:48 -0700924 <citerefentry><refentrytitle>sbrk</refentrytitle>
925 <manvolnum>2</manvolnum></citerefentry> is supported by the operating
Jason Evansf19bedb2016-11-01 13:25:42 -0700926 system; <quote>disabled</quote> otherwise.
Jason Evansd8a39002013-12-19 21:40:41 -0800927 </para></listitem>
928 </varlistentry>
929
930 <varlistentry id="opt.lg_chunk">
931 <term>
932 <mallctl>opt.lg_chunk</mallctl>
933 (<type>size_t</type>)
934 <literal>r-</literal>
935 </term>
936 <listitem><para>Virtual memory chunk size (log base 2). If a chunk
937 size outside the supported size range is specified, the size is
938 silently clipped to the minimum/maximum supported size. The default
Jason Evans5bd87962015-07-15 17:15:26 -0700939 chunk size is 2 MiB (2^21).
Jason Evansd8a39002013-12-19 21:40:41 -0800940 </para></listitem>
Jason Evans609ae592012-10-11 13:53:15 -0700941 </varlistentry>
942
Jason Evansaee7fd22010-11-24 22:00:02 -0800943 <varlistentry id="opt.narenas">
944 <term>
945 <mallctl>opt.narenas</mallctl>
Jason Evans8f683b92016-02-24 11:03:40 -0800946 (<type>unsigned</type>)
Jason Evansaee7fd22010-11-24 22:00:02 -0800947 <literal>r-</literal>
948 </term>
Jason Evans609ae592012-10-11 13:53:15 -0700949 <listitem><para>Maximum number of arenas to use for automatic
950 multiplexing of threads and arenas. The default is four times the
951 number of CPUs, or one if there is a single CPU.</para></listitem>
Jason Evansaee7fd22010-11-24 22:00:02 -0800952 </varlistentry>
953
Jason Evans243f7a02016-02-19 20:09:31 -0800954 <varlistentry id="opt.purge">
955 <term>
956 <mallctl>opt.purge</mallctl>
957 (<type>const char *</type>)
958 <literal>r-</literal>
959 </term>
960 <listitem><para>Purge mode is &ldquo;ratio&rdquo; (default) or
961 &ldquo;decay&rdquo;. See <link
962 linkend="opt.lg_dirty_mult"><mallctl>opt.lg_dirty_mult</mallctl></link>
963 for details of the ratio mode. See <link
964 linkend="opt.decay_time"><mallctl>opt.decay_time</mallctl></link> for
965 details of the decay mode.</para></listitem>
966 </varlistentry>
967
Jason Evansaee7fd22010-11-24 22:00:02 -0800968 <varlistentry id="opt.lg_dirty_mult">
969 <term>
970 <mallctl>opt.lg_dirty_mult</mallctl>
971 (<type>ssize_t</type>)
972 <literal>r-</literal>
973 </term>
974 <listitem><para>Per-arena minimum ratio (log base 2) of active to dirty
975 pages. Some dirty unused pages may be allowed to accumulate, within
976 the limit set by the ratio (or one chunk worth of dirty pages,
977 whichever is greater), before informing the kernel about some of those
978 pages via <citerefentry><refentrytitle>madvise</refentrytitle>
979 <manvolnum>2</manvolnum></citerefentry> or a similar system call. This
980 provides the kernel with sufficient information to recycle dirty pages
981 if physical memory becomes scarce and the pages remain unused. The
Jason Evanse3d13062012-10-30 15:42:37 -0700982 default minimum ratio is 8:1 (2^3:1); an option value of -1 will
Jason Evans8d6a3e82015-03-18 18:55:33 -0700983 disable dirty page purging. See <link
984 linkend="arenas.lg_dirty_mult"><mallctl>arenas.lg_dirty_mult</mallctl></link>
985 and <link
986 linkend="arena.i.lg_dirty_mult"><mallctl>arena.&lt;i&gt;.lg_dirty_mult</mallctl></link>
987 for related dynamic control options.</para></listitem>
Jason Evansaee7fd22010-11-24 22:00:02 -0800988 </varlistentry>
989
Jason Evans243f7a02016-02-19 20:09:31 -0800990 <varlistentry id="opt.decay_time">
991 <term>
992 <mallctl>opt.decay_time</mallctl>
993 (<type>ssize_t</type>)
994 <literal>r-</literal>
995 </term>
996 <listitem><para>Approximate time in seconds from the creation of a set
997 of unused dirty pages until an equivalent set of unused dirty pages is
998 purged and/or reused. The pages are incrementally purged according to a
999 sigmoidal decay curve that starts and ends with zero purge rate. A
1000 decay time of 0 causes all unused dirty pages to be purged immediately
1001 upon creation. A decay time of -1 disables purging. The default decay
1002 time is 10 seconds. See <link
1003 linkend="arenas.decay_time"><mallctl>arenas.decay_time</mallctl></link>
1004 and <link
1005 linkend="arena.i.decay_time"><mallctl>arena.&lt;i&gt;.decay_time</mallctl></link>
1006 for related dynamic control options.
1007 </para></listitem>
1008 </varlistentry>
1009
Jason Evansaee7fd22010-11-24 22:00:02 -08001010 <varlistentry id="opt.stats_print">
1011 <term>
1012 <mallctl>opt.stats_print</mallctl>
1013 (<type>bool</type>)
1014 <literal>r-</literal>
1015 </term>
1016 <listitem><para>Enable/disable statistics printing at exit. If
Jason Evans9ebbfca92016-09-12 16:44:33 -07001017 enabled, the <function>malloc_stats_print()</function>
Jason Evansaee7fd22010-11-24 22:00:02 -08001018 function is called at program exit via an
1019 <citerefentry><refentrytitle>atexit</refentrytitle>
1020 <manvolnum>3</manvolnum></citerefentry> function. If
1021 <option>--enable-stats</option> is specified during configuration, this
1022 has the potential to cause deadlock for a multi-threaded process that
1023 exits while one or more threads are executing in the memory allocation
Jason Evans9ebbfca92016-09-12 16:44:33 -07001024 functions. Furthermore, <function>atexit()</function> may
Jason Evans57efa7b2014-10-08 17:57:19 -07001025 allocate memory during application initialization and then deadlock
1026 internally when jemalloc in turn calls
Jason Evans9ebbfca92016-09-12 16:44:33 -07001027 <function>atexit()</function>, so this option is not
hitstergtdeb688422016-04-18 11:08:39 +01001028 universally usable (though the application can register its own
Jason Evans9ebbfca92016-09-12 16:44:33 -07001029 <function>atexit()</function> function with equivalent
Jason Evans57efa7b2014-10-08 17:57:19 -07001030 functionality). Therefore, this option should only be used with care;
1031 it is primarily intended as a performance tuning aid during application
Jason Evansaee7fd22010-11-24 22:00:02 -08001032 development. This option is disabled by default.</para></listitem>
1033 </varlistentry>
1034
1035 <varlistentry id="opt.junk">
1036 <term>
1037 <mallctl>opt.junk</mallctl>
Guilherme Goncalves2c5cb612014-12-08 19:12:41 -02001038 (<type>const char *</type>)
Jason Evansaee7fd22010-11-24 22:00:02 -08001039 <literal>r-</literal>
1040 [<option>--enable-fill</option>]
1041 </term>
Jason Evansf19bedb2016-11-01 13:25:42 -07001042 <listitem><para>Junk filling. If set to <quote>alloc</quote>, each byte
1043 of uninitialized allocated memory will be initialized to
1044 <literal>0xa5</literal>. If set to <quote>free</quote>, all deallocated
1045 memory will be initialized to <literal>0x5a</literal>. If set to
1046 <quote>true</quote>, both allocated and deallocated memory will be
1047 initialized, and if set to <quote>false</quote>, junk filling be
1048 disabled entirely. This is intended for debugging and will impact
1049 performance negatively. This option is <quote>false</quote> by default
1050 unless <option>--enable-debug</option> is specified during
1051 configuration, in which case it is <quote>true</quote> by default unless
Guilherme Goncalves2c5cb612014-12-08 19:12:41 -02001052 running inside <ulink
Jason Evans781fe752012-05-15 14:48:14 -07001053 url="http://valgrind.org/">Valgrind</ulink>.</para></listitem>
Jason Evansaee7fd22010-11-24 22:00:02 -08001054 </varlistentry>
1055
Jason Evans122449b2012-04-06 00:35:09 -07001056 <varlistentry id="opt.quarantine">
1057 <term>
1058 <mallctl>opt.quarantine</mallctl>
1059 (<type>size_t</type>)
1060 <literal>r-</literal>
1061 [<option>--enable-fill</option>]
1062 </term>
1063 <listitem><para>Per thread quarantine size in bytes. If non-zero, each
1064 thread maintains a FIFO object quarantine that stores up to the
1065 specified number of bytes of memory. The quarantined memory is not
1066 freed until it is released from quarantine, though it is immediately
1067 junk-filled if the <link
1068 linkend="opt.junk"><mallctl>opt.junk</mallctl></link> option is
1069 enabled. This feature is of particular use in combination with <ulink
Jason Evansd926c902012-04-25 23:17:57 -07001070 url="http://valgrind.org/">Valgrind</ulink>, which can detect attempts
1071 to access quarantined objects. This is intended for debugging and will
Jason Evans781fe752012-05-15 14:48:14 -07001072 impact performance negatively. The default quarantine size is 0 unless
1073 running inside Valgrind, in which case the default is 16
1074 MiB.</para></listitem>
Jason Evans122449b2012-04-06 00:35:09 -07001075 </varlistentry>
1076
1077 <varlistentry id="opt.redzone">
1078 <term>
1079 <mallctl>opt.redzone</mallctl>
1080 (<type>bool</type>)
1081 <literal>r-</literal>
1082 [<option>--enable-fill</option>]
1083 </term>
1084 <listitem><para>Redzones enabled/disabled. If enabled, small
1085 allocations have redzones before and after them. Furthermore, if the
1086 <link linkend="opt.junk"><mallctl>opt.junk</mallctl></link> option is
1087 enabled, the redzones are checked for corruption during deallocation.
1088 However, the primary intended purpose of this feature is to be used in
Jason Evansd926c902012-04-25 23:17:57 -07001089 combination with <ulink url="http://valgrind.org/">Valgrind</ulink>,
1090 which needs redzones in order to do effective buffer overflow/underflow
1091 detection. This option is intended for debugging and will impact
1092 performance negatively. This option is disabled by
Jason Evans781fe752012-05-15 14:48:14 -07001093 default unless running inside Valgrind.</para></listitem>
Jason Evans122449b2012-04-06 00:35:09 -07001094 </varlistentry>
1095
Jason Evansaee7fd22010-11-24 22:00:02 -08001096 <varlistentry id="opt.zero">
1097 <term>
1098 <mallctl>opt.zero</mallctl>
1099 (<type>bool</type>)
1100 <literal>r-</literal>
1101 [<option>--enable-fill</option>]
1102 </term>
1103 <listitem><para>Zero filling enabled/disabled. If enabled, each byte
1104 of uninitialized allocated memory will be initialized to 0. Note that
1105 this initialization only happens once for each byte, so
Jason Evans9ebbfca92016-09-12 16:44:33 -07001106 <function>realloc()</function> and
1107 <function>rallocx()</function> calls do not zero memory that
Jason Evansaee7fd22010-11-24 22:00:02 -08001108 was previously allocated. This is intended for debugging and will
1109 impact performance negatively. This option is disabled by default.
1110 </para></listitem>
1111 </varlistentry>
1112
Jason Evansb1476112012-04-05 13:36:17 -07001113 <varlistentry id="opt.utrace">
1114 <term>
1115 <mallctl>opt.utrace</mallctl>
1116 (<type>bool</type>)
1117 <literal>r-</literal>
1118 [<option>--enable-utrace</option>]
1119 </term>
1120 <listitem><para>Allocation tracing based on
1121 <citerefentry><refentrytitle>utrace</refentrytitle>
1122 <manvolnum>2</manvolnum></citerefentry> enabled/disabled. This option
1123 is disabled by default.</para></listitem>
1124 </varlistentry>
1125
Jason Evansaee7fd22010-11-24 22:00:02 -08001126 <varlistentry id="opt.xmalloc">
1127 <term>
1128 <mallctl>opt.xmalloc</mallctl>
1129 (<type>bool</type>)
1130 <literal>r-</literal>
1131 [<option>--enable-xmalloc</option>]
1132 </term>
1133 <listitem><para>Abort-on-out-of-memory enabled/disabled. If enabled,
1134 rather than returning failure for any allocation function, display a
1135 diagnostic message on <constant>STDERR_FILENO</constant> and cause the
1136 program to drop core (using
1137 <citerefentry><refentrytitle>abort</refentrytitle>
1138 <manvolnum>3</manvolnum></citerefentry>). If an application is
1139 designed to depend on this behavior, set the option at compile time by
1140 including the following in the source code:
1141 <programlisting language="C"><![CDATA[
1142malloc_conf = "xmalloc:true";]]></programlisting>
1143 This option is disabled by default.</para></listitem>
1144 </varlistentry>
1145
1146 <varlistentry id="opt.tcache">
1147 <term>
1148 <mallctl>opt.tcache</mallctl>
1149 (<type>bool</type>)
1150 <literal>r-</literal>
1151 [<option>--enable-tcache</option>]
1152 </term>
Jason Evans1cb181e2015-01-29 15:30:47 -08001153 <listitem><para>Thread-specific caching (tcache) enabled/disabled. When
1154 there are multiple threads, each thread uses a tcache for objects up to
1155 a certain size. Thread-specific caching allows many allocations to be
1156 satisfied without performing any thread synchronization, at the cost of
1157 increased memory use. See the <link
Jason Evansaee7fd22010-11-24 22:00:02 -08001158 linkend="opt.lg_tcache_max"><mallctl>opt.lg_tcache_max</mallctl></link>
Jason Evans4507f342012-03-05 14:34:37 -08001159 option for related tuning information. This option is enabled by
Jason Evans174b70e2012-05-15 23:31:53 -07001160 default unless running inside <ulink
Jason Evansbd87b012014-04-15 16:35:08 -07001161 url="http://valgrind.org/">Valgrind</ulink>, in which case it is
1162 forcefully disabled.</para></listitem>
Jason Evansaee7fd22010-11-24 22:00:02 -08001163 </varlistentry>
1164
Jason Evansaee7fd22010-11-24 22:00:02 -08001165 <varlistentry id="opt.lg_tcache_max">
1166 <term>
1167 <mallctl>opt.lg_tcache_max</mallctl>
1168 (<type>size_t</type>)
1169 <literal>r-</literal>
1170 [<option>--enable-tcache</option>]
1171 </term>
1172 <listitem><para>Maximum size class (log base 2) to cache in the
Jason Evans1cb181e2015-01-29 15:30:47 -08001173 thread-specific cache (tcache). At a minimum, all small size classes
1174 are cached, and at a maximum all large size classes are cached. The
Jason Evansaee7fd22010-11-24 22:00:02 -08001175 default maximum is 32 KiB (2^15).</para></listitem>
1176 </varlistentry>
1177
1178 <varlistentry id="opt.prof">
1179 <term>
1180 <mallctl>opt.prof</mallctl>
1181 (<type>bool</type>)
1182 <literal>r-</literal>
1183 [<option>--enable-prof</option>]
1184 </term>
1185 <listitem><para>Memory profiling enabled/disabled. If enabled, profile
Jason Evans0b25fe72012-04-17 16:39:33 -07001186 memory allocation activity. See the <link
Jason Evansaee7fd22010-11-24 22:00:02 -08001187 linkend="opt.prof_active"><mallctl>opt.prof_active</mallctl></link>
1188 option for on-the-fly activation/deactivation. See the <link
1189 linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link>
1190 option for probabilistic sampling control. See the <link
1191 linkend="opt.prof_accum"><mallctl>opt.prof_accum</mallctl></link>
1192 option for control of cumulative sample reporting. See the <link
Jason Evansaee7fd22010-11-24 22:00:02 -08001193 linkend="opt.lg_prof_interval"><mallctl>opt.lg_prof_interval</mallctl></link>
Jason Evans0b25fe72012-04-17 16:39:33 -07001194 option for information on interval-triggered profile dumping, the <link
1195 linkend="opt.prof_gdump"><mallctl>opt.prof_gdump</mallctl></link>
1196 option for information on high-water-triggered profile dumping, and the
1197 <link linkend="opt.prof_final"><mallctl>opt.prof_final</mallctl></link>
1198 option for final profile dumping. Profile output is compatible with
Jason Evans70417202015-05-01 12:31:12 -07001199 the <command>jeprof</command> command, which is based on the
1200 <command>pprof</command> that is developed as part of the <ulink
1201 url="http://code.google.com/p/gperftools/">gperftools
Jason Evans5ec703d2016-02-24 15:35:24 -08001202 package</ulink>. See <link linkend="heap_profile_format">HEAP PROFILE
1203 FORMAT</link> for heap profile format documentation.</para></listitem>
Jason Evansaee7fd22010-11-24 22:00:02 -08001204 </varlistentry>
1205
1206 <varlistentry id="opt.prof_prefix">
1207 <term>
1208 <mallctl>opt.prof_prefix</mallctl>
1209 (<type>const char *</type>)
1210 <literal>r-</literal>
1211 [<option>--enable-prof</option>]
1212 </term>
1213 <listitem><para>Filename prefix for profile dumps. If the prefix is
1214 set to the empty string, no automatic dumps will occur; this is
1215 primarily useful for disabling the automatic final heap dump (which
1216 also disables leak reporting, if enabled). The default prefix is
1217 <filename>jeprof</filename>.</para></listitem>
1218 </varlistentry>
1219
Jason Evansaee7fd22010-11-24 22:00:02 -08001220 <varlistentry id="opt.prof_active">
1221 <term>
1222 <mallctl>opt.prof_active</mallctl>
1223 (<type>bool</type>)
Jason Evans8d6a3e82015-03-18 18:55:33 -07001224 <literal>r-</literal>
Jason Evansaee7fd22010-11-24 22:00:02 -08001225 [<option>--enable-prof</option>]
1226 </term>
1227 <listitem><para>Profiling activated/deactivated. This is a secondary
1228 control mechanism that makes it possible to start the application with
1229 profiling enabled (see the <link
1230 linkend="opt.prof"><mallctl>opt.prof</mallctl></link> option) but
1231 inactive, then toggle profiling at any time during program execution
1232 with the <link
1233 linkend="prof.active"><mallctl>prof.active</mallctl></link> mallctl.
1234 This option is enabled by default.</para></listitem>
1235 </varlistentry>
1236
Jason Evansfc12c0b2014-10-03 23:25:30 -07001237 <varlistentry id="opt.prof_thread_active_init">
1238 <term>
1239 <mallctl>opt.prof_thread_active_init</mallctl>
1240 (<type>bool</type>)
1241 <literal>r-</literal>
1242 [<option>--enable-prof</option>]
1243 </term>
1244 <listitem><para>Initial setting for <link
1245 linkend="thread.prof.active"><mallctl>thread.prof.active</mallctl></link>
1246 in newly created threads. The initial setting for newly created threads
1247 can also be changed during execution via the <link
1248 linkend="prof.thread_active_init"><mallctl>prof.thread_active_init</mallctl></link>
1249 mallctl. This option is enabled by default.</para></listitem>
1250 </varlistentry>
1251
Jason Evansaee7fd22010-11-24 22:00:02 -08001252 <varlistentry id="opt.lg_prof_sample">
1253 <term>
1254 <mallctl>opt.lg_prof_sample</mallctl>
Jason Evans602c8e02014-08-18 16:22:13 -07001255 (<type>size_t</type>)
Jason Evansaee7fd22010-11-24 22:00:02 -08001256 <literal>r-</literal>
1257 [<option>--enable-prof</option>]
1258 </term>
1259 <listitem><para>Average interval (log base 2) between allocation
1260 samples, as measured in bytes of allocation activity. Increasing the
1261 sampling interval decreases profile fidelity, but also decreases the
Jason Evans0b25fe72012-04-17 16:39:33 -07001262 computational overhead. The default sample interval is 512 KiB (2^19
1263 B).</para></listitem>
Jason Evansaee7fd22010-11-24 22:00:02 -08001264 </varlistentry>
1265
1266 <varlistentry id="opt.prof_accum">
1267 <term>
1268 <mallctl>opt.prof_accum</mallctl>
1269 (<type>bool</type>)
1270 <literal>r-</literal>
1271 [<option>--enable-prof</option>]
1272 </term>
1273 <listitem><para>Reporting of cumulative object/byte counts in profile
1274 dumps enabled/disabled. If this option is enabled, every unique
1275 backtrace must be stored for the duration of execution. Depending on
1276 the application, this can impose a large memory overhead, and the
Jason Evans0b25fe72012-04-17 16:39:33 -07001277 cumulative counts are not always of interest. This option is disabled
Jason Evans0b526ff2012-02-13 18:04:26 -08001278 by default.</para></listitem>
Jason Evansaee7fd22010-11-24 22:00:02 -08001279 </varlistentry>
1280
1281 <varlistentry id="opt.lg_prof_interval">
1282 <term>
1283 <mallctl>opt.lg_prof_interval</mallctl>
1284 (<type>ssize_t</type>)
1285 <literal>r-</literal>
1286 [<option>--enable-prof</option>]
1287 </term>
1288 <listitem><para>Average interval (log base 2) between memory profile
1289 dumps, as measured in bytes of allocation activity. The actual
1290 interval between dumps may be sporadic because decentralized allocation
1291 counters are used to avoid synchronization bottlenecks. Profiles are
1292 dumped to files named according to the pattern
1293 <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.i&lt;iseq&gt;.heap</filename>,
1294 where <literal>&lt;prefix&gt;</literal> is controlled by the
1295 <link
1296 linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
1297 option. By default, interval-triggered profile dumping is disabled
1298 (encoded as -1).
1299 </para></listitem>
1300 </varlistentry>
1301
1302 <varlistentry id="opt.prof_gdump">
1303 <term>
1304 <mallctl>opt.prof_gdump</mallctl>
1305 (<type>bool</type>)
1306 <literal>r-</literal>
1307 [<option>--enable-prof</option>]
1308 </term>
Jason Evans5b8ed5b2015-01-25 21:16:57 -08001309 <listitem><para>Set the initial state of <link
1310 linkend="prof.gdump"><mallctl>prof.gdump</mallctl></link>, which when
1311 enabled triggers a memory profile dump every time the total virtual
1312 memory exceeds the previous maximum. This option is disabled by
1313 default.</para></listitem>
Jason Evansaee7fd22010-11-24 22:00:02 -08001314 </varlistentry>
1315
Jason Evans0b25fe72012-04-17 16:39:33 -07001316 <varlistentry id="opt.prof_final">
1317 <term>
1318 <mallctl>opt.prof_final</mallctl>
1319 (<type>bool</type>)
1320 <literal>r-</literal>
1321 [<option>--enable-prof</option>]
1322 </term>
1323 <listitem><para>Use an
1324 <citerefentry><refentrytitle>atexit</refentrytitle>
1325 <manvolnum>3</manvolnum></citerefentry> function to dump final memory
1326 usage to a file named according to the pattern
1327 <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.f.heap</filename>,
1328 where <literal>&lt;prefix&gt;</literal> is controlled by the <link
1329 linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
Jason Evans9ebbfca92016-09-12 16:44:33 -07001330 option. Note that <function>atexit()</function> may allocate
Jason Evans57efa7b2014-10-08 17:57:19 -07001331 memory during application initialization and then deadlock internally
Jason Evans9ebbfca92016-09-12 16:44:33 -07001332 when jemalloc in turn calls <function>atexit()</function>, so
hitstergtdeb688422016-04-18 11:08:39 +01001333 this option is not universally usable (though the application can
Jason Evans9ebbfca92016-09-12 16:44:33 -07001334 register its own <function>atexit()</function> function with
Jason Evans57efa7b2014-10-08 17:57:19 -07001335 equivalent functionality). This option is disabled by
1336 default.</para></listitem>
Jason Evans0b25fe72012-04-17 16:39:33 -07001337 </varlistentry>
1338
Jason Evansaee7fd22010-11-24 22:00:02 -08001339 <varlistentry id="opt.prof_leak">
1340 <term>
1341 <mallctl>opt.prof_leak</mallctl>
1342 (<type>bool</type>)
1343 <literal>r-</literal>
1344 [<option>--enable-prof</option>]
1345 </term>
1346 <listitem><para>Leak reporting enabled/disabled. If enabled, use an
1347 <citerefentry><refentrytitle>atexit</refentrytitle>
1348 <manvolnum>3</manvolnum></citerefentry> function to report memory leaks
1349 detected by allocation sampling. See the
Jason Evansaee7fd22010-11-24 22:00:02 -08001350 <link linkend="opt.prof"><mallctl>opt.prof</mallctl></link> option for
1351 information on analyzing heap profile output. This option is disabled
1352 by default.</para></listitem>
1353 </varlistentry>
1354
Jason Evansaabaf852013-10-30 14:52:09 -07001355 <varlistentry id="thread.arena">
Jason Evansaee7fd22010-11-24 22:00:02 -08001356 <term>
Jason Evansaee7fd22010-11-24 22:00:02 -08001357 <mallctl>thread.arena</mallctl>
1358 (<type>unsigned</type>)
1359 <literal>rw</literal>
1360 </term>
1361 <listitem><para>Get or set the arena associated with the calling
Jason Evans609ae592012-10-11 13:53:15 -07001362 thread. If the specified arena was not initialized beforehand (see the
1363 <link
Jason Evansaee7fd22010-11-24 22:00:02 -08001364 linkend="arenas.initialized"><mallctl>arenas.initialized</mallctl></link>
1365 mallctl), it will be automatically initialized as a side effect of
1366 calling this interface.</para></listitem>
1367 </varlistentry>
1368
Jason Evansecf229a2010-12-03 15:55:47 -08001369 <varlistentry id="thread.allocated">
Jason Evansaee7fd22010-11-24 22:00:02 -08001370 <term>
1371 <mallctl>thread.allocated</mallctl>
1372 (<type>uint64_t</type>)
1373 <literal>r-</literal>
1374 [<option>--enable-stats</option>]
1375 </term>
1376 <listitem><para>Get the total number of bytes ever allocated by the
1377 calling thread. This counter has the potential to wrap around; it is
1378 up to the application to appropriately interpret the counter in such
1379 cases.</para></listitem>
1380 </varlistentry>
1381
Jason Evansaabaf852013-10-30 14:52:09 -07001382 <varlistentry id="thread.allocatedp">
Jason Evansaee7fd22010-11-24 22:00:02 -08001383 <term>
Jason Evansecf229a2010-12-03 15:55:47 -08001384 <mallctl>thread.allocatedp</mallctl>
1385 (<type>uint64_t *</type>)
1386 <literal>r-</literal>
1387 [<option>--enable-stats</option>]
1388 </term>
1389 <listitem><para>Get a pointer to the the value that is returned by the
1390 <link
1391 linkend="thread.allocated"><mallctl>thread.allocated</mallctl></link>
1392 mallctl. This is useful for avoiding the overhead of repeated
Jason Evans9ebbfca92016-09-12 16:44:33 -07001393 <function>mallctl*()</function> calls.</para></listitem>
Jason Evansecf229a2010-12-03 15:55:47 -08001394 </varlistentry>
1395
1396 <varlistentry id="thread.deallocated">
1397 <term>
Jason Evansaee7fd22010-11-24 22:00:02 -08001398 <mallctl>thread.deallocated</mallctl>
1399 (<type>uint64_t</type>)
1400 <literal>r-</literal>
1401 [<option>--enable-stats</option>]
1402 </term>
1403 <listitem><para>Get the total number of bytes ever deallocated by the
1404 calling thread. This counter has the potential to wrap around; it is
1405 up to the application to appropriately interpret the counter in such
1406 cases.</para></listitem>
1407 </varlistentry>
1408
Jason Evansaabaf852013-10-30 14:52:09 -07001409 <varlistentry id="thread.deallocatedp">
Jason Evansecf229a2010-12-03 15:55:47 -08001410 <term>
1411 <mallctl>thread.deallocatedp</mallctl>
1412 (<type>uint64_t *</type>)
1413 <literal>r-</literal>
1414 [<option>--enable-stats</option>]
1415 </term>
1416 <listitem><para>Get a pointer to the the value that is returned by the
1417 <link
1418 linkend="thread.deallocated"><mallctl>thread.deallocated</mallctl></link>
1419 mallctl. This is useful for avoiding the overhead of repeated
Jason Evans9ebbfca92016-09-12 16:44:33 -07001420 <function>mallctl*()</function> calls.</para></listitem>
Jason Evansecf229a2010-12-03 15:55:47 -08001421 </varlistentry>
1422
Jason Evansaabaf852013-10-30 14:52:09 -07001423 <varlistentry id="thread.tcache.enabled">
Jason Evanse7b8fa12012-03-16 17:09:32 -07001424 <term>
Jason Evansd4be8b72012-03-26 18:54:44 -07001425 <mallctl>thread.tcache.enabled</mallctl>
1426 (<type>bool</type>)
1427 <literal>rw</literal>
1428 [<option>--enable-tcache</option>]
1429 </term>
1430 <listitem><para>Enable/disable calling thread's tcache. The tcache is
1431 implicitly flushed as a side effect of becoming
1432 disabled (see <link
Jason Evans1cb181e2015-01-29 15:30:47 -08001433 linkend="thread.tcache.flush"><mallctl>thread.tcache.flush</mallctl></link>).
Jason Evansd4be8b72012-03-26 18:54:44 -07001434 </para></listitem>
1435 </varlistentry>
1436
Jason Evansaabaf852013-10-30 14:52:09 -07001437 <varlistentry id="thread.tcache.flush">
Jason Evansd4be8b72012-03-26 18:54:44 -07001438 <term>
Jason Evanse7b8fa12012-03-16 17:09:32 -07001439 <mallctl>thread.tcache.flush</mallctl>
1440 (<type>void</type>)
1441 <literal>--</literal>
1442 [<option>--enable-tcache</option>]
1443 </term>
Jason Evans1cb181e2015-01-29 15:30:47 -08001444 <listitem><para>Flush calling thread's thread-specific cache (tcache).
1445 This interface releases all cached objects and internal data structures
1446 associated with the calling thread's tcache. Ordinarily, this interface
Jason Evanse7b8fa12012-03-16 17:09:32 -07001447 need not be called, since automatic periodic incremental garbage
1448 collection occurs, and the thread cache is automatically discarded when
1449 a thread exits. However, garbage collection is triggered by allocation
1450 activity, so it is possible for a thread that stops
1451 allocating/deallocating to retain its cache indefinitely, in which case
1452 the developer may find manual flushing useful.</para></listitem>
1453 </varlistentry>
1454
Jason Evans602c8e02014-08-18 16:22:13 -07001455 <varlistentry id="thread.prof.name">
1456 <term>
1457 <mallctl>thread.prof.name</mallctl>
1458 (<type>const char *</type>)
Jason Evansfc12c0b2014-10-03 23:25:30 -07001459 <literal>r-</literal> or
1460 <literal>-w</literal>
Jason Evans602c8e02014-08-18 16:22:13 -07001461 [<option>--enable-prof</option>]
1462 </term>
1463 <listitem><para>Get/set the descriptive name associated with the calling
1464 thread in memory profile dumps. An internal copy of the name string is
1465 created, so the input string need not be maintained after this interface
1466 completes execution. The output string of this interface should be
1467 copied for non-ephemeral uses, because multiple implementation details
Jason Evansfc12c0b2014-10-03 23:25:30 -07001468 can cause asynchronous string deallocation. Furthermore, each
1469 invocation of this interface can only read or write; simultaneous
1470 read/write is not supported due to string lifetime limitations. The
Jason Evansea7449f2015-10-19 16:56:05 -04001471 name string must be nil-terminated and comprised only of characters in
1472 the sets recognized
Jason Evansfc12c0b2014-10-03 23:25:30 -07001473 by <citerefentry><refentrytitle>isgraph</refentrytitle>
1474 <manvolnum>3</manvolnum></citerefentry> and
1475 <citerefentry><refentrytitle>isblank</refentrytitle>
1476 <manvolnum>3</manvolnum></citerefentry>.</para></listitem>
Jason Evans602c8e02014-08-18 16:22:13 -07001477 </varlistentry>
1478
1479 <varlistentry id="thread.prof.active">
1480 <term>
1481 <mallctl>thread.prof.active</mallctl>
1482 (<type>bool</type>)
1483 <literal>rw</literal>
1484 [<option>--enable-prof</option>]
1485 </term>
1486 <listitem><para>Control whether sampling is currently active for the
Jason Evansfc12c0b2014-10-03 23:25:30 -07001487 calling thread. This is an activation mechanism in addition to <link
Jason Evans602c8e02014-08-18 16:22:13 -07001488 linkend="prof.active"><mallctl>prof.active</mallctl></link>; both must
1489 be active for the calling thread to sample. This flag is enabled by
1490 default.</para></listitem>
1491 </varlistentry>
1492
Jason Evans1cb181e2015-01-29 15:30:47 -08001493 <varlistentry id="tcache.create">
1494 <term>
1495 <mallctl>tcache.create</mallctl>
1496 (<type>unsigned</type>)
1497 <literal>r-</literal>
1498 [<option>--enable-tcache</option>]
1499 </term>
1500 <listitem><para>Create an explicit thread-specific cache (tcache) and
1501 return an identifier that can be passed to the <link
1502 linkend="MALLOCX_TCACHE"><constant>MALLOCX_TCACHE(<parameter>tc</parameter>)</constant></link>
1503 macro to explicitly use the specified cache rather than the
1504 automatically managed one that is used by default. Each explicit cache
1505 can be used by only one thread at a time; the application must assure
1506 that this constraint holds.
1507 </para></listitem>
1508 </varlistentry>
1509
1510 <varlistentry id="tcache.flush">
1511 <term>
1512 <mallctl>tcache.flush</mallctl>
1513 (<type>unsigned</type>)
1514 <literal>-w</literal>
1515 [<option>--enable-tcache</option>]
1516 </term>
1517 <listitem><para>Flush the specified thread-specific cache (tcache). The
1518 same considerations apply to this interface as to <link
1519 linkend="thread.tcache.flush"><mallctl>thread.tcache.flush</mallctl></link>,
Jason Evans109712b2016-02-19 12:08:14 -08001520 except that the tcache will never be automatically discarded.
Jason Evans1cb181e2015-01-29 15:30:47 -08001521 </para></listitem>
1522 </varlistentry>
1523
1524 <varlistentry id="tcache.destroy">
1525 <term>
1526 <mallctl>tcache.destroy</mallctl>
1527 (<type>unsigned</type>)
1528 <literal>-w</literal>
1529 [<option>--enable-tcache</option>]
1530 </term>
1531 <listitem><para>Flush the specified thread-specific cache (tcache) and
1532 make the identifier available for use during a future tcache creation.
1533 </para></listitem>
1534 </varlistentry>
1535
Jason Evans609ae592012-10-11 13:53:15 -07001536 <varlistentry id="arena.i.purge">
1537 <term>
1538 <mallctl>arena.&lt;i&gt;.purge</mallctl>
Jason Evansa2c719b2014-04-15 12:46:28 -07001539 (<type>void</type>)
Jason Evans609ae592012-10-11 13:53:15 -07001540 <literal>--</literal>
1541 </term>
Jason Evans243f7a02016-02-19 20:09:31 -08001542 <listitem><para>Purge all unused dirty pages for arena &lt;i&gt;, or for
Jason Evans609ae592012-10-11 13:53:15 -07001543 all arenas if &lt;i&gt; equals <link
1544 linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link>.
1545 </para></listitem>
1546 </varlistentry>
1547
Jason Evans243f7a02016-02-19 20:09:31 -08001548 <varlistentry id="arena.i.decay">
1549 <term>
1550 <mallctl>arena.&lt;i&gt;.decay</mallctl>
1551 (<type>void</type>)
1552 <literal>--</literal>
1553 </term>
1554 <listitem><para>Trigger decay-based purging of unused dirty pages for
1555 arena &lt;i&gt;, or for all arenas if &lt;i&gt; equals <link
1556 linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link>.
1557 The proportion of unused dirty pages to be purged depends on the current
1558 time; see <link
1559 linkend="opt.decay_time"><mallctl>opt.decay_time</mallctl></link> for
1560 details.</para></listitem>
1561 </varlistentry>
1562
Jason Evans19ff2ce2016-04-22 14:37:17 -07001563 <varlistentry id="arena.i.reset">
1564 <term>
1565 <mallctl>arena.&lt;i&gt;.reset</mallctl>
1566 (<type>void</type>)
1567 <literal>--</literal>
1568 </term>
1569 <listitem><para>Discard all of the arena's extant allocations. This
1570 interface can only be used with arenas created via <link
1571 linkend="arenas.extend"><mallctl>arenas.extend</mallctl></link>. None
1572 of the arena's discarded/cached allocations may accessed afterward. As
1573 part of this requirement, all thread caches which were used to
1574 allocate/deallocate in conjunction with the arena must be flushed
1575 beforehand. This interface cannot be used if running inside Valgrind,
1576 nor if the <link linkend="opt.quarantine">quarantine</link> size is
1577 non-zero.</para></listitem>
1578 </varlistentry>
1579
Jason Evans609ae592012-10-11 13:53:15 -07001580 <varlistentry id="arena.i.dss">
1581 <term>
1582 <mallctl>arena.&lt;i&gt;.dss</mallctl>
1583 (<type>const char *</type>)
1584 <literal>rw</literal>
1585 </term>
1586 <listitem><para>Set the precedence of dss allocation as related to mmap
1587 allocation for arena &lt;i&gt;, or for all arenas if &lt;i&gt; equals
1588 <link
Jason Evanse2deab72014-05-15 22:22:27 -07001589 linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link>. See
1590 <link linkend="opt.dss"><mallctl>opt.dss</mallctl></link> for supported
1591 settings.</para></listitem>
Jason Evans609ae592012-10-11 13:53:15 -07001592 </varlistentry>
1593
Jason Evans8d6a3e82015-03-18 18:55:33 -07001594 <varlistentry id="arena.i.lg_dirty_mult">
1595 <term>
1596 <mallctl>arena.&lt;i&gt;.lg_dirty_mult</mallctl>
1597 (<type>ssize_t</type>)
1598 <literal>rw</literal>
1599 </term>
1600 <listitem><para>Current per-arena minimum ratio (log base 2) of active
1601 to dirty pages for arena &lt;i&gt;. Each time this interface is set and
1602 the ratio is increased, pages are synchronously purged as necessary to
1603 impose the new ratio. See <link
1604 linkend="opt.lg_dirty_mult"><mallctl>opt.lg_dirty_mult</mallctl></link>
1605 for additional information.</para></listitem>
1606 </varlistentry>
1607
Jason Evans243f7a02016-02-19 20:09:31 -08001608 <varlistentry id="arena.i.decay_time">
1609 <term>
1610 <mallctl>arena.&lt;i&gt;.decay_time</mallctl>
1611 (<type>ssize_t</type>)
1612 <literal>rw</literal>
1613 </term>
1614 <listitem><para>Current per-arena approximate time in seconds from the
1615 creation of a set of unused dirty pages until an equivalent set of
1616 unused dirty pages is purged and/or reused. Each time this interface is
1617 set, all currently unused dirty pages are considered to have fully
1618 decayed, which causes immediate purging of all unused dirty pages unless
1619 the decay time is set to -1 (i.e. purging disabled). See <link
1620 linkend="opt.decay_time"><mallctl>opt.decay_time</mallctl></link> for
1621 additional information.</para></listitem>
1622 </varlistentry>
1623
Jason Evansb49a3342015-07-28 11:28:19 -04001624 <varlistentry id="arena.i.chunk_hooks">
aravindfb7fe502014-05-05 15:16:56 -07001625 <term>
Jason Evansb49a3342015-07-28 11:28:19 -04001626 <mallctl>arena.&lt;i&gt;.chunk_hooks</mallctl>
1627 (<type>chunk_hooks_t</type>)
aravindfb7fe502014-05-05 15:16:56 -07001628 <literal>rw</literal>
1629 </term>
Jason Evansb49a3342015-07-28 11:28:19 -04001630 <listitem><para>Get or set the chunk management hook functions for arena
1631 &lt;i&gt;. The functions must be capable of operating on all extant
1632 chunks associated with arena &lt;i&gt;, usually by passing unknown
1633 chunks to the replaced functions. In practice, it is feasible to
1634 control allocation for arenas created via <link
1635 linkend="arenas.extend"><mallctl>arenas.extend</mallctl></link> such
1636 that all chunks originate from an application-supplied chunk allocator
1637 (by setting custom chunk hook functions just after arena creation), but
1638 the automatically created arenas may have already created chunks prior
1639 to the application having an opportunity to take over chunk
1640 allocation.</para>
1641
Jason Evans92e96e32015-08-14 13:46:08 -07001642 <programlisting language="C"><![CDATA[
Jason Evansb49a3342015-07-28 11:28:19 -04001643typedef struct {
1644 chunk_alloc_t *alloc;
1645 chunk_dalloc_t *dalloc;
1646 chunk_commit_t *commit;
1647 chunk_decommit_t *decommit;
1648 chunk_purge_t *purge;
1649 chunk_split_t *split;
1650 chunk_merge_t *merge;
1651} chunk_hooks_t;]]></programlisting>
Jason Evans92e96e32015-08-14 13:46:08 -07001652 <para>The <type>chunk_hooks_t</type> structure comprises function
1653 pointers which are described individually below. jemalloc uses these
Jason Evansb49a3342015-07-28 11:28:19 -04001654 functions to manage chunk lifetime, which starts off with allocation of
1655 mapped committed memory, in the simplest case followed by deallocation.
1656 However, there are performance and platform reasons to retain chunks for
1657 later reuse. Cleanup attempts cascade from deallocation to decommit to
1658 purging, which gives the chunk management functions opportunities to
1659 reject the most permanent cleanup operations in favor of less permanent
1660 (and often less costly) operations. The chunk splitting and merging
1661 operations can also be opted out of, but this is mainly intended to
1662 support platforms on which virtual memory mappings provided by the
Jason Evans38f86492015-08-14 00:55:44 -07001663 operating system kernel do not automatically coalesce and split, e.g.
1664 Windows.</para>
Jason Evansb49a3342015-07-28 11:28:19 -04001665
Jason Evans92e96e32015-08-14 13:46:08 -07001666 <funcsynopsis><funcprototype>
aravindfb7fe502014-05-05 15:16:56 -07001667 <funcdef>typedef void *<function>(chunk_alloc_t)</function></funcdef>
Daniel Micaya95018e2014-10-04 01:39:32 -04001668 <paramdef>void *<parameter>chunk</parameter></paramdef>
aravindfb7fe502014-05-05 15:16:56 -07001669 <paramdef>size_t <parameter>size</parameter></paramdef>
1670 <paramdef>size_t <parameter>alignment</parameter></paramdef>
1671 <paramdef>bool *<parameter>zero</parameter></paramdef>
Jason Evans8fadb1a2015-08-04 10:49:46 -07001672 <paramdef>bool *<parameter>commit</parameter></paramdef>
aravindfb7fe502014-05-05 15:16:56 -07001673 <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
Jason Evans3c3b3b12014-10-05 14:48:44 -07001674 </funcprototype></funcsynopsis>
Jason Evans92e96e32015-08-14 13:46:08 -07001675 <literallayout></literallayout>
1676 <para>A chunk allocation function conforms to the
1677 <type>chunk_alloc_t</type> type and upon success returns a pointer to
1678 <parameter>size</parameter> bytes of mapped memory on behalf of arena
Jason Evansb49a3342015-07-28 11:28:19 -04001679 <parameter>arena_ind</parameter> such that the chunk's base address is a
1680 multiple of <parameter>alignment</parameter>, as well as setting
Jason Evans8fadb1a2015-08-04 10:49:46 -07001681 <parameter>*zero</parameter> to indicate whether the chunk is zeroed and
1682 <parameter>*commit</parameter> to indicate whether the chunk is
1683 committed. Upon error the function returns <constant>NULL</constant>
1684 and leaves <parameter>*zero</parameter> and
1685 <parameter>*commit</parameter> unmodified. The
aravindfb7fe502014-05-05 15:16:56 -07001686 <parameter>size</parameter> parameter is always a multiple of the chunk
1687 size. The <parameter>alignment</parameter> parameter is always a power
1688 of two at least as large as the chunk size. Zeroing is mandatory if
Jason Evans8fadb1a2015-08-04 10:49:46 -07001689 <parameter>*zero</parameter> is true upon function entry. Committing is
1690 mandatory if <parameter>*commit</parameter> is true upon function entry.
1691 If <parameter>chunk</parameter> is not <constant>NULL</constant>, the
Jason Evansb49a3342015-07-28 11:28:19 -04001692 returned pointer must be <parameter>chunk</parameter> on success or
1693 <constant>NULL</constant> on error. Committed memory may be committed
1694 in absolute terms as on a system that does not overcommit, or in
1695 implicit terms as on a system that overcommits and satisfies physical
1696 memory needs on demand via soft page faults. Note that replacing the
1697 default chunk allocation function makes the arena's <link
Jason Evanse2deab72014-05-15 22:22:27 -07001698 linkend="arena.i.dss"><mallctl>arena.&lt;i&gt;.dss</mallctl></link>
Jason Evansb49a3342015-07-28 11:28:19 -04001699 setting irrelevant.</para>
aravindfb7fe502014-05-05 15:16:56 -07001700
Jason Evans92e96e32015-08-14 13:46:08 -07001701 <funcsynopsis><funcprototype>
Jason Evans8d6a3e82015-03-18 18:55:33 -07001702 <funcdef>typedef bool <function>(chunk_dalloc_t)</function></funcdef>
aravindfb7fe502014-05-05 15:16:56 -07001703 <paramdef>void *<parameter>chunk</parameter></paramdef>
1704 <paramdef>size_t <parameter>size</parameter></paramdef>
Jason Evans8fadb1a2015-08-04 10:49:46 -07001705 <paramdef>bool <parameter>committed</parameter></paramdef>
aravindfb7fe502014-05-05 15:16:56 -07001706 <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
Jason Evans3c3b3b12014-10-05 14:48:44 -07001707 </funcprototype></funcsynopsis>
Jason Evans92e96e32015-08-14 13:46:08 -07001708 <literallayout></literallayout>
1709 <para>
aravindfb7fe502014-05-05 15:16:56 -07001710 A chunk deallocation function conforms to the
Jason Evanse2deab72014-05-15 22:22:27 -07001711 <type>chunk_dalloc_t</type> type and deallocates a
Jason Evans8fadb1a2015-08-04 10:49:46 -07001712 <parameter>chunk</parameter> of given <parameter>size</parameter> with
1713 <parameter>committed</parameter>/decommited memory as indicated, on
Jason Evans8d6a3e82015-03-18 18:55:33 -07001714 behalf of arena <parameter>arena_ind</parameter>, returning false upon
Jason Evansb49a3342015-07-28 11:28:19 -04001715 success. If the function returns true, this indicates opt-out from
1716 deallocation; the virtual memory mapping associated with the chunk
Jason Evans8fadb1a2015-08-04 10:49:46 -07001717 remains mapped, in the same commit state, and available for future use,
1718 in which case it will be automatically retained for later reuse.</para>
Jason Evans8d6a3e82015-03-18 18:55:33 -07001719
Jason Evans92e96e32015-08-14 13:46:08 -07001720 <funcsynopsis><funcprototype>
Jason Evansb49a3342015-07-28 11:28:19 -04001721 <funcdef>typedef bool <function>(chunk_commit_t)</function></funcdef>
1722 <paramdef>void *<parameter>chunk</parameter></paramdef>
1723 <paramdef>size_t <parameter>size</parameter></paramdef>
Jason Evans8fadb1a2015-08-04 10:49:46 -07001724 <paramdef>size_t <parameter>offset</parameter></paramdef>
1725 <paramdef>size_t <parameter>length</parameter></paramdef>
Jason Evansb49a3342015-07-28 11:28:19 -04001726 <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
1727 </funcprototype></funcsynopsis>
Jason Evans92e96e32015-08-14 13:46:08 -07001728 <literallayout></literallayout>
1729 <para>A chunk commit function conforms to the
1730 <type>chunk_commit_t</type> type and commits zeroed physical memory to
1731 back pages within a <parameter>chunk</parameter> of given
1732 <parameter>size</parameter> at <parameter>offset</parameter> bytes,
1733 extending for <parameter>length</parameter> on behalf of arena
Jason Evans8fadb1a2015-08-04 10:49:46 -07001734 <parameter>arena_ind</parameter>, returning false upon success.
1735 Committed memory may be committed in absolute terms as on a system that
1736 does not overcommit, or in implicit terms as on a system that
1737 overcommits and satisfies physical memory needs on demand via soft page
1738 faults. If the function returns true, this indicates insufficient
Jason Evansb49a3342015-07-28 11:28:19 -04001739 physical memory to satisfy the request.</para>
1740
Jason Evans92e96e32015-08-14 13:46:08 -07001741 <funcsynopsis><funcprototype>
Jason Evansb49a3342015-07-28 11:28:19 -04001742 <funcdef>typedef bool <function>(chunk_decommit_t)</function></funcdef>
1743 <paramdef>void *<parameter>chunk</parameter></paramdef>
1744 <paramdef>size_t <parameter>size</parameter></paramdef>
Jason Evans8fadb1a2015-08-04 10:49:46 -07001745 <paramdef>size_t <parameter>offset</parameter></paramdef>
1746 <paramdef>size_t <parameter>length</parameter></paramdef>
Jason Evansb49a3342015-07-28 11:28:19 -04001747 <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
1748 </funcprototype></funcsynopsis>
Jason Evans92e96e32015-08-14 13:46:08 -07001749 <literallayout></literallayout>
1750 <para>A chunk decommit function conforms to the
1751 <type>chunk_decommit_t</type> type and decommits any physical memory
1752 that is backing pages within a <parameter>chunk</parameter> of given
1753 <parameter>size</parameter> at <parameter>offset</parameter> bytes,
1754 extending for <parameter>length</parameter> on behalf of arena
Jason Evans8fadb1a2015-08-04 10:49:46 -07001755 <parameter>arena_ind</parameter>, returning false upon success, in which
1756 case the pages will be committed via the chunk commit function before
1757 being reused. If the function returns true, this indicates opt-out from
1758 decommit; the memory remains committed and available for future use, in
1759 which case it will be automatically retained for later reuse.</para>
Jason Evansb49a3342015-07-28 11:28:19 -04001760
Jason Evans92e96e32015-08-14 13:46:08 -07001761 <funcsynopsis><funcprototype>
Jason Evans8d6a3e82015-03-18 18:55:33 -07001762 <funcdef>typedef bool <function>(chunk_purge_t)</function></funcdef>
1763 <paramdef>void *<parameter>chunk</parameter></paramdef>
Jason Evansb49a3342015-07-28 11:28:19 -04001764 <paramdef>size_t<parameter>size</parameter></paramdef>
Jason Evans8d6a3e82015-03-18 18:55:33 -07001765 <paramdef>size_t <parameter>offset</parameter></paramdef>
1766 <paramdef>size_t <parameter>length</parameter></paramdef>
1767 <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
1768 </funcprototype></funcsynopsis>
Jason Evans92e96e32015-08-14 13:46:08 -07001769 <literallayout></literallayout>
1770 <para>A chunk purge function conforms to the <type>chunk_purge_t</type>
1771 type and optionally discards physical pages within the virtual memory
1772 mapping associated with <parameter>chunk</parameter> of given
Jason Evansb49a3342015-07-28 11:28:19 -04001773 <parameter>size</parameter> at <parameter>offset</parameter> bytes,
1774 extending for <parameter>length</parameter> on behalf of arena
Jason Evans8d6a3e82015-03-18 18:55:33 -07001775 <parameter>arena_ind</parameter>, returning false if pages within the
1776 purged virtual memory range will be zero-filled the next time they are
Jason Evansb49a3342015-07-28 11:28:19 -04001777 accessed.</para>
1778
Jason Evans92e96e32015-08-14 13:46:08 -07001779 <funcsynopsis><funcprototype>
Jason Evansb49a3342015-07-28 11:28:19 -04001780 <funcdef>typedef bool <function>(chunk_split_t)</function></funcdef>
1781 <paramdef>void *<parameter>chunk</parameter></paramdef>
1782 <paramdef>size_t <parameter>size</parameter></paramdef>
1783 <paramdef>size_t <parameter>size_a</parameter></paramdef>
1784 <paramdef>size_t <parameter>size_b</parameter></paramdef>
1785 <paramdef>bool <parameter>committed</parameter></paramdef>
1786 <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
1787 </funcprototype></funcsynopsis>
Jason Evans92e96e32015-08-14 13:46:08 -07001788 <literallayout></literallayout>
1789 <para>A chunk split function conforms to the <type>chunk_split_t</type>
1790 type and optionally splits <parameter>chunk</parameter> of given
Jason Evansb49a3342015-07-28 11:28:19 -04001791 <parameter>size</parameter> into two adjacent chunks, the first of
1792 <parameter>size_a</parameter> bytes, and the second of
1793 <parameter>size_b</parameter> bytes, operating on
1794 <parameter>committed</parameter>/decommitted memory as indicated, on
1795 behalf of arena <parameter>arena_ind</parameter>, returning false upon
1796 success. If the function returns true, this indicates that the chunk
1797 remains unsplit and therefore should continue to be operated on as a
1798 whole.</para>
1799
Jason Evans92e96e32015-08-14 13:46:08 -07001800 <funcsynopsis><funcprototype>
Jason Evansb49a3342015-07-28 11:28:19 -04001801 <funcdef>typedef bool <function>(chunk_merge_t)</function></funcdef>
1802 <paramdef>void *<parameter>chunk_a</parameter></paramdef>
1803 <paramdef>size_t <parameter>size_a</parameter></paramdef>
1804 <paramdef>void *<parameter>chunk_b</parameter></paramdef>
1805 <paramdef>size_t <parameter>size_b</parameter></paramdef>
1806 <paramdef>bool <parameter>committed</parameter></paramdef>
1807 <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
1808 </funcprototype></funcsynopsis>
Jason Evans92e96e32015-08-14 13:46:08 -07001809 <literallayout></literallayout>
1810 <para>A chunk merge function conforms to the <type>chunk_merge_t</type>
1811 type and optionally merges adjacent chunks,
1812 <parameter>chunk_a</parameter> of given <parameter>size_a</parameter>
1813 and <parameter>chunk_b</parameter> of given
1814 <parameter>size_b</parameter> into one contiguous chunk, operating on
1815 <parameter>committed</parameter>/decommitted memory as indicated, on
1816 behalf of arena <parameter>arena_ind</parameter>, returning false upon
1817 success. If the function returns true, this indicates that the chunks
1818 remain distinct mappings and therefore should continue to be operated on
1819 independently.</para>
Jason Evansb49a3342015-07-28 11:28:19 -04001820 </listitem>
aravindfb7fe502014-05-05 15:16:56 -07001821 </varlistentry>
1822
Jason Evansaee7fd22010-11-24 22:00:02 -08001823 <varlistentry id="arenas.narenas">
1824 <term>
1825 <mallctl>arenas.narenas</mallctl>
1826 (<type>unsigned</type>)
1827 <literal>r-</literal>
1828 </term>
Jason Evans609ae592012-10-11 13:53:15 -07001829 <listitem><para>Current limit on number of arenas.</para></listitem>
Jason Evansaee7fd22010-11-24 22:00:02 -08001830 </varlistentry>
1831
1832 <varlistentry id="arenas.initialized">
1833 <term>
1834 <mallctl>arenas.initialized</mallctl>
1835 (<type>bool *</type>)
1836 <literal>r-</literal>
1837 </term>
1838 <listitem><para>An array of <link
1839 linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link>
1840 booleans. Each boolean indicates whether the corresponding arena is
1841 initialized.</para></listitem>
1842 </varlistentry>
1843
Jason Evans8d6a3e82015-03-18 18:55:33 -07001844 <varlistentry id="arenas.lg_dirty_mult">
1845 <term>
1846 <mallctl>arenas.lg_dirty_mult</mallctl>
1847 (<type>ssize_t</type>)
1848 <literal>rw</literal>
1849 </term>
1850 <listitem><para>Current default per-arena minimum ratio (log base 2) of
1851 active to dirty pages, used to initialize <link
1852 linkend="arena.i.lg_dirty_mult"><mallctl>arena.&lt;i&gt;.lg_dirty_mult</mallctl></link>
1853 during arena creation. See <link
1854 linkend="opt.lg_dirty_mult"><mallctl>opt.lg_dirty_mult</mallctl></link>
1855 for additional information.</para></listitem>
1856 </varlistentry>
1857
Jason Evans243f7a02016-02-19 20:09:31 -08001858 <varlistentry id="arenas.decay_time">
1859 <term>
1860 <mallctl>arenas.decay_time</mallctl>
1861 (<type>ssize_t</type>)
1862 <literal>rw</literal>
1863 </term>
1864 <listitem><para>Current default per-arena approximate time in seconds
1865 from the creation of a set of unused dirty pages until an equivalent set
1866 of unused dirty pages is purged and/or reused, used to initialize <link
1867 linkend="arena.i.decay_time"><mallctl>arena.&lt;i&gt;.decay_time</mallctl></link>
1868 during arena creation. See <link
1869 linkend="opt.decay_time"><mallctl>opt.decay_time</mallctl></link> for
1870 additional information.</para></listitem>
1871 </varlistentry>
1872
Jason Evansaabaf852013-10-30 14:52:09 -07001873 <varlistentry id="arenas.quantum">
Jason Evansaee7fd22010-11-24 22:00:02 -08001874 <term>
1875 <mallctl>arenas.quantum</mallctl>
1876 (<type>size_t</type>)
1877 <literal>r-</literal>
1878 </term>
1879 <listitem><para>Quantum size.</para></listitem>
1880 </varlistentry>
1881
Jason Evansaabaf852013-10-30 14:52:09 -07001882 <varlistentry id="arenas.page">
Jason Evansaee7fd22010-11-24 22:00:02 -08001883 <term>
Jason Evansae4c7b42012-04-02 07:04:34 -07001884 <mallctl>arenas.page</mallctl>
Jason Evansaee7fd22010-11-24 22:00:02 -08001885 (<type>size_t</type>)
1886 <literal>r-</literal>
1887 </term>
1888 <listitem><para>Page size.</para></listitem>
1889 </varlistentry>
1890
Jason Evansaabaf852013-10-30 14:52:09 -07001891 <varlistentry id="arenas.tcache_max">
Jason Evansaee7fd22010-11-24 22:00:02 -08001892 <term>
Jason Evansaee7fd22010-11-24 22:00:02 -08001893 <mallctl>arenas.tcache_max</mallctl>
1894 (<type>size_t</type>)
1895 <literal>r-</literal>
1896 [<option>--enable-tcache</option>]
1897 </term>
1898 <listitem><para>Maximum thread-cached size class.</para></listitem>
1899 </varlistentry>
1900
Jason Evansaabaf852013-10-30 14:52:09 -07001901 <varlistentry id="arenas.nbins">
Jason Evansaee7fd22010-11-24 22:00:02 -08001902 <term>
Jason Evansaee7fd22010-11-24 22:00:02 -08001903 <mallctl>arenas.nbins</mallctl>
1904 (<type>unsigned</type>)
1905 <literal>r-</literal>
1906 </term>
Jason Evansb1726102012-02-28 16:50:47 -08001907 <listitem><para>Number of bin size classes.</para></listitem>
Jason Evansaee7fd22010-11-24 22:00:02 -08001908 </varlistentry>
1909
Jason Evansaabaf852013-10-30 14:52:09 -07001910 <varlistentry id="arenas.nhbins">
Jason Evansaee7fd22010-11-24 22:00:02 -08001911 <term>
1912 <mallctl>arenas.nhbins</mallctl>
1913 (<type>unsigned</type>)
1914 <literal>r-</literal>
1915 [<option>--enable-tcache</option>]
1916 </term>
1917 <listitem><para>Total number of thread cache bin size
1918 classes.</para></listitem>
1919 </varlistentry>
1920
1921 <varlistentry id="arenas.bin.i.size">
1922 <term>
1923 <mallctl>arenas.bin.&lt;i&gt;.size</mallctl>
1924 (<type>size_t</type>)
1925 <literal>r-</literal>
1926 </term>
1927 <listitem><para>Maximum size supported by size class.</para></listitem>
1928 </varlistentry>
1929
Jason Evansaabaf852013-10-30 14:52:09 -07001930 <varlistentry id="arenas.bin.i.nregs">
Jason Evansaee7fd22010-11-24 22:00:02 -08001931 <term>
1932 <mallctl>arenas.bin.&lt;i&gt;.nregs</mallctl>
1933 (<type>uint32_t</type>)
1934 <literal>r-</literal>
1935 </term>
1936 <listitem><para>Number of regions per page run.</para></listitem>
1937 </varlistentry>
1938
Jason Evansaabaf852013-10-30 14:52:09 -07001939 <varlistentry id="arenas.bin.i.run_size">
Jason Evansaee7fd22010-11-24 22:00:02 -08001940 <term>
1941 <mallctl>arenas.bin.&lt;i&gt;.run_size</mallctl>
1942 (<type>size_t</type>)
1943 <literal>r-</literal>
1944 </term>
1945 <listitem><para>Number of bytes per page run.</para></listitem>
1946 </varlistentry>
1947
Jason Evansaabaf852013-10-30 14:52:09 -07001948 <varlistentry id="arenas.nlruns">
Jason Evansaee7fd22010-11-24 22:00:02 -08001949 <term>
1950 <mallctl>arenas.nlruns</mallctl>
Jason Evans3c4d92e2014-10-12 22:53:59 -07001951 (<type>unsigned</type>)
Jason Evansaee7fd22010-11-24 22:00:02 -08001952 <literal>r-</literal>
1953 </term>
1954 <listitem><para>Total number of large size classes.</para></listitem>
1955 </varlistentry>
1956
Jason Evansaabaf852013-10-30 14:52:09 -07001957 <varlistentry id="arenas.lrun.i.size">
Jason Evansaee7fd22010-11-24 22:00:02 -08001958 <term>
1959 <mallctl>arenas.lrun.&lt;i&gt;.size</mallctl>
1960 (<type>size_t</type>)
1961 <literal>r-</literal>
1962 </term>
1963 <listitem><para>Maximum size supported by this large size
1964 class.</para></listitem>
1965 </varlistentry>
1966
Jason Evans3c4d92e2014-10-12 22:53:59 -07001967 <varlistentry id="arenas.nhchunks">
1968 <term>
1969 <mallctl>arenas.nhchunks</mallctl>
1970 (<type>unsigned</type>)
1971 <literal>r-</literal>
1972 </term>
1973 <listitem><para>Total number of huge size classes.</para></listitem>
1974 </varlistentry>
1975
Qinfan Wu89750352015-04-21 16:57:42 -07001976 <varlistentry id="arenas.hchunk.i.size">
Jason Evans3c4d92e2014-10-12 22:53:59 -07001977 <term>
Qinfan Wu89750352015-04-21 16:57:42 -07001978 <mallctl>arenas.hchunk.&lt;i&gt;.size</mallctl>
Jason Evans3c4d92e2014-10-12 22:53:59 -07001979 (<type>size_t</type>)
1980 <literal>r-</literal>
1981 </term>
1982 <listitem><para>Maximum size supported by this huge size
1983 class.</para></listitem>
1984 </varlistentry>
1985
Jason Evansaabaf852013-10-30 14:52:09 -07001986 <varlistentry id="arenas.extend">
Jason Evans609ae592012-10-11 13:53:15 -07001987 <term>
1988 <mallctl>arenas.extend</mallctl>
1989 (<type>unsigned</type>)
1990 <literal>r-</literal>
1991 </term>
1992 <listitem><para>Extend the array of arenas by appending a new arena,
1993 and returning the new arena index.</para></listitem>
1994 </varlistentry>
1995
Jason Evansfc12c0b2014-10-03 23:25:30 -07001996 <varlistentry id="prof.thread_active_init">
1997 <term>
1998 <mallctl>prof.thread_active_init</mallctl>
1999 (<type>bool</type>)
2000 <literal>rw</literal>
2001 [<option>--enable-prof</option>]
2002 </term>
2003 <listitem><para>Control the initial setting for <link
2004 linkend="thread.prof.active"><mallctl>thread.prof.active</mallctl></link>
2005 in newly created threads. See the <link
2006 linkend="opt.prof_thread_active_init"><mallctl>opt.prof_thread_active_init</mallctl></link>
2007 option for additional information.</para></listitem>
2008 </varlistentry>
2009
Jason Evansaee7fd22010-11-24 22:00:02 -08002010 <varlistentry id="prof.active">
2011 <term>
2012 <mallctl>prof.active</mallctl>
2013 (<type>bool</type>)
2014 <literal>rw</literal>
2015 [<option>--enable-prof</option>]
2016 </term>
2017 <listitem><para>Control whether sampling is currently active. See the
2018 <link
2019 linkend="opt.prof_active"><mallctl>opt.prof_active</mallctl></link>
Jason Evansfc12c0b2014-10-03 23:25:30 -07002020 option for additional information, as well as the interrelated <link
2021 linkend="thread.prof.active"><mallctl>thread.prof.active</mallctl></link>
2022 mallctl.</para></listitem>
Jason Evansaee7fd22010-11-24 22:00:02 -08002023 </varlistentry>
2024
Jason Evansaabaf852013-10-30 14:52:09 -07002025 <varlistentry id="prof.dump">
Jason Evansaee7fd22010-11-24 22:00:02 -08002026 <term>
2027 <mallctl>prof.dump</mallctl>
2028 (<type>const char *</type>)
2029 <literal>-w</literal>
2030 [<option>--enable-prof</option>]
2031 </term>
2032 <listitem><para>Dump a memory profile to the specified file, or if NULL
2033 is specified, to a file according to the pattern
2034 <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.m&lt;mseq&gt;.heap</filename>,
2035 where <literal>&lt;prefix&gt;</literal> is controlled by the
2036 <link
2037 linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
2038 option.</para></listitem>
2039 </varlistentry>
2040
Jason Evans5b8ed5b2015-01-25 21:16:57 -08002041 <varlistentry id="prof.gdump">
2042 <term>
2043 <mallctl>prof.gdump</mallctl>
2044 (<type>bool</type>)
2045 <literal>rw</literal>
2046 [<option>--enable-prof</option>]
2047 </term>
2048 <listitem><para>When enabled, trigger a memory profile dump every time
2049 the total virtual memory exceeds the previous maximum. Profiles are
2050 dumped to files named according to the pattern
2051 <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.u&lt;useq&gt;.heap</filename>,
2052 where <literal>&lt;prefix&gt;</literal> is controlled by the <link
2053 linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
2054 option.</para></listitem>
2055 </varlistentry>
2056
Jason Evans602c8e02014-08-18 16:22:13 -07002057 <varlistentry id="prof.reset">
2058 <term>
2059 <mallctl>prof.reset</mallctl>
2060 (<type>size_t</type>)
2061 <literal>-w</literal>
2062 [<option>--enable-prof</option>]
2063 </term>
2064 <listitem><para>Reset all memory profile statistics, and optionally
2065 update the sample rate (see <link
Jason Evans20c31de2014-10-02 23:01:10 -07002066 linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link>
Jason Evansfc12c0b2014-10-03 23:25:30 -07002067 and <link
2068 linkend="prof.lg_sample"><mallctl>prof.lg_sample</mallctl></link>).
Jason Evans602c8e02014-08-18 16:22:13 -07002069 </para></listitem>
2070 </varlistentry>
2071
2072 <varlistentry id="prof.lg_sample">
2073 <term>
2074 <mallctl>prof.lg_sample</mallctl>
2075 (<type>size_t</type>)
2076 <literal>r-</literal>
2077 [<option>--enable-prof</option>]
2078 </term>
Jason Evans20c31de2014-10-02 23:01:10 -07002079 <listitem><para>Get the current sample rate (see <link
Jason Evans602c8e02014-08-18 16:22:13 -07002080 linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link>).
2081 </para></listitem>
2082 </varlistentry>
2083
Jason Evansaabaf852013-10-30 14:52:09 -07002084 <varlistentry id="prof.interval">
Jason Evansaee7fd22010-11-24 22:00:02 -08002085 <term>
2086 <mallctl>prof.interval</mallctl>
2087 (<type>uint64_t</type>)
2088 <literal>r-</literal>
2089 [<option>--enable-prof</option>]
2090 </term>
2091 <listitem><para>Average number of bytes allocated between
hitstergtdeb688422016-04-18 11:08:39 +01002092 interval-based profile dumps. See the
Jason Evansaee7fd22010-11-24 22:00:02 -08002093 <link
2094 linkend="opt.lg_prof_interval"><mallctl>opt.lg_prof_interval</mallctl></link>
2095 option for additional information.</para></listitem>
2096 </varlistentry>
2097
Jason Evans0657f122011-03-18 17:56:14 -07002098 <varlistentry id="stats.cactive">
2099 <term>
2100 <mallctl>stats.cactive</mallctl>
2101 (<type>size_t *</type>)
2102 <literal>r-</literal>
2103 [<option>--enable-stats</option>]
2104 </term>
2105 <listitem><para>Pointer to a counter that contains an approximate count
2106 of the current number of bytes in active pages. The estimate may be
Jason Evans9b41ac92014-10-14 22:20:00 -07002107 high, but never low, because each arena rounds up when computing its
2108 contribution to the counter. Note that the <link
Jason Evans0657f122011-03-18 17:56:14 -07002109 linkend="epoch"><mallctl>epoch</mallctl></link> mallctl has no bearing
2110 on this counter. Furthermore, counter consistency is maintained via
2111 atomic operations, so it is necessary to use an atomic operation in
2112 order to guarantee a consistent read when dereferencing the pointer.
2113 </para></listitem>
2114 </varlistentry>
2115
Jason Evansaee7fd22010-11-24 22:00:02 -08002116 <varlistentry id="stats.allocated">
2117 <term>
2118 <mallctl>stats.allocated</mallctl>
2119 (<type>size_t</type>)
2120 <literal>r-</literal>
2121 [<option>--enable-stats</option>]
2122 </term>
2123 <listitem><para>Total number of bytes allocated by the
2124 application.</para></listitem>
2125 </varlistentry>
2126
2127 <varlistentry id="stats.active">
2128 <term>
2129 <mallctl>stats.active</mallctl>
2130 (<type>size_t</type>)
2131 <literal>r-</literal>
2132 [<option>--enable-stats</option>]
2133 </term>
2134 <listitem><para>Total number of bytes in active pages allocated by the
2135 application. This is a multiple of the page size, and greater than or
2136 equal to <link
2137 linkend="stats.allocated"><mallctl>stats.allocated</mallctl></link>.
Jan Beiched90c972012-10-18 00:06:32 +04002138 This does not include <link linkend="stats.arenas.i.pdirty">
Jason Evanscbf3a6d2015-02-11 12:24:27 -08002139 <mallctl>stats.arenas.&lt;i&gt;.pdirty</mallctl></link>, nor pages
Jan Beiched90c972012-10-18 00:06:32 +04002140 entirely devoted to allocator metadata.</para></listitem>
Jason Evansaee7fd22010-11-24 22:00:02 -08002141 </varlistentry>
2142
Jason Evans4581b972014-11-27 17:22:36 -02002143 <varlistentry id="stats.metadata">
2144 <term>
2145 <mallctl>stats.metadata</mallctl>
2146 (<type>size_t</type>)
2147 <literal>r-</literal>
2148 [<option>--enable-stats</option>]
2149 </term>
2150 <listitem><para>Total number of bytes dedicated to metadata, which
2151 comprise base allocations used for bootstrap-sensitive internal
2152 allocator data structures, arena chunk headers (see <link
2153 linkend="stats.arenas.i.metadata.mapped"><mallctl>stats.arenas.&lt;i&gt;.metadata.mapped</mallctl></link>),
2154 and internal allocations (see <link
2155 linkend="stats.arenas.i.metadata.allocated"><mallctl>stats.arenas.&lt;i&gt;.metadata.allocated</mallctl></link>).</para></listitem>
2156 </varlistentry>
2157
Jason Evans4acd75a2015-03-23 17:25:57 -07002158 <varlistentry id="stats.resident">
2159 <term>
2160 <mallctl>stats.resident</mallctl>
2161 (<type>size_t</type>)
2162 <literal>r-</literal>
2163 [<option>--enable-stats</option>]
2164 </term>
2165 <listitem><para>Maximum number of bytes in physically resident data
2166 pages mapped by the allocator, comprising all pages dedicated to
2167 allocator metadata, pages backing active allocations, and unused dirty
2168 pages. This is a maximum rather than precise because pages may not
2169 actually be physically resident if they correspond to demand-zeroed
2170 virtual memory that has not yet been touched. This is a multiple of the
2171 page size, and is larger than <link
2172 linkend="stats.active"><mallctl>stats.active</mallctl></link>.</para></listitem>
2173 </varlistentry>
2174
Jason Evansaabaf852013-10-30 14:52:09 -07002175 <varlistentry id="stats.mapped">
Jason Evansaee7fd22010-11-24 22:00:02 -08002176 <term>
2177 <mallctl>stats.mapped</mallctl>
2178 (<type>size_t</type>)
2179 <literal>r-</literal>
2180 [<option>--enable-stats</option>]
2181 </term>
Jason Evans4acd75a2015-03-23 17:25:57 -07002182 <listitem><para>Total number of bytes in active chunks mapped by the
Jason Evans56048ba2015-05-28 15:03:58 -07002183 allocator. This is a multiple of the chunk size, and is larger than
2184 <link linkend="stats.active"><mallctl>stats.active</mallctl></link>.
2185 This does not include inactive chunks, even those that contain unused
2186 dirty pages, which means that there is no strict ordering between this
2187 and <link
2188 linkend="stats.resident"><mallctl>stats.resident</mallctl></link>.</para></listitem>
Jason Evansaee7fd22010-11-24 22:00:02 -08002189 </varlistentry>
2190
Jason Evans04c3c0f2016-05-03 22:11:35 -07002191 <varlistentry id="stats.retained">
2192 <term>
2193 <mallctl>stats.retained</mallctl>
2194 (<type>size_t</type>)
2195 <literal>r-</literal>
2196 [<option>--enable-stats</option>]
2197 </term>
2198 <listitem><para>Total number of bytes in virtual memory mappings that
2199 were retained rather than being returned to the operating system via
2200 e.g. <citerefentry><refentrytitle>munmap</refentrytitle>
2201 <manvolnum>2</manvolnum></citerefentry>. Retained virtual memory is
2202 typically untouched, decommitted, or purged, so it has no strongly
2203 associated physical memory (see <link
2204 linkend="arena.i.chunk_hooks">chunk hooks</link> for details). Retained
2205 memory is excluded from mapped memory statistics, e.g. <link
2206 linkend="stats.mapped"><mallctl>stats.mapped</mallctl></link>.
2207 </para></listitem>
2208 </varlistentry>
2209
Jason Evansaabaf852013-10-30 14:52:09 -07002210 <varlistentry id="stats.arenas.i.dss">
Jason Evansaee7fd22010-11-24 22:00:02 -08002211 <term>
Jason Evans609ae592012-10-11 13:53:15 -07002212 <mallctl>stats.arenas.&lt;i&gt;.dss</mallctl>
2213 (<type>const char *</type>)
2214 <literal>r-</literal>
2215 </term>
2216 <listitem><para>dss (<citerefentry><refentrytitle>sbrk</refentrytitle>
2217 <manvolnum>2</manvolnum></citerefentry>) allocation precedence as
2218 related to <citerefentry><refentrytitle>mmap</refentrytitle>
2219 <manvolnum>2</manvolnum></citerefentry> allocation. See <link
2220 linkend="opt.dss"><mallctl>opt.dss</mallctl></link> for details.
2221 </para></listitem>
2222 </varlistentry>
2223
Jason Evans562d2662015-03-24 16:36:12 -07002224 <varlistentry id="stats.arenas.i.lg_dirty_mult">
2225 <term>
2226 <mallctl>stats.arenas.&lt;i&gt;.lg_dirty_mult</mallctl>
2227 (<type>ssize_t</type>)
2228 <literal>r-</literal>
2229 </term>
2230 <listitem><para>Minimum ratio (log base 2) of active to dirty pages.
2231 See <link
2232 linkend="opt.lg_dirty_mult"><mallctl>opt.lg_dirty_mult</mallctl></link>
2233 for details.</para></listitem>
2234 </varlistentry>
2235
Jason Evans243f7a02016-02-19 20:09:31 -08002236 <varlistentry id="stats.arenas.i.decay_time">
2237 <term>
2238 <mallctl>stats.arenas.&lt;i&gt;.decay_time</mallctl>
2239 (<type>ssize_t</type>)
2240 <literal>r-</literal>
2241 </term>
2242 <listitem><para>Approximate time in seconds from the creation of a set
2243 of unused dirty pages until an equivalent set of unused dirty pages is
2244 purged and/or reused. See <link
2245 linkend="opt.decay_time"><mallctl>opt.decay_time</mallctl></link>
2246 for details.</para></listitem>
2247 </varlistentry>
2248
Jason Evansaabaf852013-10-30 14:52:09 -07002249 <varlistentry id="stats.arenas.i.nthreads">
Jason Evans609ae592012-10-11 13:53:15 -07002250 <term>
Jason Evans597632b2011-03-18 13:41:33 -07002251 <mallctl>stats.arenas.&lt;i&gt;.nthreads</mallctl>
2252 (<type>unsigned</type>)
2253 <literal>r-</literal>
2254 </term>
2255 <listitem><para>Number of threads currently assigned to
2256 arena.</para></listitem>
2257 </varlistentry>
2258
Jason Evansaabaf852013-10-30 14:52:09 -07002259 <varlistentry id="stats.arenas.i.pactive">
Jason Evans597632b2011-03-18 13:41:33 -07002260 <term>
Jason Evansaee7fd22010-11-24 22:00:02 -08002261 <mallctl>stats.arenas.&lt;i&gt;.pactive</mallctl>
2262 (<type>size_t</type>)
2263 <literal>r-</literal>
2264 </term>
2265 <listitem><para>Number of pages in active runs.</para></listitem>
2266 </varlistentry>
2267
Jan Beiched90c972012-10-18 00:06:32 +04002268 <varlistentry id="stats.arenas.i.pdirty">
Jason Evansaee7fd22010-11-24 22:00:02 -08002269 <term>
2270 <mallctl>stats.arenas.&lt;i&gt;.pdirty</mallctl>
2271 (<type>size_t</type>)
2272 <literal>r-</literal>
2273 </term>
2274 <listitem><para>Number of pages within unused runs that are potentially
2275 dirty, and for which <function>madvise<parameter>...</parameter>
2276 <parameter><constant>MADV_DONTNEED</constant></parameter></function> or
2277 similar has not been called.</para></listitem>
2278 </varlistentry>
2279
Jason Evansaabaf852013-10-30 14:52:09 -07002280 <varlistentry id="stats.arenas.i.mapped">
Jason Evansaee7fd22010-11-24 22:00:02 -08002281 <term>
2282 <mallctl>stats.arenas.&lt;i&gt;.mapped</mallctl>
2283 (<type>size_t</type>)
2284 <literal>r-</literal>
2285 [<option>--enable-stats</option>]
2286 </term>
2287 <listitem><para>Number of mapped bytes.</para></listitem>
2288 </varlistentry>
2289
Jason Evans04c3c0f2016-05-03 22:11:35 -07002290 <varlistentry id="stats.arenas.i.retained">
2291 <term>
2292 <mallctl>stats.arenas.&lt;i&gt;.retained</mallctl>
2293 (<type>size_t</type>)
2294 <literal>r-</literal>
2295 [<option>--enable-stats</option>]
2296 </term>
2297 <listitem><para>Number of retained bytes. See <link
2298 linkend="stats.retained"><mallctl>stats.retained</mallctl></link> for
2299 details.</para></listitem>
2300 </varlistentry>
2301
Jason Evans4581b972014-11-27 17:22:36 -02002302 <varlistentry id="stats.arenas.i.metadata.mapped">
2303 <term>
2304 <mallctl>stats.arenas.&lt;i&gt;.metadata.mapped</mallctl>
2305 (<type>size_t</type>)
2306 <literal>r-</literal>
2307 [<option>--enable-stats</option>]
2308 </term>
2309 <listitem><para>Number of mapped bytes in arena chunk headers, which
2310 track the states of the non-metadata pages.</para></listitem>
2311 </varlistentry>
2312
2313 <varlistentry id="stats.arenas.i.metadata.allocated">
2314 <term>
2315 <mallctl>stats.arenas.&lt;i&gt;.metadata.allocated</mallctl>
2316 (<type>size_t</type>)
2317 <literal>r-</literal>
2318 [<option>--enable-stats</option>]
2319 </term>
2320 <listitem><para>Number of bytes dedicated to internal allocations.
2321 Internal allocations differ from application-originated allocations in
2322 that they are for internal use, and that they are omitted from heap
2323 profiles. This statistic is reported separately from <link
2324 linkend="stats.metadata"><mallctl>stats.metadata</mallctl></link> and
2325 <link
2326 linkend="stats.arenas.i.metadata.mapped"><mallctl>stats.arenas.&lt;i&gt;.metadata.mapped</mallctl></link>
2327 because it overlaps with e.g. the <link
2328 linkend="stats.allocated"><mallctl>stats.allocated</mallctl></link> and
2329 <link linkend="stats.active"><mallctl>stats.active</mallctl></link>
2330 statistics, whereas the other metadata statistics do
2331 not.</para></listitem>
2332 </varlistentry>
2333
Jason Evansaabaf852013-10-30 14:52:09 -07002334 <varlistentry id="stats.arenas.i.npurge">
Jason Evansaee7fd22010-11-24 22:00:02 -08002335 <term>
2336 <mallctl>stats.arenas.&lt;i&gt;.npurge</mallctl>
2337 (<type>uint64_t</type>)
2338 <literal>r-</literal>
2339 [<option>--enable-stats</option>]
2340 </term>
2341 <listitem><para>Number of dirty page purge sweeps performed.
2342 </para></listitem>
2343 </varlistentry>
2344
Jason Evansaabaf852013-10-30 14:52:09 -07002345 <varlistentry id="stats.arenas.i.nmadvise">
Jason Evansaee7fd22010-11-24 22:00:02 -08002346 <term>
2347 <mallctl>stats.arenas.&lt;i&gt;.nmadvise</mallctl>
2348 (<type>uint64_t</type>)
2349 <literal>r-</literal>
2350 [<option>--enable-stats</option>]
2351 </term>
2352 <listitem><para>Number of <function>madvise<parameter>...</parameter>
2353 <parameter><constant>MADV_DONTNEED</constant></parameter></function> or
2354 similar calls made to purge dirty pages.</para></listitem>
2355 </varlistentry>
2356
Jason Evansd8a39002013-12-19 21:40:41 -08002357 <varlistentry id="stats.arenas.i.purged">
Jason Evansaee7fd22010-11-24 22:00:02 -08002358 <term>
Jason Evansd8a39002013-12-19 21:40:41 -08002359 <mallctl>stats.arenas.&lt;i&gt;.purged</mallctl>
Jason Evansaee7fd22010-11-24 22:00:02 -08002360 (<type>uint64_t</type>)
2361 <literal>r-</literal>
2362 [<option>--enable-stats</option>]
2363 </term>
2364 <listitem><para>Number of pages purged.</para></listitem>
2365 </varlistentry>
2366
Jason Evansaabaf852013-10-30 14:52:09 -07002367 <varlistentry id="stats.arenas.i.small.allocated">
Jason Evansaee7fd22010-11-24 22:00:02 -08002368 <term>
2369 <mallctl>stats.arenas.&lt;i&gt;.small.allocated</mallctl>
2370 (<type>size_t</type>)
2371 <literal>r-</literal>
2372 [<option>--enable-stats</option>]
2373 </term>
2374 <listitem><para>Number of bytes currently allocated by small objects.
2375 </para></listitem>
2376 </varlistentry>
2377
Jason Evansaabaf852013-10-30 14:52:09 -07002378 <varlistentry id="stats.arenas.i.small.nmalloc">
Jason Evansaee7fd22010-11-24 22:00:02 -08002379 <term>
2380 <mallctl>stats.arenas.&lt;i&gt;.small.nmalloc</mallctl>
2381 (<type>uint64_t</type>)
2382 <literal>r-</literal>
2383 [<option>--enable-stats</option>]
2384 </term>
2385 <listitem><para>Cumulative number of allocation requests served by
2386 small bins.</para></listitem>
2387 </varlistentry>
2388
Jason Evansaabaf852013-10-30 14:52:09 -07002389 <varlistentry id="stats.arenas.i.small.ndalloc">
Jason Evansaee7fd22010-11-24 22:00:02 -08002390 <term>
2391 <mallctl>stats.arenas.&lt;i&gt;.small.ndalloc</mallctl>
2392 (<type>uint64_t</type>)
2393 <literal>r-</literal>
2394 [<option>--enable-stats</option>]
2395 </term>
2396 <listitem><para>Cumulative number of small objects returned to bins.
2397 </para></listitem>
2398 </varlistentry>
2399
Jason Evansaabaf852013-10-30 14:52:09 -07002400 <varlistentry id="stats.arenas.i.small.nrequests">
Jason Evansaee7fd22010-11-24 22:00:02 -08002401 <term>
2402 <mallctl>stats.arenas.&lt;i&gt;.small.nrequests</mallctl>
2403 (<type>uint64_t</type>)
2404 <literal>r-</literal>
2405 [<option>--enable-stats</option>]
2406 </term>
2407 <listitem><para>Cumulative number of small allocation requests.
2408 </para></listitem>
2409 </varlistentry>
2410
Jason Evansaabaf852013-10-30 14:52:09 -07002411 <varlistentry id="stats.arenas.i.large.allocated">
Jason Evansaee7fd22010-11-24 22:00:02 -08002412 <term>
2413 <mallctl>stats.arenas.&lt;i&gt;.large.allocated</mallctl>
2414 (<type>size_t</type>)
2415 <literal>r-</literal>
2416 [<option>--enable-stats</option>]
2417 </term>
2418 <listitem><para>Number of bytes currently allocated by large objects.
2419 </para></listitem>
2420 </varlistentry>
2421
Jason Evansaabaf852013-10-30 14:52:09 -07002422 <varlistentry id="stats.arenas.i.large.nmalloc">
Jason Evansaee7fd22010-11-24 22:00:02 -08002423 <term>
2424 <mallctl>stats.arenas.&lt;i&gt;.large.nmalloc</mallctl>
2425 (<type>uint64_t</type>)
2426 <literal>r-</literal>
2427 [<option>--enable-stats</option>]
2428 </term>
2429 <listitem><para>Cumulative number of large allocation requests served
2430 directly by the arena.</para></listitem>
2431 </varlistentry>
2432
Jason Evansaabaf852013-10-30 14:52:09 -07002433 <varlistentry id="stats.arenas.i.large.ndalloc">
Jason Evansaee7fd22010-11-24 22:00:02 -08002434 <term>
2435 <mallctl>stats.arenas.&lt;i&gt;.large.ndalloc</mallctl>
2436 (<type>uint64_t</type>)
2437 <literal>r-</literal>
2438 [<option>--enable-stats</option>]
2439 </term>
2440 <listitem><para>Cumulative number of large deallocation requests served
2441 directly by the arena.</para></listitem>
2442 </varlistentry>
2443
Jason Evansaabaf852013-10-30 14:52:09 -07002444 <varlistentry id="stats.arenas.i.large.nrequests">
Jason Evansaee7fd22010-11-24 22:00:02 -08002445 <term>
2446 <mallctl>stats.arenas.&lt;i&gt;.large.nrequests</mallctl>
2447 (<type>uint64_t</type>)
2448 <literal>r-</literal>
2449 [<option>--enable-stats</option>]
2450 </term>
2451 <listitem><para>Cumulative number of large allocation requests.
2452 </para></listitem>
2453 </varlistentry>
2454
Jason Evanse2deab72014-05-15 22:22:27 -07002455 <varlistentry id="stats.arenas.i.huge.allocated">
2456 <term>
2457 <mallctl>stats.arenas.&lt;i&gt;.huge.allocated</mallctl>
2458 (<type>size_t</type>)
2459 <literal>r-</literal>
2460 [<option>--enable-stats</option>]
2461 </term>
2462 <listitem><para>Number of bytes currently allocated by huge objects.
2463 </para></listitem>
2464 </varlistentry>
2465
2466 <varlistentry id="stats.arenas.i.huge.nmalloc">
2467 <term>
2468 <mallctl>stats.arenas.&lt;i&gt;.huge.nmalloc</mallctl>
2469 (<type>uint64_t</type>)
2470 <literal>r-</literal>
2471 [<option>--enable-stats</option>]
2472 </term>
2473 <listitem><para>Cumulative number of huge allocation requests served
2474 directly by the arena.</para></listitem>
2475 </varlistentry>
2476
2477 <varlistentry id="stats.arenas.i.huge.ndalloc">
2478 <term>
2479 <mallctl>stats.arenas.&lt;i&gt;.huge.ndalloc</mallctl>
2480 (<type>uint64_t</type>)
2481 <literal>r-</literal>
2482 [<option>--enable-stats</option>]
2483 </term>
2484 <listitem><para>Cumulative number of huge deallocation requests served
2485 directly by the arena.</para></listitem>
2486 </varlistentry>
2487
2488 <varlistentry id="stats.arenas.i.huge.nrequests">
2489 <term>
2490 <mallctl>stats.arenas.&lt;i&gt;.huge.nrequests</mallctl>
2491 (<type>uint64_t</type>)
2492 <literal>r-</literal>
2493 [<option>--enable-stats</option>]
2494 </term>
2495 <listitem><para>Cumulative number of huge allocation requests.
2496 </para></listitem>
2497 </varlistentry>
2498
Jason Evansaabaf852013-10-30 14:52:09 -07002499 <varlistentry id="stats.arenas.i.bins.j.nmalloc">
Jason Evansaee7fd22010-11-24 22:00:02 -08002500 <term>
2501 <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nmalloc</mallctl>
2502 (<type>uint64_t</type>)
2503 <literal>r-</literal>
2504 [<option>--enable-stats</option>]
2505 </term>
2506 <listitem><para>Cumulative number of allocations served by bin.
2507 </para></listitem>
2508 </varlistentry>
2509
Jason Evansaabaf852013-10-30 14:52:09 -07002510 <varlistentry id="stats.arenas.i.bins.j.ndalloc">
Jason Evansaee7fd22010-11-24 22:00:02 -08002511 <term>
2512 <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.ndalloc</mallctl>
2513 (<type>uint64_t</type>)
2514 <literal>r-</literal>
2515 [<option>--enable-stats</option>]
2516 </term>
2517 <listitem><para>Cumulative number of allocations returned to bin.
2518 </para></listitem>
2519 </varlistentry>
2520
Jason Evansaabaf852013-10-30 14:52:09 -07002521 <varlistentry id="stats.arenas.i.bins.j.nrequests">
Jason Evansaee7fd22010-11-24 22:00:02 -08002522 <term>
2523 <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nrequests</mallctl>
2524 (<type>uint64_t</type>)
2525 <literal>r-</literal>
2526 [<option>--enable-stats</option>]
2527 </term>
2528 <listitem><para>Cumulative number of allocation
2529 requests.</para></listitem>
2530 </varlistentry>
2531
Jason Evans3c4d92e2014-10-12 22:53:59 -07002532 <varlistentry id="stats.arenas.i.bins.j.curregs">
2533 <term>
2534 <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.curregs</mallctl>
2535 (<type>size_t</type>)
2536 <literal>r-</literal>
2537 [<option>--enable-stats</option>]
2538 </term>
2539 <listitem><para>Current number of regions for this size
2540 class.</para></listitem>
2541 </varlistentry>
2542
Jason Evansaabaf852013-10-30 14:52:09 -07002543 <varlistentry id="stats.arenas.i.bins.j.nfills">
Jason Evansaee7fd22010-11-24 22:00:02 -08002544 <term>
2545 <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nfills</mallctl>
2546 (<type>uint64_t</type>)
2547 <literal>r-</literal>
2548 [<option>--enable-stats</option> <option>--enable-tcache</option>]
2549 </term>
2550 <listitem><para>Cumulative number of tcache fills.</para></listitem>
2551 </varlistentry>
2552
Jason Evansaabaf852013-10-30 14:52:09 -07002553 <varlistentry id="stats.arenas.i.bins.j.nflushes">
Jason Evansaee7fd22010-11-24 22:00:02 -08002554 <term>
2555 <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nflushes</mallctl>
2556 (<type>uint64_t</type>)
2557 <literal>r-</literal>
2558 [<option>--enable-stats</option> <option>--enable-tcache</option>]
2559 </term>
2560 <listitem><para>Cumulative number of tcache flushes.</para></listitem>
2561 </varlistentry>
2562
Jason Evansaabaf852013-10-30 14:52:09 -07002563 <varlistentry id="stats.arenas.i.bins.j.nruns">
Jason Evansaee7fd22010-11-24 22:00:02 -08002564 <term>
2565 <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nruns</mallctl>
2566 (<type>uint64_t</type>)
2567 <literal>r-</literal>
2568 [<option>--enable-stats</option>]
2569 </term>
2570 <listitem><para>Cumulative number of runs created.</para></listitem>
2571 </varlistentry>
2572
Jason Evansaabaf852013-10-30 14:52:09 -07002573 <varlistentry id="stats.arenas.i.bins.j.nreruns">
Jason Evansaee7fd22010-11-24 22:00:02 -08002574 <term>
2575 <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nreruns</mallctl>
2576 (<type>uint64_t</type>)
2577 <literal>r-</literal>
2578 [<option>--enable-stats</option>]
2579 </term>
2580 <listitem><para>Cumulative number of times the current run from which
2581 to allocate changed.</para></listitem>
2582 </varlistentry>
2583
Jason Evansaabaf852013-10-30 14:52:09 -07002584 <varlistentry id="stats.arenas.i.bins.j.curruns">
Jason Evansaee7fd22010-11-24 22:00:02 -08002585 <term>
Jason Evansaee7fd22010-11-24 22:00:02 -08002586 <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.curruns</mallctl>
2587 (<type>size_t</type>)
2588 <literal>r-</literal>
2589 [<option>--enable-stats</option>]
2590 </term>
2591 <listitem><para>Current number of runs.</para></listitem>
2592 </varlistentry>
2593
Jason Evansaabaf852013-10-30 14:52:09 -07002594 <varlistentry id="stats.arenas.i.lruns.j.nmalloc">
Jason Evansaee7fd22010-11-24 22:00:02 -08002595 <term>
2596 <mallctl>stats.arenas.&lt;i&gt;.lruns.&lt;j&gt;.nmalloc</mallctl>
2597 (<type>uint64_t</type>)
2598 <literal>r-</literal>
2599 [<option>--enable-stats</option>]
2600 </term>
2601 <listitem><para>Cumulative number of allocation requests for this size
2602 class served directly by the arena.</para></listitem>
2603 </varlistentry>
2604
Jason Evansaabaf852013-10-30 14:52:09 -07002605 <varlistentry id="stats.arenas.i.lruns.j.ndalloc">
Jason Evansaee7fd22010-11-24 22:00:02 -08002606 <term>
2607 <mallctl>stats.arenas.&lt;i&gt;.lruns.&lt;j&gt;.ndalloc</mallctl>
2608 (<type>uint64_t</type>)
2609 <literal>r-</literal>
2610 [<option>--enable-stats</option>]
2611 </term>
2612 <listitem><para>Cumulative number of deallocation requests for this
2613 size class served directly by the arena.</para></listitem>
2614 </varlistentry>
2615
Jason Evansaabaf852013-10-30 14:52:09 -07002616 <varlistentry id="stats.arenas.i.lruns.j.nrequests">
Jason Evansaee7fd22010-11-24 22:00:02 -08002617 <term>
2618 <mallctl>stats.arenas.&lt;i&gt;.lruns.&lt;j&gt;.nrequests</mallctl>
2619 (<type>uint64_t</type>)
2620 <literal>r-</literal>
2621 [<option>--enable-stats</option>]
2622 </term>
2623 <listitem><para>Cumulative number of allocation requests for this size
2624 class.</para></listitem>
2625 </varlistentry>
2626
Jason Evansaabaf852013-10-30 14:52:09 -07002627 <varlistentry id="stats.arenas.i.lruns.j.curruns">
Jason Evansaee7fd22010-11-24 22:00:02 -08002628 <term>
Jason Evansaee7fd22010-11-24 22:00:02 -08002629 <mallctl>stats.arenas.&lt;i&gt;.lruns.&lt;j&gt;.curruns</mallctl>
2630 (<type>size_t</type>)
2631 <literal>r-</literal>
2632 [<option>--enable-stats</option>]
2633 </term>
2634 <listitem><para>Current number of runs for this size class.
2635 </para></listitem>
2636 </varlistentry>
Jason Evans3c4d92e2014-10-12 22:53:59 -07002637
2638 <varlistentry id="stats.arenas.i.hchunks.j.nmalloc">
2639 <term>
2640 <mallctl>stats.arenas.&lt;i&gt;.hchunks.&lt;j&gt;.nmalloc</mallctl>
2641 (<type>uint64_t</type>)
2642 <literal>r-</literal>
2643 [<option>--enable-stats</option>]
2644 </term>
2645 <listitem><para>Cumulative number of allocation requests for this size
2646 class served directly by the arena.</para></listitem>
2647 </varlistentry>
2648
2649 <varlistentry id="stats.arenas.i.hchunks.j.ndalloc">
2650 <term>
2651 <mallctl>stats.arenas.&lt;i&gt;.hchunks.&lt;j&gt;.ndalloc</mallctl>
2652 (<type>uint64_t</type>)
2653 <literal>r-</literal>
2654 [<option>--enable-stats</option>]
2655 </term>
2656 <listitem><para>Cumulative number of deallocation requests for this
2657 size class served directly by the arena.</para></listitem>
2658 </varlistentry>
2659
2660 <varlistentry id="stats.arenas.i.hchunks.j.nrequests">
2661 <term>
2662 <mallctl>stats.arenas.&lt;i&gt;.hchunks.&lt;j&gt;.nrequests</mallctl>
2663 (<type>uint64_t</type>)
2664 <literal>r-</literal>
2665 [<option>--enable-stats</option>]
2666 </term>
2667 <listitem><para>Cumulative number of allocation requests for this size
2668 class.</para></listitem>
2669 </varlistentry>
2670
2671 <varlistentry id="stats.arenas.i.hchunks.j.curhchunks">
2672 <term>
2673 <mallctl>stats.arenas.&lt;i&gt;.hchunks.&lt;j&gt;.curhchunks</mallctl>
2674 (<type>size_t</type>)
2675 <literal>r-</literal>
2676 [<option>--enable-stats</option>]
2677 </term>
2678 <listitem><para>Current number of huge allocations for this size class.
2679 </para></listitem>
2680 </varlistentry>
Jason Evansaee7fd22010-11-24 22:00:02 -08002681 </variablelist>
2682 </refsect1>
Jason Evans5ec703d2016-02-24 15:35:24 -08002683 <refsect1 id="heap_profile_format">
2684 <title>HEAP PROFILE FORMAT</title>
2685 <para>Although the heap profiling functionality was originally designed to
2686 be compatible with the
2687 <command>pprof</command> command that is developed as part of the <ulink
2688 url="http://code.google.com/p/gperftools/">gperftools
2689 package</ulink>, the addition of per thread heap profiling functionality
2690 required a different heap profile format. The <command>jeprof</command>
2691 command is derived from <command>pprof</command>, with enhancements to
2692 support the heap profile format described here.</para>
2693
2694 <para>In the following hypothetical heap profile, <constant>[...]</constant>
2695 indicates elision for the sake of compactness. <programlisting><![CDATA[
2696heap_v2/524288
2697 t*: 28106: 56637512 [0: 0]
2698 [...]
2699 t3: 352: 16777344 [0: 0]
2700 [...]
2701 t99: 17754: 29341640 [0: 0]
2702 [...]
2703@ 0x5f86da8 0x5f5a1dc [...] 0x29e4d4e 0xa200316 0xabb2988 [...]
2704 t*: 13: 6688 [0: 0]
2705 t3: 12: 6496 [0: ]
2706 t99: 1: 192 [0: 0]
2707[...]
2708
2709MAPPED_LIBRARIES:
2710[...]]]></programlisting> The following matches the above heap profile, but most
2711tokens are replaced with <constant>&lt;description&gt;</constant> to indicate
2712descriptions of the corresponding fields. <programlisting><![CDATA[
2713<heap_profile_format_version>/<mean_sample_interval>
2714 <aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
2715 [...]
2716 <thread_3_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>]
2717 [...]
2718 <thread_99_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>]
2719 [...]
2720@ <top_frame> <frame> [...] <frame> <frame> <frame> [...]
2721 <backtrace_aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
2722 <backtrace_thread_3>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
2723 <backtrace_thread_99>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
2724[...]
2725
2726MAPPED_LIBRARIES:
2727</proc/<pid>/maps>]]></programlisting></para>
2728 </refsect1>
2729
Jason Evansaee7fd22010-11-24 22:00:02 -08002730 <refsect1 id="debugging_malloc_problems">
2731 <title>DEBUGGING MALLOC PROBLEMS</title>
2732 <para>When debugging, it is a good idea to configure/build jemalloc with
2733 the <option>--enable-debug</option> and <option>--enable-fill</option>
2734 options, and recompile the program with suitable options and symbols for
2735 debugger support. When so configured, jemalloc incorporates a wide variety
2736 of run-time assertions that catch application errors such as double-free,
2737 write-after-free, etc.</para>
2738
Jason Evansf19bedb2016-11-01 13:25:42 -07002739 <para>Programs often accidentally depend on <quote>uninitialized</quote>
Jason Evansaee7fd22010-11-24 22:00:02 -08002740 memory actually being filled with zero bytes. Junk filling
2741 (see the <link linkend="opt.junk"><mallctl>opt.junk</mallctl></link>
2742 option) tends to expose such bugs in the form of obviously incorrect
2743 results and/or coredumps. Conversely, zero
2744 filling (see the <link
2745 linkend="opt.zero"><mallctl>opt.zero</mallctl></link> option) eliminates
2746 the symptoms of such bugs. Between these two options, it is usually
2747 possible to quickly detect, diagnose, and eliminate such bugs.</para>
2748
2749 <para>This implementation does not provide much detail about the problems
2750 it detects, because the performance impact for storing such information
Jason Evans122449b2012-04-06 00:35:09 -07002751 would be prohibitive. However, jemalloc does integrate with the most
Jason Evansd926c902012-04-25 23:17:57 -07002752 excellent <ulink url="http://valgrind.org/">Valgrind</ulink> tool if the
Jason Evans781fe752012-05-15 14:48:14 -07002753 <option>--enable-valgrind</option> configuration option is enabled.</para>
Jason Evansaee7fd22010-11-24 22:00:02 -08002754 </refsect1>
2755 <refsect1 id="diagnostic_messages">
2756 <title>DIAGNOSTIC MESSAGES</title>
2757 <para>If any of the memory allocation/deallocation functions detect an
2758 error or warning condition, a message will be printed to file descriptor
2759 <constant>STDERR_FILENO</constant>. Errors will result in the process
2760 dumping core. If the <link
2761 linkend="opt.abort"><mallctl>opt.abort</mallctl></link> option is set, most
2762 warnings are treated as errors.</para>
2763
2764 <para>The <varname>malloc_message</varname> variable allows the programmer
2765 to override the function which emits the text strings forming the errors
2766 and warnings if for some reason the <constant>STDERR_FILENO</constant> file
2767 descriptor is not suitable for this.
Jason Evans9ebbfca92016-09-12 16:44:33 -07002768 <function>malloc_message()</function> takes the
Jason Evansaee7fd22010-11-24 22:00:02 -08002769 <parameter>cbopaque</parameter> pointer argument that is
2770 <constant>NULL</constant> unless overridden by the arguments in a call to
Jason Evans9ebbfca92016-09-12 16:44:33 -07002771 <function>malloc_stats_print()</function>, followed by a string
Jason Evansaee7fd22010-11-24 22:00:02 -08002772 pointer. Please note that doing anything which tries to allocate memory in
2773 this function is likely to result in a crash or deadlock.</para>
2774
2775 <para>All messages are prefixed by
Jason Evansf19bedb2016-11-01 13:25:42 -07002776 <quote><computeroutput>&lt;jemalloc&gt;: </computeroutput></quote>.</para>
Jason Evansaee7fd22010-11-24 22:00:02 -08002777 </refsect1>
2778 <refsect1 id="return_values">
2779 <title>RETURN VALUES</title>
2780 <refsect2>
2781 <title>Standard API</title>
Jason Evans9ebbfca92016-09-12 16:44:33 -07002782 <para>The <function>malloc()</function> and
2783 <function>calloc()</function> functions return a pointer to the
Jason Evansaee7fd22010-11-24 22:00:02 -08002784 allocated memory if successful; otherwise a <constant>NULL</constant>
2785 pointer is returned and <varname>errno</varname> is set to
2786 <errorname>ENOMEM</errorname>.</para>
2787
Jason Evans9ebbfca92016-09-12 16:44:33 -07002788 <para>The <function>posix_memalign()</function> function
Jason Evansaee7fd22010-11-24 22:00:02 -08002789 returns the value 0 if successful; otherwise it returns an error value.
Jason Evans9ebbfca92016-09-12 16:44:33 -07002790 The <function>posix_memalign()</function> function will fail
Jason Evansaee7fd22010-11-24 22:00:02 -08002791 if:
2792 <variablelist>
2793 <varlistentry>
2794 <term><errorname>EINVAL</errorname></term>
2795
2796 <listitem><para>The <parameter>alignment</parameter> parameter is
2797 not a power of 2 at least as large as
2798 <code language="C">sizeof(<type>void *</type>)</code>.
2799 </para></listitem>
2800 </varlistentry>
2801 <varlistentry>
2802 <term><errorname>ENOMEM</errorname></term>
2803
2804 <listitem><para>Memory allocation error.</para></listitem>
2805 </varlistentry>
2806 </variablelist>
2807 </para>
2808
Jason Evans9ebbfca92016-09-12 16:44:33 -07002809 <para>The <function>aligned_alloc()</function> function returns
Jason Evans0a0bbf62012-03-13 12:55:21 -07002810 a pointer to the allocated memory if successful; otherwise a
2811 <constant>NULL</constant> pointer is returned and
2812 <varname>errno</varname> is set. The
Jason Evans9ebbfca92016-09-12 16:44:33 -07002813 <function>aligned_alloc()</function> function will fail if:
Jason Evans0a0bbf62012-03-13 12:55:21 -07002814 <variablelist>
2815 <varlistentry>
2816 <term><errorname>EINVAL</errorname></term>
2817
2818 <listitem><para>The <parameter>alignment</parameter> parameter is
2819 not a power of 2.
2820 </para></listitem>
2821 </varlistentry>
2822 <varlistentry>
2823 <term><errorname>ENOMEM</errorname></term>
2824
2825 <listitem><para>Memory allocation error.</para></listitem>
2826 </varlistentry>
2827 </variablelist>
2828 </para>
2829
Jason Evans9ebbfca92016-09-12 16:44:33 -07002830 <para>The <function>realloc()</function> function returns a
Jason Evansaee7fd22010-11-24 22:00:02 -08002831 pointer, possibly identical to <parameter>ptr</parameter>, to the
2832 allocated memory if successful; otherwise a <constant>NULL</constant>
2833 pointer is returned, and <varname>errno</varname> is set to
2834 <errorname>ENOMEM</errorname> if the error was the result of an
Jason Evans9ebbfca92016-09-12 16:44:33 -07002835 allocation failure. The <function>realloc()</function>
Jason Evansaee7fd22010-11-24 22:00:02 -08002836 function always leaves the original buffer intact when an error occurs.
2837 </para>
2838
Jason Evans9ebbfca92016-09-12 16:44:33 -07002839 <para>The <function>free()</function> function returns no
Jason Evansaee7fd22010-11-24 22:00:02 -08002840 value.</para>
2841 </refsect2>
2842 <refsect2>
2843 <title>Non-standard API</title>
Jason Evans9ebbfca92016-09-12 16:44:33 -07002844 <para>The <function>mallocx()</function> and
2845 <function>rallocx()</function> functions return a pointer to
Jason Evansd82a5e62013-12-12 22:35:52 -08002846 the allocated memory if successful; otherwise a <constant>NULL</constant>
2847 pointer is returned to indicate insufficient contiguous memory was
2848 available to service the allocation request. </para>
2849
Jason Evans9ebbfca92016-09-12 16:44:33 -07002850 <para>The <function>xallocx()</function> function returns the
Jason Evansd82a5e62013-12-12 22:35:52 -08002851 real size of the resulting resized allocation pointed to by
2852 <parameter>ptr</parameter>, which is a value less than
2853 <parameter>size</parameter> if the allocation could not be adequately
2854 grown in place. </para>
2855
Jason Evans9ebbfca92016-09-12 16:44:33 -07002856 <para>The <function>sallocx()</function> function returns the
Jason Evansd82a5e62013-12-12 22:35:52 -08002857 real size of the allocation pointed to by <parameter>ptr</parameter>.
2858 </para>
2859
Jason Evans9ebbfca92016-09-12 16:44:33 -07002860 <para>The <function>nallocx()</function> returns the real size
Jason Evansd82a5e62013-12-12 22:35:52 -08002861 that would result from a successful equivalent
Jason Evans9ebbfca92016-09-12 16:44:33 -07002862 <function>mallocx()</function> function call, or zero if
Jason Evansd82a5e62013-12-12 22:35:52 -08002863 insufficient memory is available to perform the size computation. </para>
Jason Evansaee7fd22010-11-24 22:00:02 -08002864
Jason Evans9ebbfca92016-09-12 16:44:33 -07002865 <para>The <function>mallctl()</function>,
2866 <function>mallctlnametomib()</function>, and
2867 <function>mallctlbymib()</function> functions return 0 on
Jason Evansaee7fd22010-11-24 22:00:02 -08002868 success; otherwise they return an error value. The functions will fail
2869 if:
2870 <variablelist>
2871 <varlistentry>
2872 <term><errorname>EINVAL</errorname></term>
2873
2874 <listitem><para><parameter>newp</parameter> is not
2875 <constant>NULL</constant>, and <parameter>newlen</parameter> is too
2876 large or too small. Alternatively, <parameter>*oldlenp</parameter>
2877 is too large or too small; in this case as much data as possible
2878 are read despite the error.</para></listitem>
2879 </varlistentry>
2880 <varlistentry>
Jason Evansaee7fd22010-11-24 22:00:02 -08002881 <term><errorname>ENOENT</errorname></term>
2882
2883 <listitem><para><parameter>name</parameter> or
2884 <parameter>mib</parameter> specifies an unknown/invalid
2885 value.</para></listitem>
2886 </varlistentry>
2887 <varlistentry>
2888 <term><errorname>EPERM</errorname></term>
2889
2890 <listitem><para>Attempt to read or write void value, or attempt to
2891 write read-only value.</para></listitem>
2892 </varlistentry>
2893 <varlistentry>
2894 <term><errorname>EAGAIN</errorname></term>
2895
2896 <listitem><para>A memory allocation failure
2897 occurred.</para></listitem>
2898 </varlistentry>
2899 <varlistentry>
2900 <term><errorname>EFAULT</errorname></term>
2901
2902 <listitem><para>An interface with side effects failed in some way
Jason Evans9ebbfca92016-09-12 16:44:33 -07002903 not directly related to <function>mallctl*()</function>
Jason Evansaee7fd22010-11-24 22:00:02 -08002904 read/write processing.</para></listitem>
2905 </varlistentry>
2906 </variablelist>
2907 </para>
Jason Evansd82a5e62013-12-12 22:35:52 -08002908
Jason Evans9ebbfca92016-09-12 16:44:33 -07002909 <para>The <function>malloc_usable_size()</function> function
Jason Evansd82a5e62013-12-12 22:35:52 -08002910 returns the usable size of the allocation pointed to by
2911 <parameter>ptr</parameter>. </para>
Jason Evansaee7fd22010-11-24 22:00:02 -08002912 </refsect2>
Jason Evansaee7fd22010-11-24 22:00:02 -08002913 </refsect1>
2914 <refsect1 id="environment">
2915 <title>ENVIRONMENT</title>
2916 <para>The following environment variable affects the execution of the
2917 allocation functions:
2918 <variablelist>
2919 <varlistentry>
2920 <term><envar>MALLOC_CONF</envar></term>
2921
2922 <listitem><para>If the environment variable
2923 <envar>MALLOC_CONF</envar> is set, the characters it contains
2924 will be interpreted as options.</para></listitem>
2925 </varlistentry>
2926 </variablelist>
2927 </para>
2928 </refsect1>
2929 <refsect1 id="examples">
2930 <title>EXAMPLES</title>
2931 <para>To dump core whenever a problem occurs:
2932 <screen>ln -s 'abort:true' /etc/malloc.conf</screen>
2933 </para>
2934 <para>To specify in the source a chunk size that is 16 MiB:
2935 <programlisting language="C"><![CDATA[
2936malloc_conf = "lg_chunk:24";]]></programlisting></para>
2937 </refsect1>
2938 <refsect1 id="see_also">
2939 <title>SEE ALSO</title>
2940 <para><citerefentry><refentrytitle>madvise</refentrytitle>
2941 <manvolnum>2</manvolnum></citerefentry>,
2942 <citerefentry><refentrytitle>mmap</refentrytitle>
2943 <manvolnum>2</manvolnum></citerefentry>,
2944 <citerefentry><refentrytitle>sbrk</refentrytitle>
2945 <manvolnum>2</manvolnum></citerefentry>,
Jason Evansb1476112012-04-05 13:36:17 -07002946 <citerefentry><refentrytitle>utrace</refentrytitle>
2947 <manvolnum>2</manvolnum></citerefentry>,
Jason Evansaee7fd22010-11-24 22:00:02 -08002948 <citerefentry><refentrytitle>alloca</refentrytitle>
2949 <manvolnum>3</manvolnum></citerefentry>,
2950 <citerefentry><refentrytitle>atexit</refentrytitle>
2951 <manvolnum>3</manvolnum></citerefentry>,
2952 <citerefentry><refentrytitle>getpagesize</refentrytitle>
2953 <manvolnum>3</manvolnum></citerefentry></para>
2954 </refsect1>
2955 <refsect1 id="standards">
2956 <title>STANDARDS</title>
Jason Evans9ebbfca92016-09-12 16:44:33 -07002957 <para>The <function>malloc()</function>,
2958 <function>calloc()</function>,
2959 <function>realloc()</function>, and
2960 <function>free()</function> functions conform to ISO/IEC
Jason Evansf19bedb2016-11-01 13:25:42 -07002961 9899:1990 (<quote>ISO C90</quote>).</para>
Jason Evansaee7fd22010-11-24 22:00:02 -08002962
Jason Evans9ebbfca92016-09-12 16:44:33 -07002963 <para>The <function>posix_memalign()</function> function conforms
Jason Evansf19bedb2016-11-01 13:25:42 -07002964 to IEEE Std 1003.1-2001 (<quote>POSIX.1</quote>).</para>
Jason Evansaee7fd22010-11-24 22:00:02 -08002965 </refsect1>
2966</refentry>