1<?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>
33    <refname>aligned_alloc</refname>
34    <refname>realloc</refname>
35    <refname>free</refname>
36    <refname>mallocx</refname>
37    <refname>rallocx</refname>
38    <refname>xallocx</refname>
39    <refname>sallocx</refname>
40    <refname>dallocx</refname>
41    <refname>sdallocx</refname>
42    <refname>nallocx</refname>
43    <refname>mallctl</refname>
44    <refname>mallctlnametomib</refname>
45    <refname>mallctlbymib</refname>
46    <refname>malloc_stats_print</refname>
47    <refname>malloc_usable_size</refname>
48    -->
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
55    url="http://www.canonware.com/jemalloc/">jemalloc website</ulink>.</para>
56  </refsect1>
57  <refsynopsisdiv>
58    <title>SYNOPSIS</title>
59    <funcsynopsis>
60      <funcsynopsisinfo>#include &lt;<filename class="headerfile">jemalloc/jemalloc.h</filename>&gt;</funcsynopsisinfo>
61      <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>
79          <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>
84          <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>
96          <funcdef>void *<function>mallocx</function></funcdef>
97          <paramdef>size_t <parameter>size</parameter></paramdef>
98          <paramdef>int <parameter>flags</parameter></paramdef>
99        </funcprototype>
100        <funcprototype>
101          <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>
124          <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>
130          <funcdef>size_t <function>nallocx</function></funcdef>
131          <paramdef>size_t <parameter>size</parameter></paramdef>
132          <paramdef>int <parameter>flags</parameter></paramdef>
133        </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>
158          <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>
170          <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>
176    </funcsynopsis>
177  </refsynopsisdiv>
178  <refsect1 id="description">
179    <title>DESCRIPTION</title>
180    <refsect2>
181      <title>Standard API</title>
182
183      <para>The <function>malloc<parameter/></function> function allocates
184      <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
188      <para>The <function>calloc<parameter/></function> function allocates
189      space for <parameter>number</parameter> objects, each
190      <parameter>size</parameter> bytes in length.  The result is identical to
191      calling <function>malloc<parameter/></function> with an argument of
192      <parameter>number</parameter> * <parameter>size</parameter>, with the
193      exception that the allocated memory is explicitly initialized to zero
194      bytes.</para>
195
196      <para>The <function>posix_memalign<parameter/></function> function
197      allocates <parameter>size</parameter> bytes of memory such that the
198      allocation's base address is a multiple of
199      <parameter>alignment</parameter>, and returns the allocation in the value
200      pointed to by <parameter>ptr</parameter>.  The requested
201      <parameter>alignment</parameter> must be a power of 2 at least as large as
202      <code language="C">sizeof(<type>void *</type>)</code>.</para>
203
204      <para>The <function>aligned_alloc<parameter/></function> function
205      allocates <parameter>size</parameter> bytes of memory such that the
206      allocation's base address is a multiple of
207      <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
212      <para>The <function>realloc<parameter/></function> function changes the
213      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
220      <function>realloc<parameter/></function> may move the memory allocation,
221      resulting in a different return value than <parameter>ptr</parameter>.
222      If <parameter>ptr</parameter> is <constant>NULL</constant>, the
223      <function>realloc<parameter/></function> function behaves identically to
224      <function>malloc<parameter/></function> for the specified size.</para>
225
226      <para>The <function>free<parameter/></function> function causes the
227      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>
233      <para>The <function>mallocx<parameter/></function>,
234      <function>rallocx<parameter/></function>,
235      <function>xallocx<parameter/></function>,
236      <function>sallocx<parameter/></function>,
237      <function>dallocx<parameter/></function>,
238      <function>sdallocx<parameter/></function>, and
239      <function>nallocx<parameter/></function> functions all have a
240      <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>
245          <varlistentry id="MALLOCX_LG_ALIGN">
246            <term><constant>MALLOCX_LG_ALIGN(<parameter>la</parameter>)
247            </constant></term>
248
249            <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>
255          <varlistentry id="MALLOCX_ALIGN">
256            <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>
265          <varlistentry id="MALLOCX_ZERO">
266            <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>
274          <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">
298            <term><constant>MALLOCX_ARENA(<parameter>a</parameter>)
299            </constant></term>
300
301            <listitem><para>Use the arena specified by the index
302            <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>
306          </varlistentry>
307        </variablelist>
308      </para>
309
310      <para>The <function>mallocx<parameter/></function> function allocates at
311      least <parameter>size</parameter> bytes of memory, and returns a pointer
312      to the base address of the allocation.  Behavior is undefined if
313      <parameter>size</parameter> is <constant>0</constant>, or if request size
314      overflows due to size class and/or alignment constraints.</para>
315
316      <para>The <function>rallocx<parameter/></function> function resizes the
317      allocation at <parameter>ptr</parameter> to be at least
318      <parameter>size</parameter> bytes, and returns a pointer to the base
319      address of the resulting allocation, which may or may not have moved from
320      its original location.  Behavior is undefined if
321      <parameter>size</parameter> is <constant>0</constant>, or if request size
322      overflows due to size class and/or alignment constraints.</para>
323
324      <para>The <function>xallocx<parameter/></function> function resizes the
325      allocation at <parameter>ptr</parameter> in place to be at least
326      <parameter>size</parameter> bytes, and returns the real size of the
327      allocation.  If <parameter>extra</parameter> is non-zero, an attempt is
328      made to resize the allocation to be at least <code
329      language="C">(<parameter>size</parameter> +
330      <parameter>extra</parameter>)</code> bytes, though inability to allocate
331      the extra byte(s) will not by itself result in failure to resize.
332      Behavior is undefined if <parameter>size</parameter> is
333      <constant>0</constant>, or if <code
334      language="C">(<parameter>size</parameter> + <parameter>extra</parameter>
335      &gt; <constant>SIZE_T_MAX</constant>)</code>.</para>
336
337      <para>The <function>sallocx<parameter/></function> function returns the
338      real size of the allocation at <parameter>ptr</parameter>.</para>
339
340      <para>The <function>dallocx<parameter/></function> function causes the
341      memory referenced by <parameter>ptr</parameter> to be made available for
342      future allocations.</para>
343
344      <para>The <function>sdallocx<parameter/></function> function is an
345      extension of <function>dallocx<parameter/></function> with a
346      <parameter>size</parameter> parameter to allow the caller to pass in the
347      allocation size as an optimization.  The minimum valid input size is the
348      original requested size of the allocation, and the maximum valid input
349      size is the corresponding value returned by
350      <function>nallocx<parameter/></function> or
351      <function>sallocx<parameter/></function>.</para>
352
353      <para>The <function>nallocx<parameter/></function> function allocates no
354      memory, but it performs the same size computation as the
355      <function>mallocx<parameter/></function> function, and returns the real
356      size of the allocation that would result from the equivalent
357      <function>mallocx<parameter/></function> function call.  Behavior is
358      undefined if <parameter>size</parameter> is <constant>0</constant>, or if
359      request size overflows due to size class and/or alignment
360      constraints.</para>
361
362      <para>The <function>mallctl<parameter/></function> function provides a
363      general interface for introspecting the memory allocator, as well as
364      setting modifiable parameters and triggering actions.  The
365      period-separated <parameter>name</parameter> argument specifies a
366      location in a tree-structured namespace; see the <xref
367      linkend="mallctl_namespace" xrefstyle="template:%t"/> section for
368      documentation on the tree contents.  To read a value, pass a pointer via
369      <parameter>oldp</parameter> to adequate space to contain the value, and a
370      pointer to its length via <parameter>oldlenp</parameter>; otherwise pass
371      <constant>NULL</constant> and <constant>NULL</constant>.  Similarly, to
372      write a value, pass a pointer to the value via
373      <parameter>newp</parameter>, and its length via
374      <parameter>newlen</parameter>; otherwise pass <constant>NULL</constant>
375      and <constant>0</constant>.</para>
376
377      <para>The <function>mallctlnametomib<parameter/></function> function
378      provides a way to avoid repeated name lookups for applications that
379      repeatedly query the same portion of the namespace, by translating a name
380      to a &ldquo;Management Information Base&rdquo; (MIB) that can be passed
381      repeatedly to <function>mallctlbymib<parameter/></function>.  Upon
382      successful return from <function>mallctlnametomib<parameter/></function>,
383      <parameter>mibp</parameter> contains an array of
384      <parameter>*miblenp</parameter> integers, where
385      <parameter>*miblenp</parameter> is the lesser of the number of components
386      in <parameter>name</parameter> and the input value of
387      <parameter>*miblenp</parameter>.  Thus it is possible to pass a
388      <parameter>*miblenp</parameter> that is smaller than the number of
389      period-separated name components, which results in a partial MIB that can
390      be used as the basis for constructing a complete MIB.  For name
391      components that are integers (e.g. the 2 in
392      <link
393      linkend="arenas.bin.i.size"><mallctl>arenas.bin.2.size</mallctl></link>),
394      the corresponding MIB component will always be that integer.  Therefore,
395      it is legitimate to construct code like the following: <programlisting
396      language="C"><![CDATA[
397unsigned nbins, i;
398size_t mib[4];
399size_t len, miblen;
400
401len = sizeof(nbins);
402mallctl("arenas.nbins", &nbins, &len, NULL, 0);
403
404miblen = 4;
405mallctlnametomib("arenas.bin.0.size", mib, &miblen);
406for (i = 0; i < nbins; i++) {
407	size_t bin_size;
408
409	mib[2] = i;
410	len = sizeof(bin_size);
411	mallctlbymib(mib, miblen, &bin_size, &len, NULL, 0);
412	/* Do something with bin_size... */
413}]]></programlisting></para>
414
415      <para>The <function>malloc_stats_print<parameter/></function> function
416      writes human-readable summary statistics via the
417      <parameter>write_cb</parameter> callback function pointer and
418      <parameter>cbopaque</parameter> data passed to
419      <parameter>write_cb</parameter>, or
420      <function>malloc_message<parameter/></function> if
421      <parameter>write_cb</parameter> is <constant>NULL</constant>.  This
422      function can be called repeatedly.  General information that never
423      changes during execution can be omitted by specifying "g" as a character
424      within the <parameter>opts</parameter> string.  Note that
425      <function>malloc_message<parameter/></function> uses the
426      <function>mallctl*<parameter/></function> functions internally, so
427      inconsistent statistics can be reported if multiple threads use these
428      functions simultaneously.  If <option>--enable-stats</option> is
429      specified during configuration, &ldquo;m&rdquo; and &ldquo;a&rdquo; can
430      be specified to omit merged arena and per arena statistics, respectively;
431      &ldquo;b&rdquo;, &ldquo;l&rdquo;, and &ldquo;h&rdquo; can be specified to
432      omit per size class statistics for bins, large objects, and huge objects,
433      respectively.  Unrecognized characters are silently ignored.  Note that
434      thread caching may prevent some statistics from being completely up to
435      date, since extra locking would be required to merge counters that track
436      thread cache operations.
437      </para>
438
439      <para>The <function>malloc_usable_size<parameter/></function> function
440      returns the usable size of the allocation pointed to by
441      <parameter>ptr</parameter>.  The return value may be larger than the size
442      that was requested during allocation.  The
443      <function>malloc_usable_size<parameter/></function> function is not a
444      mechanism for in-place <function>realloc<parameter/></function>; rather
445      it is provided solely as a tool for introspection purposes.  Any
446      discrepancy between the requested allocation size and the size reported
447      by <function>malloc_usable_size<parameter/></function> should not be
448      depended on, since such behavior is entirely implementation-dependent.
449      </para>
450    </refsect2>
451  </refsect1>
452  <refsect1 id="tuning">
453    <title>TUNING</title>
454    <para>Once, when the first call is made to one of the memory allocation
455    routines, the allocator initializes its internals based in part on various
456    options that can be specified at compile- or run-time.</para>
457
458    <para>The string pointed to by the global variable
459    <varname>malloc_conf</varname>, the &ldquo;name&rdquo; of the file
460    referenced by the symbolic link named <filename
461    class="symlink">/etc/malloc.conf</filename>, and the value of the
462    environment variable <envar>MALLOC_CONF</envar>, will be interpreted, in
463    that order, from left to right as options.  Note that
464    <varname>malloc_conf</varname> may be read before
465    <function>main<parameter/></function> is entered, so the declaration of
466    <varname>malloc_conf</varname> should specify an initializer that contains
467    the final value to be read by jemalloc.  <varname>malloc_conf</varname> is
468    a compile-time setting, whereas <filename
469    class="symlink">/etc/malloc.conf</filename> and <envar>MALLOC_CONF</envar>
470    can be safely set any time prior to program invocation.</para>
471
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
490    <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>
494    <manvolnum>2</manvolnum></citerefentry> and
495    <citerefentry><refentrytitle>sbrk</refentrytitle>
496    <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
520    <para>Memory is conceptually broken into equal-sized chunks, where the
521    chunk size is a power of two that is greater than the page size.  Chunks
522    are always aligned to multiples of the chunk size.  This alignment makes it
523    possible to find metadata for user objects very quickly.</para>
524
525    <para>User objects are broken into three categories according to size:
526    small, large, and huge.  Small and large objects are managed entirely by
527    arenas; huge objects are additionally aggregated in a single data structure
528    that is shared by all threads.  Huge objects are typically used by
529    applications infrequently enough that this single data structure is not a
530    scalability issue.</para>
531
532    <para>Each chunk that is managed by an arena tracks its contents as runs of
533    contiguous pages (unused, backing a set of small objects, or backing one
534    large object).  The combination of chunk alignment and chunk page maps
535    makes it possible to determine all metadata regarding small and large
536    allocations in constant time.</para>
537
538    <para>Small objects are managed in groups by page runs.  Each run maintains
539    a bitmap to track which regions are in use.  Allocation requests that are no
540    more than half the quantum (8 or 16, depending on architecture) are rounded
541    up to the nearest power of two that is at least <code
542    language="C">sizeof(<type>double</type>)</code>.  All other object size
543    classes are multiples of the quantum, spaced such that there are four size
544    classes for each doubling in size, which limits internal fragmentation to
545    approximately 20% for all but the smallest size classes.  Small size classes
546    are smaller than four times the page size, large size classes are smaller
547    than the chunk size (see the <link
548    linkend="opt.lg_chunk"><mallctl>opt.lg_chunk</mallctl></link> option), and
549    huge size classes extend from the chunk size up to one size class less than
550    the full address space size.</para>
551
552    <para>Allocations are packed tightly together, which can be an issue for
553    multi-threaded applications.  If you need to assure that allocations do not
554    suffer from cacheline sharing, round your allocation requests up to the
555    nearest multiple of the cacheline size, or specify cacheline alignment when
556    allocating.</para>
557
558    <para>The <function>realloc<parameter/></function>,
559    <function>rallocx<parameter/></function>, and
560    <function>xallocx<parameter/></function> functions may resize allocations
561    without moving them under limited circumstances.  Unlike the
562    <function>*allocx<parameter/></function> API, the standard API does not
563    officially round up the usable size of an allocation to the nearest size
564    class, so technically it is necessary to call
565    <function>realloc<parameter/></function> to grow e.g. a 9-byte allocation to
566    16 bytes, or shrink a 16-byte allocation to 9 bytes.  Growth and shrinkage
567    trivially succeeds in place as long as the pre-size and post-size both round
568    up to the same size class.  No other API guarantees are made regarding
569    in-place resizing, but the current implementation also tries to resize large
570    and huge allocations in place, as long as the pre-size and post-size are
571    both large or both huge.  In such cases shrinkage always succeeds for large
572    size classes, but for huge size classes the chunk allocator must support
573    splitting (see <link
574    linkend="arena.i.chunk_hooks"><mallctl>arena.&lt;i&gt;.chunk_hooks</mallctl></link>).
575    Growth only succeeds if the trailing memory is currently available, and
576    additionally for huge size classes the chunk allocator must support
577    merging.</para>
578
579    <para>Assuming 2 MiB chunks, 4 KiB pages, and a 16-byte quantum on a
580    64-bit system, the size classes in each category are as shown in <xref
581    linkend="size_classes" xrefstyle="template:Table %n"/>.</para>
582
583    <table xml:id="size_classes" frame="all">
584      <title>Size classes</title>
585      <tgroup cols="3" colsep="1" rowsep="1">
586      <colspec colname="c1" align="left"/>
587      <colspec colname="c2" align="right"/>
588      <colspec colname="c3" align="left"/>
589      <thead>
590        <row>
591          <entry>Category</entry>
592          <entry>Spacing</entry>
593          <entry>Size</entry>
594        </row>
595      </thead>
596      <tbody>
597        <row>
598          <entry morerows="8">Small</entry>
599          <entry>lg</entry>
600          <entry>[8]</entry>
601        </row>
602        <row>
603          <entry>16</entry>
604          <entry>[16, 32, 48, 64, 80, 96, 112, 128]</entry>
605        </row>
606        <row>
607          <entry>32</entry>
608          <entry>[160, 192, 224, 256]</entry>
609        </row>
610        <row>
611          <entry>64</entry>
612          <entry>[320, 384, 448, 512]</entry>
613        </row>
614        <row>
615          <entry>128</entry>
616          <entry>[640, 768, 896, 1024]</entry>
617        </row>
618        <row>
619          <entry>256</entry>
620          <entry>[1280, 1536, 1792, 2048]</entry>
621        </row>
622        <row>
623          <entry>512</entry>
624          <entry>[2560, 3072, 3584, 4096]</entry>
625        </row>
626        <row>
627          <entry>1 KiB</entry>
628          <entry>[5 KiB, 6 KiB, 7 KiB, 8 KiB]</entry>
629        </row>
630        <row>
631          <entry>2 KiB</entry>
632          <entry>[10 KiB, 12 KiB, 14 KiB]</entry>
633        </row>
634        <row>
635          <entry morerows="7">Large</entry>
636          <entry>2 KiB</entry>
637          <entry>[16 KiB]</entry>
638        </row>
639        <row>
640          <entry>4 KiB</entry>
641          <entry>[20 KiB, 24 KiB, 28 KiB, 32 KiB]</entry>
642        </row>
643        <row>
644          <entry>8 KiB</entry>
645          <entry>[40 KiB, 48 KiB, 54 KiB, 64 KiB]</entry>
646        </row>
647        <row>
648          <entry>16 KiB</entry>
649          <entry>[80 KiB, 96 KiB, 112 KiB, 128 KiB]</entry>
650        </row>
651        <row>
652          <entry>32 KiB</entry>
653          <entry>[160 KiB, 192 KiB, 224 KiB, 256 KiB]</entry>
654        </row>
655        <row>
656          <entry>64 KiB</entry>
657          <entry>[320 KiB, 384 KiB, 448 KiB, 512 KiB]</entry>
658        </row>
659        <row>
660          <entry>128 KiB</entry>
661          <entry>[640 KiB, 768 KiB, 896 KiB, 1 MiB]</entry>
662        </row>
663        <row>
664          <entry>256 KiB</entry>
665          <entry>[1280 KiB, 1536 KiB, 1792 KiB]</entry>
666        </row>
667        <row>
668          <entry morerows="6">Huge</entry>
669          <entry>256 KiB</entry>
670          <entry>[2 MiB]</entry>
671        </row>
672        <row>
673          <entry>512 KiB</entry>
674          <entry>[2560 KiB, 3 MiB, 3584 KiB, 4 MiB]</entry>
675        </row>
676        <row>
677          <entry>1 MiB</entry>
678          <entry>[5 MiB, 6 MiB, 7 MiB, 8 MiB]</entry>
679        </row>
680        <row>
681          <entry>2 MiB</entry>
682          <entry>[10 MiB, 12 MiB, 14 MiB, 16 MiB]</entry>
683        </row>
684        <row>
685          <entry>4 MiB</entry>
686          <entry>[20 MiB, 24 MiB, 28 MiB, 32 MiB]</entry>
687        </row>
688        <row>
689          <entry>8 MiB</entry>
690          <entry>[40 MiB, 48 MiB, 56 MiB, 64 MiB]</entry>
691        </row>
692        <row>
693          <entry>...</entry>
694          <entry>...</entry>
695        </row>
696      </tbody>
697      </tgroup>
698    </table>
699  </refsect1>
700  <refsect1 id="mallctl_namespace">
701    <title>MALLCTL NAMESPACE</title>
702    <para>The following names are defined in the namespace accessible via the
703    <function>mallctl*<parameter/></function> functions.  Value types are
704    specified in parentheses, their readable/writable statuses are encoded as
705    <literal>rw</literal>, <literal>r-</literal>, <literal>-w</literal>, or
706    <literal>--</literal>, and required build configuration flags follow, if
707    any.  A name element encoded as <literal>&lt;i&gt;</literal> or
708    <literal>&lt;j&gt;</literal> indicates an integer component, where the
709    integer varies from 0 to some upper value that must be determined via
710    introspection.  In the case of <mallctl>stats.arenas.&lt;i&gt;.*</mallctl>,
711    <literal>&lt;i&gt;</literal> equal to <link
712    linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link> can be
713    used to access the summation of statistics from all arenas.  Take special
714    note of the <link linkend="epoch"><mallctl>epoch</mallctl></link> mallctl,
715    which controls refreshing of cached dynamic statistics.</para>
716
717    <variablelist>
718      <varlistentry id="version">
719        <term>
720          <mallctl>version</mallctl>
721          (<type>const char *</type>)
722          <literal>r-</literal>
723        </term>
724        <listitem><para>Return the jemalloc version string.</para></listitem>
725      </varlistentry>
726
727      <varlistentry id="epoch">
728        <term>
729          <mallctl>epoch</mallctl>
730          (<type>uint64_t</type>)
731          <literal>rw</literal>
732        </term>
733        <listitem><para>If a value is passed in, refresh the data from which
734        the <function>mallctl*<parameter/></function> functions report values,
735        and increment the epoch.  Return the current epoch.  This is useful for
736        detecting whether another thread caused a refresh.</para></listitem>
737      </varlistentry>
738
739      <varlistentry id="config.cache_oblivious">
740        <term>
741          <mallctl>config.cache_oblivious</mallctl>
742          (<type>bool</type>)
743          <literal>r-</literal>
744        </term>
745        <listitem><para><option>--enable-cache-oblivious</option> was specified
746        during build configuration.</para></listitem>
747      </varlistentry>
748
749      <varlistentry id="config.debug">
750        <term>
751          <mallctl>config.debug</mallctl>
752          (<type>bool</type>)
753          <literal>r-</literal>
754        </term>
755        <listitem><para><option>--enable-debug</option> was specified during
756        build configuration.</para></listitem>
757      </varlistentry>
758
759      <varlistentry id="config.fill">
760        <term>
761          <mallctl>config.fill</mallctl>
762          (<type>bool</type>)
763          <literal>r-</literal>
764        </term>
765        <listitem><para><option>--enable-fill</option> was specified during
766        build configuration.</para></listitem>
767      </varlistentry>
768
769      <varlistentry id="config.lazy_lock">
770        <term>
771          <mallctl>config.lazy_lock</mallctl>
772          (<type>bool</type>)
773          <literal>r-</literal>
774        </term>
775        <listitem><para><option>--enable-lazy-lock</option> was specified
776        during build configuration.</para></listitem>
777      </varlistentry>
778
779      <varlistentry id="config.munmap">
780        <term>
781          <mallctl>config.munmap</mallctl>
782          (<type>bool</type>)
783          <literal>r-</literal>
784        </term>
785        <listitem><para><option>--enable-munmap</option> was specified during
786        build configuration.</para></listitem>
787      </varlistentry>
788
789      <varlistentry id="config.prof">
790        <term>
791          <mallctl>config.prof</mallctl>
792          (<type>bool</type>)
793          <literal>r-</literal>
794        </term>
795        <listitem><para><option>--enable-prof</option> was specified during
796        build configuration.</para></listitem>
797      </varlistentry>
798
799      <varlistentry id="config.prof_libgcc">
800        <term>
801          <mallctl>config.prof_libgcc</mallctl>
802          (<type>bool</type>)
803          <literal>r-</literal>
804        </term>
805        <listitem><para><option>--disable-prof-libgcc</option> was not
806        specified during build configuration.</para></listitem>
807      </varlistentry>
808
809      <varlistentry id="config.prof_libunwind">
810        <term>
811          <mallctl>config.prof_libunwind</mallctl>
812          (<type>bool</type>)
813          <literal>r-</literal>
814        </term>
815        <listitem><para><option>--enable-prof-libunwind</option> was specified
816        during build configuration.</para></listitem>
817      </varlistentry>
818
819      <varlistentry id="config.stats">
820        <term>
821          <mallctl>config.stats</mallctl>
822          (<type>bool</type>)
823          <literal>r-</literal>
824        </term>
825        <listitem><para><option>--enable-stats</option> was specified during
826        build configuration.</para></listitem>
827      </varlistentry>
828
829      <varlistentry id="config.tcache">
830        <term>
831          <mallctl>config.tcache</mallctl>
832          (<type>bool</type>)
833          <literal>r-</literal>
834        </term>
835        <listitem><para><option>--disable-tcache</option> was not specified
836        during build configuration.</para></listitem>
837      </varlistentry>
838
839      <varlistentry id="config.tls">
840        <term>
841          <mallctl>config.tls</mallctl>
842          (<type>bool</type>)
843          <literal>r-</literal>
844        </term>
845        <listitem><para><option>--disable-tls</option> was not specified during
846        build configuration.</para></listitem>
847      </varlistentry>
848
849      <varlistentry id="config.utrace">
850        <term>
851          <mallctl>config.utrace</mallctl>
852          (<type>bool</type>)
853          <literal>r-</literal>
854        </term>
855        <listitem><para><option>--enable-utrace</option> was specified during
856        build configuration.</para></listitem>
857      </varlistentry>
858
859      <varlistentry id="config.valgrind">
860        <term>
861          <mallctl>config.valgrind</mallctl>
862          (<type>bool</type>)
863          <literal>r-</literal>
864        </term>
865        <listitem><para><option>--enable-valgrind</option> was specified during
866        build configuration.</para></listitem>
867      </varlistentry>
868
869      <varlistentry id="config.xmalloc">
870        <term>
871          <mallctl>config.xmalloc</mallctl>
872          (<type>bool</type>)
873          <literal>r-</literal>
874        </term>
875        <listitem><para><option>--enable-xmalloc</option> was specified during
876        build configuration.</para></listitem>
877      </varlistentry>
878
879      <varlistentry id="opt.abort">
880        <term>
881          <mallctl>opt.abort</mallctl>
882          (<type>bool</type>)
883          <literal>r-</literal>
884        </term>
885        <listitem><para>Abort-on-warning enabled/disabled.  If true, most
886        warnings are fatal.  The process will call
887        <citerefentry><refentrytitle>abort</refentrytitle>
888        <manvolnum>3</manvolnum></citerefentry> in these cases.  This option is
889        disabled by default unless <option>--enable-debug</option> is
890        specified during configuration, in which case it is enabled by default.
891        </para></listitem>
892      </varlistentry>
893
894      <varlistentry id="opt.dss">
895        <term>
896          <mallctl>opt.dss</mallctl>
897          (<type>const char *</type>)
898          <literal>r-</literal>
899        </term>
900        <listitem><para>dss (<citerefentry><refentrytitle>sbrk</refentrytitle>
901        <manvolnum>2</manvolnum></citerefentry>) allocation precedence as
902        related to <citerefentry><refentrytitle>mmap</refentrytitle>
903        <manvolnum>2</manvolnum></citerefentry> allocation.  The following
904        settings are supported if
905        <citerefentry><refentrytitle>sbrk</refentrytitle>
906        <manvolnum>2</manvolnum></citerefentry> is supported by the operating
907        system: &ldquo;disabled&rdquo;, &ldquo;primary&rdquo;, and
908        &ldquo;secondary&rdquo;; otherwise only &ldquo;disabled&rdquo; is
909        supported.  The default is &ldquo;secondary&rdquo; if
910        <citerefentry><refentrytitle>sbrk</refentrytitle>
911        <manvolnum>2</manvolnum></citerefentry> is supported by the operating
912        system; &ldquo;disabled&rdquo; otherwise.
913        </para></listitem>
914      </varlistentry>
915
916      <varlistentry id="opt.lg_chunk">
917        <term>
918          <mallctl>opt.lg_chunk</mallctl>
919          (<type>size_t</type>)
920          <literal>r-</literal>
921        </term>
922        <listitem><para>Virtual memory chunk size (log base 2).  If a chunk
923        size outside the supported size range is specified, the size is
924        silently clipped to the minimum/maximum supported size.  The default
925        chunk size is 2 MiB (2^21).
926        </para></listitem>
927      </varlistentry>
928
929      <varlistentry id="opt.narenas">
930        <term>
931          <mallctl>opt.narenas</mallctl>
932          (<type>size_t</type>)
933          <literal>r-</literal>
934        </term>
935        <listitem><para>Maximum number of arenas to use for automatic
936        multiplexing of threads and arenas.  The default is four times the
937        number of CPUs, or one if there is a single CPU.</para></listitem>
938      </varlistentry>
939
940      <varlistentry id="opt.lg_dirty_mult">
941        <term>
942          <mallctl>opt.lg_dirty_mult</mallctl>
943          (<type>ssize_t</type>)
944          <literal>r-</literal>
945        </term>
946        <listitem><para>Per-arena minimum ratio (log base 2) of active to dirty
947        pages.  Some dirty unused pages may be allowed to accumulate, within
948        the limit set by the ratio (or one chunk worth of dirty pages,
949        whichever is greater), before informing the kernel about some of those
950        pages via <citerefentry><refentrytitle>madvise</refentrytitle>
951        <manvolnum>2</manvolnum></citerefentry> or a similar system call.  This
952        provides the kernel with sufficient information to recycle dirty pages
953        if physical memory becomes scarce and the pages remain unused.  The
954        default minimum ratio is 8:1 (2^3:1); an option value of -1 will
955        disable dirty page purging.  See <link
956        linkend="arenas.lg_dirty_mult"><mallctl>arenas.lg_dirty_mult</mallctl></link>
957        and <link
958        linkend="arena.i.lg_dirty_mult"><mallctl>arena.&lt;i&gt;.lg_dirty_mult</mallctl></link>
959        for related dynamic control options.</para></listitem>
960      </varlistentry>
961
962      <varlistentry id="opt.stats_print">
963        <term>
964          <mallctl>opt.stats_print</mallctl>
965          (<type>bool</type>)
966          <literal>r-</literal>
967        </term>
968        <listitem><para>Enable/disable statistics printing at exit.  If
969        enabled, the <function>malloc_stats_print<parameter/></function>
970        function is called at program exit via an
971        <citerefentry><refentrytitle>atexit</refentrytitle>
972        <manvolnum>3</manvolnum></citerefentry> function.  If
973        <option>--enable-stats</option> is specified during configuration, this
974        has the potential to cause deadlock for a multi-threaded process that
975        exits while one or more threads are executing in the memory allocation
976        functions.  Furthermore, <function>atexit<parameter/></function> may
977        allocate memory during application initialization and then deadlock
978        internally when jemalloc in turn calls
979        <function>atexit<parameter/></function>, so this option is not
980        univerally usable (though the application can register its own
981        <function>atexit<parameter/></function> function with equivalent
982        functionality).  Therefore, this option should only be used with care;
983        it is primarily intended as a performance tuning aid during application
984        development.  This option is disabled by default.</para></listitem>
985      </varlistentry>
986
987      <varlistentry id="opt.junk">
988        <term>
989          <mallctl>opt.junk</mallctl>
990          (<type>const char *</type>)
991          <literal>r-</literal>
992          [<option>--enable-fill</option>]
993        </term>
994        <listitem><para>Junk filling.  If set to "alloc", each byte of
995        uninitialized allocated memory will be initialized to
996        <literal>0xa5</literal>.  If set to "free", all deallocated memory will
997        be initialized to <literal>0x5a</literal>.  If set to "true", both
998        allocated and deallocated memory will be initialized, and if set to
999        "false", junk filling be disabled entirely.  This is intended for
1000        debugging and will impact performance negatively.  This option is
1001        "false" by default unless <option>--enable-debug</option> is specified
1002        during configuration, in which case it is "true" by default unless
1003        running inside <ulink
1004        url="http://valgrind.org/">Valgrind</ulink>.</para></listitem>
1005      </varlistentry>
1006
1007      <varlistentry id="opt.quarantine">
1008        <term>
1009          <mallctl>opt.quarantine</mallctl>
1010          (<type>size_t</type>)
1011          <literal>r-</literal>
1012          [<option>--enable-fill</option>]
1013        </term>
1014        <listitem><para>Per thread quarantine size in bytes.  If non-zero, each
1015        thread maintains a FIFO object quarantine that stores up to the
1016        specified number of bytes of memory.  The quarantined memory is not
1017        freed until it is released from quarantine, though it is immediately
1018        junk-filled if the <link
1019        linkend="opt.junk"><mallctl>opt.junk</mallctl></link> option is
1020        enabled.  This feature is of particular use in combination with <ulink
1021        url="http://valgrind.org/">Valgrind</ulink>, which can detect attempts
1022        to access quarantined objects.  This is intended for debugging and will
1023        impact performance negatively.  The default quarantine size is 0 unless
1024        running inside Valgrind, in which case the default is 16
1025        MiB.</para></listitem>
1026      </varlistentry>
1027
1028      <varlistentry id="opt.redzone">
1029        <term>
1030          <mallctl>opt.redzone</mallctl>
1031          (<type>bool</type>)
1032          <literal>r-</literal>
1033          [<option>--enable-fill</option>]
1034        </term>
1035        <listitem><para>Redzones enabled/disabled.  If enabled, small
1036        allocations have redzones before and after them.  Furthermore, if the
1037        <link linkend="opt.junk"><mallctl>opt.junk</mallctl></link> option is
1038        enabled, the redzones are checked for corruption during deallocation.
1039        However, the primary intended purpose of this feature is to be used in
1040        combination with <ulink url="http://valgrind.org/">Valgrind</ulink>,
1041        which needs redzones in order to do effective buffer overflow/underflow
1042        detection.  This option is intended for debugging and will impact
1043        performance negatively.  This option is disabled by
1044        default unless running inside Valgrind.</para></listitem>
1045      </varlistentry>
1046
1047      <varlistentry id="opt.zero">
1048        <term>
1049          <mallctl>opt.zero</mallctl>
1050          (<type>bool</type>)
1051          <literal>r-</literal>
1052          [<option>--enable-fill</option>]
1053        </term>
1054        <listitem><para>Zero filling enabled/disabled.  If enabled, each byte
1055        of uninitialized allocated memory will be initialized to 0.  Note that
1056        this initialization only happens once for each byte, so
1057        <function>realloc<parameter/></function> and
1058        <function>rallocx<parameter/></function> calls do not zero memory that
1059        was previously allocated.  This is intended for debugging and will
1060        impact performance negatively.  This option is disabled by default.
1061        </para></listitem>
1062      </varlistentry>
1063
1064      <varlistentry id="opt.utrace">
1065        <term>
1066          <mallctl>opt.utrace</mallctl>
1067          (<type>bool</type>)
1068          <literal>r-</literal>
1069          [<option>--enable-utrace</option>]
1070        </term>
1071        <listitem><para>Allocation tracing based on
1072        <citerefentry><refentrytitle>utrace</refentrytitle>
1073        <manvolnum>2</manvolnum></citerefentry> enabled/disabled.  This option
1074        is disabled by default.</para></listitem>
1075      </varlistentry>
1076
1077      <varlistentry id="opt.xmalloc">
1078        <term>
1079          <mallctl>opt.xmalloc</mallctl>
1080          (<type>bool</type>)
1081          <literal>r-</literal>
1082          [<option>--enable-xmalloc</option>]
1083        </term>
1084        <listitem><para>Abort-on-out-of-memory enabled/disabled.  If enabled,
1085        rather than returning failure for any allocation function, display a
1086        diagnostic message on <constant>STDERR_FILENO</constant> and cause the
1087        program to drop core (using
1088        <citerefentry><refentrytitle>abort</refentrytitle>
1089        <manvolnum>3</manvolnum></citerefentry>).  If an application is
1090        designed to depend on this behavior, set the option at compile time by
1091        including the following in the source code:
1092        <programlisting language="C"><![CDATA[
1093malloc_conf = "xmalloc:true";]]></programlisting>
1094        This option is disabled by default.</para></listitem>
1095      </varlistentry>
1096
1097      <varlistentry id="opt.tcache">
1098        <term>
1099          <mallctl>opt.tcache</mallctl>
1100          (<type>bool</type>)
1101          <literal>r-</literal>
1102          [<option>--enable-tcache</option>]
1103        </term>
1104        <listitem><para>Thread-specific caching (tcache) enabled/disabled.  When
1105        there are multiple threads, each thread uses a tcache for objects up to
1106        a certain size.  Thread-specific caching allows many allocations to be
1107        satisfied without performing any thread synchronization, at the cost of
1108        increased memory use.  See the <link
1109        linkend="opt.lg_tcache_max"><mallctl>opt.lg_tcache_max</mallctl></link>
1110        option for related tuning information.  This option is enabled by
1111        default unless running inside <ulink
1112        url="http://valgrind.org/">Valgrind</ulink>, in which case it is
1113        forcefully disabled.</para></listitem>
1114      </varlistentry>
1115
1116      <varlistentry id="opt.lg_tcache_max">
1117        <term>
1118          <mallctl>opt.lg_tcache_max</mallctl>
1119          (<type>size_t</type>)
1120          <literal>r-</literal>
1121          [<option>--enable-tcache</option>]
1122        </term>
1123        <listitem><para>Maximum size class (log base 2) to cache in the
1124        thread-specific cache (tcache).  At a minimum, all small size classes
1125        are cached, and at a maximum all large size classes are cached.  The
1126        default maximum is 32 KiB (2^15).</para></listitem>
1127      </varlistentry>
1128
1129      <varlistentry id="opt.prof">
1130        <term>
1131          <mallctl>opt.prof</mallctl>
1132          (<type>bool</type>)
1133          <literal>r-</literal>
1134          [<option>--enable-prof</option>]
1135        </term>
1136        <listitem><para>Memory profiling enabled/disabled.  If enabled, profile
1137        memory allocation activity.  See the <link
1138        linkend="opt.prof_active"><mallctl>opt.prof_active</mallctl></link>
1139        option for on-the-fly activation/deactivation.  See the <link
1140        linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link>
1141        option for probabilistic sampling control.  See the <link
1142        linkend="opt.prof_accum"><mallctl>opt.prof_accum</mallctl></link>
1143        option for control of cumulative sample reporting.  See the <link
1144        linkend="opt.lg_prof_interval"><mallctl>opt.lg_prof_interval</mallctl></link>
1145        option for information on interval-triggered profile dumping, the <link
1146        linkend="opt.prof_gdump"><mallctl>opt.prof_gdump</mallctl></link>
1147        option for information on high-water-triggered profile dumping, and the
1148        <link linkend="opt.prof_final"><mallctl>opt.prof_final</mallctl></link>
1149        option for final profile dumping.  Profile output is compatible with
1150        the <command>jeprof</command> command, which is based on the
1151        <command>pprof</command> that is developed as part of the <ulink
1152        url="http://code.google.com/p/gperftools/">gperftools
1153        package</ulink>.</para></listitem>
1154      </varlistentry>
1155
1156      <varlistentry id="opt.prof_prefix">
1157        <term>
1158          <mallctl>opt.prof_prefix</mallctl>
1159          (<type>const char *</type>)
1160          <literal>r-</literal>
1161          [<option>--enable-prof</option>]
1162        </term>
1163        <listitem><para>Filename prefix for profile dumps.  If the prefix is
1164        set to the empty string, no automatic dumps will occur; this is
1165        primarily useful for disabling the automatic final heap dump (which
1166        also disables leak reporting, if enabled).  The default prefix is
1167        <filename>jeprof</filename>.</para></listitem>
1168      </varlistentry>
1169
1170      <varlistentry id="opt.prof_active">
1171        <term>
1172          <mallctl>opt.prof_active</mallctl>
1173          (<type>bool</type>)
1174          <literal>r-</literal>
1175          [<option>--enable-prof</option>]
1176        </term>
1177        <listitem><para>Profiling activated/deactivated.  This is a secondary
1178        control mechanism that makes it possible to start the application with
1179        profiling enabled (see the <link
1180        linkend="opt.prof"><mallctl>opt.prof</mallctl></link> option) but
1181        inactive, then toggle profiling at any time during program execution
1182        with the <link
1183        linkend="prof.active"><mallctl>prof.active</mallctl></link> mallctl.
1184        This option is enabled by default.</para></listitem>
1185      </varlistentry>
1186
1187      <varlistentry id="opt.prof_thread_active_init">
1188        <term>
1189          <mallctl>opt.prof_thread_active_init</mallctl>
1190          (<type>bool</type>)
1191          <literal>r-</literal>
1192          [<option>--enable-prof</option>]
1193        </term>
1194        <listitem><para>Initial setting for <link
1195        linkend="thread.prof.active"><mallctl>thread.prof.active</mallctl></link>
1196        in newly created threads.  The initial setting for newly created threads
1197        can also be changed during execution via the <link
1198        linkend="prof.thread_active_init"><mallctl>prof.thread_active_init</mallctl></link>
1199        mallctl.  This option is enabled by default.</para></listitem>
1200      </varlistentry>
1201
1202      <varlistentry id="opt.lg_prof_sample">
1203        <term>
1204          <mallctl>opt.lg_prof_sample</mallctl>
1205          (<type>size_t</type>)
1206          <literal>r-</literal>
1207          [<option>--enable-prof</option>]
1208        </term>
1209        <listitem><para>Average interval (log base 2) between allocation
1210        samples, as measured in bytes of allocation activity.  Increasing the
1211        sampling interval decreases profile fidelity, but also decreases the
1212        computational overhead.  The default sample interval is 512 KiB (2^19
1213        B).</para></listitem>
1214      </varlistentry>
1215
1216      <varlistentry id="opt.prof_accum">
1217        <term>
1218          <mallctl>opt.prof_accum</mallctl>
1219          (<type>bool</type>)
1220          <literal>r-</literal>
1221          [<option>--enable-prof</option>]
1222        </term>
1223        <listitem><para>Reporting of cumulative object/byte counts in profile
1224        dumps enabled/disabled.  If this option is enabled, every unique
1225        backtrace must be stored for the duration of execution.  Depending on
1226        the application, this can impose a large memory overhead, and the
1227        cumulative counts are not always of interest.  This option is disabled
1228        by default.</para></listitem>
1229      </varlistentry>
1230
1231      <varlistentry id="opt.lg_prof_interval">
1232        <term>
1233          <mallctl>opt.lg_prof_interval</mallctl>
1234          (<type>ssize_t</type>)
1235          <literal>r-</literal>
1236          [<option>--enable-prof</option>]
1237        </term>
1238        <listitem><para>Average interval (log base 2) between memory profile
1239        dumps, as measured in bytes of allocation activity.  The actual
1240        interval between dumps may be sporadic because decentralized allocation
1241        counters are used to avoid synchronization bottlenecks.  Profiles are
1242        dumped to files named according to the pattern
1243        <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.i&lt;iseq&gt;.heap</filename>,
1244        where <literal>&lt;prefix&gt;</literal> is controlled by the
1245        <link
1246        linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
1247        option.  By default, interval-triggered profile dumping is disabled
1248        (encoded as -1).
1249        </para></listitem>
1250      </varlistentry>
1251
1252      <varlistentry id="opt.prof_gdump">
1253        <term>
1254          <mallctl>opt.prof_gdump</mallctl>
1255          (<type>bool</type>)
1256          <literal>r-</literal>
1257          [<option>--enable-prof</option>]
1258        </term>
1259        <listitem><para>Set the initial state of <link
1260        linkend="prof.gdump"><mallctl>prof.gdump</mallctl></link>, which when
1261        enabled triggers a memory profile dump every time the total virtual
1262        memory exceeds the previous maximum.  This option is disabled by
1263        default.</para></listitem>
1264      </varlistentry>
1265
1266      <varlistentry id="opt.prof_final">
1267        <term>
1268          <mallctl>opt.prof_final</mallctl>
1269          (<type>bool</type>)
1270          <literal>r-</literal>
1271          [<option>--enable-prof</option>]
1272        </term>
1273        <listitem><para>Use an
1274        <citerefentry><refentrytitle>atexit</refentrytitle>
1275        <manvolnum>3</manvolnum></citerefentry> function to dump final memory
1276        usage to a file named according to the pattern
1277        <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.f.heap</filename>,
1278        where <literal>&lt;prefix&gt;</literal> is controlled by the <link
1279        linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
1280        option.  Note that <function>atexit<parameter/></function> may allocate
1281        memory during application initialization and then deadlock internally
1282        when jemalloc in turn calls <function>atexit<parameter/></function>, so
1283        this option is not univerally usable (though the application can
1284        register its own <function>atexit<parameter/></function> function with
1285        equivalent functionality).  This option is disabled by
1286        default.</para></listitem>
1287      </varlistentry>
1288
1289      <varlistentry id="opt.prof_leak">
1290        <term>
1291          <mallctl>opt.prof_leak</mallctl>
1292          (<type>bool</type>)
1293          <literal>r-</literal>
1294          [<option>--enable-prof</option>]
1295        </term>
1296        <listitem><para>Leak reporting enabled/disabled.  If enabled, use an
1297        <citerefentry><refentrytitle>atexit</refentrytitle>
1298        <manvolnum>3</manvolnum></citerefentry> function to report memory leaks
1299        detected by allocation sampling.  See the
1300        <link linkend="opt.prof"><mallctl>opt.prof</mallctl></link> option for
1301        information on analyzing heap profile output.  This option is disabled
1302        by default.</para></listitem>
1303      </varlistentry>
1304
1305      <varlistentry id="thread.arena">
1306        <term>
1307          <mallctl>thread.arena</mallctl>
1308          (<type>unsigned</type>)
1309          <literal>rw</literal>
1310        </term>
1311        <listitem><para>Get or set the arena associated with the calling
1312        thread.  If the specified arena was not initialized beforehand (see the
1313        <link
1314        linkend="arenas.initialized"><mallctl>arenas.initialized</mallctl></link>
1315        mallctl), it will be automatically initialized as a side effect of
1316        calling this interface.</para></listitem>
1317      </varlistentry>
1318
1319      <varlistentry id="thread.allocated">
1320        <term>
1321          <mallctl>thread.allocated</mallctl>
1322          (<type>uint64_t</type>)
1323          <literal>r-</literal>
1324          [<option>--enable-stats</option>]
1325        </term>
1326        <listitem><para>Get the total number of bytes ever allocated by the
1327        calling thread.  This counter has the potential to wrap around; it is
1328        up to the application to appropriately interpret the counter in such
1329        cases.</para></listitem>
1330      </varlistentry>
1331
1332      <varlistentry id="thread.allocatedp">
1333        <term>
1334          <mallctl>thread.allocatedp</mallctl>
1335          (<type>uint64_t *</type>)
1336          <literal>r-</literal>
1337          [<option>--enable-stats</option>]
1338        </term>
1339        <listitem><para>Get a pointer to the the value that is returned by the
1340        <link
1341        linkend="thread.allocated"><mallctl>thread.allocated</mallctl></link>
1342        mallctl.  This is useful for avoiding the overhead of repeated
1343        <function>mallctl*<parameter/></function> calls.</para></listitem>
1344      </varlistentry>
1345
1346      <varlistentry id="thread.deallocated">
1347        <term>
1348          <mallctl>thread.deallocated</mallctl>
1349          (<type>uint64_t</type>)
1350          <literal>r-</literal>
1351          [<option>--enable-stats</option>]
1352        </term>
1353        <listitem><para>Get the total number of bytes ever deallocated by the
1354        calling thread.  This counter has the potential to wrap around; it is
1355        up to the application to appropriately interpret the counter in such
1356        cases.</para></listitem>
1357      </varlistentry>
1358
1359      <varlistentry id="thread.deallocatedp">
1360        <term>
1361          <mallctl>thread.deallocatedp</mallctl>
1362          (<type>uint64_t *</type>)
1363          <literal>r-</literal>
1364          [<option>--enable-stats</option>]
1365        </term>
1366        <listitem><para>Get a pointer to the the value that is returned by the
1367        <link
1368        linkend="thread.deallocated"><mallctl>thread.deallocated</mallctl></link>
1369        mallctl.  This is useful for avoiding the overhead of repeated
1370        <function>mallctl*<parameter/></function> calls.</para></listitem>
1371      </varlistentry>
1372
1373      <varlistentry id="thread.tcache.enabled">
1374        <term>
1375          <mallctl>thread.tcache.enabled</mallctl>
1376          (<type>bool</type>)
1377          <literal>rw</literal>
1378          [<option>--enable-tcache</option>]
1379        </term>
1380        <listitem><para>Enable/disable calling thread's tcache.  The tcache is
1381        implicitly flushed as a side effect of becoming
1382        disabled (see <link
1383        linkend="thread.tcache.flush"><mallctl>thread.tcache.flush</mallctl></link>).
1384        </para></listitem>
1385      </varlistentry>
1386
1387      <varlistentry id="thread.tcache.flush">
1388        <term>
1389          <mallctl>thread.tcache.flush</mallctl>
1390          (<type>void</type>)
1391          <literal>--</literal>
1392          [<option>--enable-tcache</option>]
1393        </term>
1394        <listitem><para>Flush calling thread's thread-specific cache (tcache).
1395        This interface releases all cached objects and internal data structures
1396        associated with the calling thread's tcache.  Ordinarily, this interface
1397        need not be called, since automatic periodic incremental garbage
1398        collection occurs, and the thread cache is automatically discarded when
1399        a thread exits.  However, garbage collection is triggered by allocation
1400        activity, so it is possible for a thread that stops
1401        allocating/deallocating to retain its cache indefinitely, in which case
1402        the developer may find manual flushing useful.</para></listitem>
1403      </varlistentry>
1404
1405      <varlistentry id="thread.prof.name">
1406        <term>
1407          <mallctl>thread.prof.name</mallctl>
1408          (<type>const char *</type>)
1409          <literal>r-</literal> or
1410          <literal>-w</literal>
1411          [<option>--enable-prof</option>]
1412        </term>
1413        <listitem><para>Get/set the descriptive name associated with the calling
1414        thread in memory profile dumps.  An internal copy of the name string is
1415        created, so the input string need not be maintained after this interface
1416        completes execution.  The output string of this interface should be
1417        copied for non-ephemeral uses, because multiple implementation details
1418        can cause asynchronous string deallocation.  Furthermore, each
1419        invocation of this interface can only read or write; simultaneous
1420        read/write is not supported due to string lifetime limitations.  The
1421        name string must nil-terminated and comprised only of characters in the
1422        sets recognized
1423        by <citerefentry><refentrytitle>isgraph</refentrytitle>
1424        <manvolnum>3</manvolnum></citerefentry> and
1425        <citerefentry><refentrytitle>isblank</refentrytitle>
1426        <manvolnum>3</manvolnum></citerefentry>.</para></listitem>
1427      </varlistentry>
1428
1429      <varlistentry id="thread.prof.active">
1430        <term>
1431          <mallctl>thread.prof.active</mallctl>
1432          (<type>bool</type>)
1433          <literal>rw</literal>
1434          [<option>--enable-prof</option>]
1435        </term>
1436        <listitem><para>Control whether sampling is currently active for the
1437        calling thread.  This is an activation mechanism in addition to <link
1438        linkend="prof.active"><mallctl>prof.active</mallctl></link>; both must
1439        be active for the calling thread to sample.  This flag is enabled by
1440        default.</para></listitem>
1441      </varlistentry>
1442
1443      <varlistentry id="tcache.create">
1444        <term>
1445          <mallctl>tcache.create</mallctl>
1446          (<type>unsigned</type>)
1447          <literal>r-</literal>
1448          [<option>--enable-tcache</option>]
1449        </term>
1450        <listitem><para>Create an explicit thread-specific cache (tcache) and
1451        return an identifier that can be passed to the <link
1452        linkend="MALLOCX_TCACHE"><constant>MALLOCX_TCACHE(<parameter>tc</parameter>)</constant></link>
1453        macro to explicitly use the specified cache rather than the
1454        automatically managed one that is used by default.  Each explicit cache
1455        can be used by only one thread at a time; the application must assure
1456        that this constraint holds.
1457        </para></listitem>
1458      </varlistentry>
1459
1460      <varlistentry id="tcache.flush">
1461        <term>
1462          <mallctl>tcache.flush</mallctl>
1463          (<type>unsigned</type>)
1464          <literal>-w</literal>
1465          [<option>--enable-tcache</option>]
1466        </term>
1467        <listitem><para>Flush the specified thread-specific cache (tcache).  The
1468        same considerations apply to this interface as to <link
1469        linkend="thread.tcache.flush"><mallctl>thread.tcache.flush</mallctl></link>,
1470        except that the tcache will never be automatically be discarded.
1471        </para></listitem>
1472      </varlistentry>
1473
1474      <varlistentry id="tcache.destroy">
1475        <term>
1476          <mallctl>tcache.destroy</mallctl>
1477          (<type>unsigned</type>)
1478          <literal>-w</literal>
1479          [<option>--enable-tcache</option>]
1480        </term>
1481        <listitem><para>Flush the specified thread-specific cache (tcache) and
1482        make the identifier available for use during a future tcache creation.
1483        </para></listitem>
1484      </varlistentry>
1485
1486      <varlistentry id="arena.i.purge">
1487        <term>
1488          <mallctl>arena.&lt;i&gt;.purge</mallctl>
1489          (<type>void</type>)
1490          <literal>--</literal>
1491        </term>
1492        <listitem><para>Purge unused dirty pages for arena &lt;i&gt;, or for
1493        all arenas if &lt;i&gt; equals <link
1494        linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link>.
1495        </para></listitem>
1496      </varlistentry>
1497
1498      <varlistentry id="arena.i.dss">
1499        <term>
1500          <mallctl>arena.&lt;i&gt;.dss</mallctl>
1501          (<type>const char *</type>)
1502          <literal>rw</literal>
1503        </term>
1504        <listitem><para>Set the precedence of dss allocation as related to mmap
1505        allocation for arena &lt;i&gt;, or for all arenas if &lt;i&gt; equals
1506        <link
1507        linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link>.  See
1508        <link linkend="opt.dss"><mallctl>opt.dss</mallctl></link> for supported
1509        settings.</para></listitem>
1510      </varlistentry>
1511
1512      <varlistentry id="arena.i.lg_dirty_mult">
1513        <term>
1514          <mallctl>arena.&lt;i&gt;.lg_dirty_mult</mallctl>
1515          (<type>ssize_t</type>)
1516          <literal>rw</literal>
1517        </term>
1518        <listitem><para>Current per-arena minimum ratio (log base 2) of active
1519        to dirty pages for arena &lt;i&gt;.  Each time this interface is set and
1520        the ratio is increased, pages are synchronously purged as necessary to
1521        impose the new ratio.  See <link
1522        linkend="opt.lg_dirty_mult"><mallctl>opt.lg_dirty_mult</mallctl></link>
1523        for additional information.</para></listitem>
1524      </varlistentry>
1525
1526      <varlistentry id="arena.i.chunk_hooks">
1527        <term>
1528          <mallctl>arena.&lt;i&gt;.chunk_hooks</mallctl>
1529          (<type>chunk_hooks_t</type>)
1530          <literal>rw</literal>
1531        </term>
1532        <listitem><para>Get or set the chunk management hook functions for arena
1533        &lt;i&gt;.  The functions must be capable of operating on all extant
1534        chunks associated with arena &lt;i&gt;, usually by passing unknown
1535        chunks to the replaced functions.  In practice, it is feasible to
1536        control allocation for arenas created via <link
1537        linkend="arenas.extend"><mallctl>arenas.extend</mallctl></link> such
1538        that all chunks originate from an application-supplied chunk allocator
1539        (by setting custom chunk hook functions just after arena creation), but
1540        the automatically created arenas may have already created chunks prior
1541        to the application having an opportunity to take over chunk
1542        allocation.</para>
1543
1544        <programlisting language="C"><![CDATA[
1545typedef struct {
1546	chunk_alloc_t		*alloc;
1547	chunk_dalloc_t		*dalloc;
1548	chunk_commit_t		*commit;
1549	chunk_decommit_t	*decommit;
1550	chunk_purge_t		*purge;
1551	chunk_split_t		*split;
1552	chunk_merge_t		*merge;
1553} chunk_hooks_t;]]></programlisting>
1554        <para>The <type>chunk_hooks_t</type> structure comprises function
1555        pointers which are described individually below.  jemalloc uses these
1556        functions to manage chunk lifetime, which starts off with allocation of
1557        mapped committed memory, in the simplest case followed by deallocation.
1558        However, there are performance and platform reasons to retain chunks for
1559        later reuse.  Cleanup attempts cascade from deallocation to decommit to
1560        purging, which gives the chunk management functions opportunities to
1561        reject the most permanent cleanup operations in favor of less permanent
1562        (and often less costly) operations.  The chunk splitting and merging
1563        operations can also be opted out of, but this is mainly intended to
1564        support platforms on which virtual memory mappings provided by the
1565        operating system kernel do not automatically coalesce and split, e.g.
1566        Windows.</para>
1567
1568        <funcsynopsis><funcprototype>
1569          <funcdef>typedef void *<function>(chunk_alloc_t)</function></funcdef>
1570          <paramdef>void *<parameter>chunk</parameter></paramdef>
1571          <paramdef>size_t <parameter>size</parameter></paramdef>
1572          <paramdef>size_t <parameter>alignment</parameter></paramdef>
1573          <paramdef>bool *<parameter>zero</parameter></paramdef>
1574          <paramdef>bool *<parameter>commit</parameter></paramdef>
1575          <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
1576        </funcprototype></funcsynopsis>
1577        <literallayout></literallayout>
1578        <para>A chunk allocation function conforms to the
1579        <type>chunk_alloc_t</type> type and upon success returns a pointer to
1580        <parameter>size</parameter> bytes of mapped memory on behalf of arena
1581        <parameter>arena_ind</parameter> such that the chunk's base address is a
1582        multiple of <parameter>alignment</parameter>, as well as setting
1583        <parameter>*zero</parameter> to indicate whether the chunk is zeroed and
1584        <parameter>*commit</parameter> to indicate whether the chunk is
1585        committed.  Upon error the function returns <constant>NULL</constant>
1586        and leaves <parameter>*zero</parameter> and
1587        <parameter>*commit</parameter> unmodified.  The
1588        <parameter>size</parameter> parameter is always a multiple of the chunk
1589        size.  The <parameter>alignment</parameter> parameter is always a power
1590        of two at least as large as the chunk size.  Zeroing is mandatory if
1591        <parameter>*zero</parameter> is true upon function entry.  Committing is
1592        mandatory if <parameter>*commit</parameter> is true upon function entry.
1593        If <parameter>chunk</parameter> is not <constant>NULL</constant>, the
1594        returned pointer must be <parameter>chunk</parameter> on success or
1595        <constant>NULL</constant> on error.  Committed memory may be committed
1596        in absolute terms as on a system that does not overcommit, or in
1597        implicit terms as on a system that overcommits and satisfies physical
1598        memory needs on demand via soft page faults.  Note that replacing the
1599        default chunk allocation function makes the arena's <link
1600        linkend="arena.i.dss"><mallctl>arena.&lt;i&gt;.dss</mallctl></link>
1601        setting irrelevant.</para>
1602
1603        <funcsynopsis><funcprototype>
1604          <funcdef>typedef bool <function>(chunk_dalloc_t)</function></funcdef>
1605          <paramdef>void *<parameter>chunk</parameter></paramdef>
1606          <paramdef>size_t <parameter>size</parameter></paramdef>
1607          <paramdef>bool <parameter>committed</parameter></paramdef>
1608          <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
1609        </funcprototype></funcsynopsis>
1610        <literallayout></literallayout>
1611        <para>
1612        A chunk deallocation function conforms to the
1613        <type>chunk_dalloc_t</type> type and deallocates a
1614        <parameter>chunk</parameter> of given <parameter>size</parameter> with
1615        <parameter>committed</parameter>/decommited memory as indicated, on
1616        behalf of arena <parameter>arena_ind</parameter>, returning false upon
1617        success.  If the function returns true, this indicates opt-out from
1618        deallocation; the virtual memory mapping associated with the chunk
1619        remains mapped, in the same commit state, and available for future use,
1620        in which case it will be automatically retained for later reuse.</para>
1621
1622        <funcsynopsis><funcprototype>
1623          <funcdef>typedef bool <function>(chunk_commit_t)</function></funcdef>
1624          <paramdef>void *<parameter>chunk</parameter></paramdef>
1625          <paramdef>size_t <parameter>size</parameter></paramdef>
1626          <paramdef>size_t <parameter>offset</parameter></paramdef>
1627          <paramdef>size_t <parameter>length</parameter></paramdef>
1628          <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
1629        </funcprototype></funcsynopsis>
1630        <literallayout></literallayout>
1631        <para>A chunk commit function conforms to the
1632        <type>chunk_commit_t</type> type and commits zeroed physical memory to
1633        back pages within a <parameter>chunk</parameter> of given
1634        <parameter>size</parameter> at <parameter>offset</parameter> bytes,
1635        extending for <parameter>length</parameter> on behalf of arena
1636        <parameter>arena_ind</parameter>, returning false upon success.
1637        Committed memory may be committed in absolute terms as on a system that
1638        does not overcommit, or in implicit terms as on a system that
1639        overcommits and satisfies physical memory needs on demand via soft page
1640        faults. If the function returns true, this indicates insufficient
1641        physical memory to satisfy the request.</para>
1642
1643        <funcsynopsis><funcprototype>
1644          <funcdef>typedef bool <function>(chunk_decommit_t)</function></funcdef>
1645          <paramdef>void *<parameter>chunk</parameter></paramdef>
1646          <paramdef>size_t <parameter>size</parameter></paramdef>
1647          <paramdef>size_t <parameter>offset</parameter></paramdef>
1648          <paramdef>size_t <parameter>length</parameter></paramdef>
1649          <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
1650        </funcprototype></funcsynopsis>
1651        <literallayout></literallayout>
1652        <para>A chunk decommit function conforms to the
1653        <type>chunk_decommit_t</type> type and decommits any physical memory
1654        that is backing pages within a <parameter>chunk</parameter> of given
1655        <parameter>size</parameter> at <parameter>offset</parameter> bytes,
1656        extending for <parameter>length</parameter> on behalf of arena
1657        <parameter>arena_ind</parameter>, returning false upon success, in which
1658        case the pages will be committed via the chunk commit function before
1659        being reused.  If the function returns true, this indicates opt-out from
1660        decommit; the memory remains committed and available for future use, in
1661        which case it will be automatically retained for later reuse.</para>
1662
1663        <funcsynopsis><funcprototype>
1664          <funcdef>typedef bool <function>(chunk_purge_t)</function></funcdef>
1665          <paramdef>void *<parameter>chunk</parameter></paramdef>
1666          <paramdef>size_t<parameter>size</parameter></paramdef>
1667          <paramdef>size_t <parameter>offset</parameter></paramdef>
1668          <paramdef>size_t <parameter>length</parameter></paramdef>
1669          <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
1670        </funcprototype></funcsynopsis>
1671        <literallayout></literallayout>
1672        <para>A chunk purge function conforms to the <type>chunk_purge_t</type>
1673        type and optionally discards physical pages within the virtual memory
1674        mapping associated with <parameter>chunk</parameter> of given
1675        <parameter>size</parameter> at <parameter>offset</parameter> bytes,
1676        extending for <parameter>length</parameter> on behalf of arena
1677        <parameter>arena_ind</parameter>, returning false if pages within the
1678        purged virtual memory range will be zero-filled the next time they are
1679        accessed.</para>
1680
1681        <funcsynopsis><funcprototype>
1682          <funcdef>typedef bool <function>(chunk_split_t)</function></funcdef>
1683          <paramdef>void *<parameter>chunk</parameter></paramdef>
1684          <paramdef>size_t <parameter>size</parameter></paramdef>
1685          <paramdef>size_t <parameter>size_a</parameter></paramdef>
1686          <paramdef>size_t <parameter>size_b</parameter></paramdef>
1687          <paramdef>bool <parameter>committed</parameter></paramdef>
1688          <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
1689        </funcprototype></funcsynopsis>
1690        <literallayout></literallayout>
1691        <para>A chunk split function conforms to the <type>chunk_split_t</type>
1692        type and optionally splits <parameter>chunk</parameter> of given
1693        <parameter>size</parameter> into two adjacent chunks, the first of
1694        <parameter>size_a</parameter> bytes, and the second of
1695        <parameter>size_b</parameter> bytes, operating on
1696        <parameter>committed</parameter>/decommitted memory as indicated, on
1697        behalf of arena <parameter>arena_ind</parameter>, returning false upon
1698        success.  If the function returns true, this indicates that the chunk
1699        remains unsplit and therefore should continue to be operated on as a
1700        whole.</para>
1701
1702        <funcsynopsis><funcprototype>
1703          <funcdef>typedef bool <function>(chunk_merge_t)</function></funcdef>
1704          <paramdef>void *<parameter>chunk_a</parameter></paramdef>
1705          <paramdef>size_t <parameter>size_a</parameter></paramdef>
1706          <paramdef>void *<parameter>chunk_b</parameter></paramdef>
1707          <paramdef>size_t <parameter>size_b</parameter></paramdef>
1708          <paramdef>bool <parameter>committed</parameter></paramdef>
1709          <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
1710        </funcprototype></funcsynopsis>
1711        <literallayout></literallayout>
1712        <para>A chunk merge function conforms to the <type>chunk_merge_t</type>
1713        type and optionally merges adjacent chunks,
1714        <parameter>chunk_a</parameter> of given <parameter>size_a</parameter>
1715        and <parameter>chunk_b</parameter> of given
1716        <parameter>size_b</parameter> into one contiguous chunk, operating on
1717        <parameter>committed</parameter>/decommitted memory as indicated, on
1718        behalf of arena <parameter>arena_ind</parameter>, returning false upon
1719        success.  If the function returns true, this indicates that the chunks
1720        remain distinct mappings and therefore should continue to be operated on
1721        independently.</para>
1722        </listitem>
1723      </varlistentry>
1724
1725      <varlistentry id="arenas.narenas">
1726        <term>
1727          <mallctl>arenas.narenas</mallctl>
1728          (<type>unsigned</type>)
1729          <literal>r-</literal>
1730        </term>
1731        <listitem><para>Current limit on number of arenas.</para></listitem>
1732      </varlistentry>
1733
1734      <varlistentry id="arenas.initialized">
1735        <term>
1736          <mallctl>arenas.initialized</mallctl>
1737          (<type>bool *</type>)
1738          <literal>r-</literal>
1739        </term>
1740        <listitem><para>An array of <link
1741        linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link>
1742        booleans.  Each boolean indicates whether the corresponding arena is
1743        initialized.</para></listitem>
1744      </varlistentry>
1745
1746      <varlistentry id="arenas.lg_dirty_mult">
1747        <term>
1748          <mallctl>arenas.lg_dirty_mult</mallctl>
1749          (<type>ssize_t</type>)
1750          <literal>rw</literal>
1751        </term>
1752        <listitem><para>Current default per-arena minimum ratio (log base 2) of
1753        active to dirty pages, used to initialize <link
1754        linkend="arena.i.lg_dirty_mult"><mallctl>arena.&lt;i&gt;.lg_dirty_mult</mallctl></link>
1755        during arena creation.  See <link
1756        linkend="opt.lg_dirty_mult"><mallctl>opt.lg_dirty_mult</mallctl></link>
1757        for additional information.</para></listitem>
1758      </varlistentry>
1759
1760      <varlistentry id="arenas.quantum">
1761        <term>
1762          <mallctl>arenas.quantum</mallctl>
1763          (<type>size_t</type>)
1764          <literal>r-</literal>
1765        </term>
1766        <listitem><para>Quantum size.</para></listitem>
1767      </varlistentry>
1768
1769      <varlistentry id="arenas.page">
1770        <term>
1771          <mallctl>arenas.page</mallctl>
1772          (<type>size_t</type>)
1773          <literal>r-</literal>
1774        </term>
1775        <listitem><para>Page size.</para></listitem>
1776      </varlistentry>
1777
1778      <varlistentry id="arenas.tcache_max">
1779        <term>
1780          <mallctl>arenas.tcache_max</mallctl>
1781          (<type>size_t</type>)
1782          <literal>r-</literal>
1783          [<option>--enable-tcache</option>]
1784        </term>
1785        <listitem><para>Maximum thread-cached size class.</para></listitem>
1786      </varlistentry>
1787
1788      <varlistentry id="arenas.nbins">
1789        <term>
1790          <mallctl>arenas.nbins</mallctl>
1791          (<type>unsigned</type>)
1792          <literal>r-</literal>
1793        </term>
1794        <listitem><para>Number of bin size classes.</para></listitem>
1795      </varlistentry>
1796
1797      <varlistentry id="arenas.nhbins">
1798        <term>
1799          <mallctl>arenas.nhbins</mallctl>
1800          (<type>unsigned</type>)
1801          <literal>r-</literal>
1802          [<option>--enable-tcache</option>]
1803        </term>
1804        <listitem><para>Total number of thread cache bin size
1805        classes.</para></listitem>
1806      </varlistentry>
1807
1808      <varlistentry id="arenas.bin.i.size">
1809        <term>
1810          <mallctl>arenas.bin.&lt;i&gt;.size</mallctl>
1811          (<type>size_t</type>)
1812          <literal>r-</literal>
1813        </term>
1814        <listitem><para>Maximum size supported by size class.</para></listitem>
1815      </varlistentry>
1816
1817      <varlistentry id="arenas.bin.i.nregs">
1818        <term>
1819          <mallctl>arenas.bin.&lt;i&gt;.nregs</mallctl>
1820          (<type>uint32_t</type>)
1821          <literal>r-</literal>
1822        </term>
1823        <listitem><para>Number of regions per page run.</para></listitem>
1824      </varlistentry>
1825
1826      <varlistentry id="arenas.bin.i.run_size">
1827        <term>
1828          <mallctl>arenas.bin.&lt;i&gt;.run_size</mallctl>
1829          (<type>size_t</type>)
1830          <literal>r-</literal>
1831        </term>
1832        <listitem><para>Number of bytes per page run.</para></listitem>
1833      </varlistentry>
1834
1835      <varlistentry id="arenas.nlruns">
1836        <term>
1837          <mallctl>arenas.nlruns</mallctl>
1838          (<type>unsigned</type>)
1839          <literal>r-</literal>
1840        </term>
1841        <listitem><para>Total number of large size classes.</para></listitem>
1842      </varlistentry>
1843
1844      <varlistentry id="arenas.lrun.i.size">
1845        <term>
1846          <mallctl>arenas.lrun.&lt;i&gt;.size</mallctl>
1847          (<type>size_t</type>)
1848          <literal>r-</literal>
1849        </term>
1850        <listitem><para>Maximum size supported by this large size
1851        class.</para></listitem>
1852      </varlistentry>
1853
1854      <varlistentry id="arenas.nhchunks">
1855        <term>
1856          <mallctl>arenas.nhchunks</mallctl>
1857          (<type>unsigned</type>)
1858          <literal>r-</literal>
1859        </term>
1860        <listitem><para>Total number of huge size classes.</para></listitem>
1861      </varlistentry>
1862
1863      <varlistentry id="arenas.hchunk.i.size">
1864        <term>
1865          <mallctl>arenas.hchunk.&lt;i&gt;.size</mallctl>
1866          (<type>size_t</type>)
1867          <literal>r-</literal>
1868        </term>
1869        <listitem><para>Maximum size supported by this huge size
1870        class.</para></listitem>
1871      </varlistentry>
1872
1873      <varlistentry id="arenas.extend">
1874        <term>
1875          <mallctl>arenas.extend</mallctl>
1876          (<type>unsigned</type>)
1877          <literal>r-</literal>
1878        </term>
1879        <listitem><para>Extend the array of arenas by appending a new arena,
1880        and returning the new arena index.</para></listitem>
1881      </varlistentry>
1882
1883      <varlistentry id="prof.thread_active_init">
1884        <term>
1885          <mallctl>prof.thread_active_init</mallctl>
1886          (<type>bool</type>)
1887          <literal>rw</literal>
1888          [<option>--enable-prof</option>]
1889        </term>
1890        <listitem><para>Control the initial setting for <link
1891        linkend="thread.prof.active"><mallctl>thread.prof.active</mallctl></link>
1892        in newly created threads.  See the <link
1893        linkend="opt.prof_thread_active_init"><mallctl>opt.prof_thread_active_init</mallctl></link>
1894        option for additional information.</para></listitem>
1895      </varlistentry>
1896
1897      <varlistentry id="prof.active">
1898        <term>
1899          <mallctl>prof.active</mallctl>
1900          (<type>bool</type>)
1901          <literal>rw</literal>
1902          [<option>--enable-prof</option>]
1903        </term>
1904        <listitem><para>Control whether sampling is currently active.  See the
1905        <link
1906        linkend="opt.prof_active"><mallctl>opt.prof_active</mallctl></link>
1907        option for additional information, as well as the interrelated <link
1908        linkend="thread.prof.active"><mallctl>thread.prof.active</mallctl></link>
1909        mallctl.</para></listitem>
1910      </varlistentry>
1911
1912      <varlistentry id="prof.dump">
1913        <term>
1914          <mallctl>prof.dump</mallctl>
1915          (<type>const char *</type>)
1916          <literal>-w</literal>
1917          [<option>--enable-prof</option>]
1918        </term>
1919        <listitem><para>Dump a memory profile to the specified file, or if NULL
1920        is specified, to a file according to the pattern
1921        <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.m&lt;mseq&gt;.heap</filename>,
1922        where <literal>&lt;prefix&gt;</literal> is controlled by the
1923        <link
1924        linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
1925        option.</para></listitem>
1926      </varlistentry>
1927
1928      <varlistentry id="prof.gdump">
1929        <term>
1930          <mallctl>prof.gdump</mallctl>
1931          (<type>bool</type>)
1932          <literal>rw</literal>
1933          [<option>--enable-prof</option>]
1934        </term>
1935        <listitem><para>When enabled, trigger a memory profile dump every time
1936        the total virtual memory exceeds the previous maximum.  Profiles are
1937        dumped to files named according to the pattern
1938        <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.u&lt;useq&gt;.heap</filename>,
1939        where <literal>&lt;prefix&gt;</literal> is controlled by the <link
1940        linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
1941        option.</para></listitem>
1942      </varlistentry>
1943
1944      <varlistentry id="prof.reset">
1945        <term>
1946          <mallctl>prof.reset</mallctl>
1947          (<type>size_t</type>)
1948          <literal>-w</literal>
1949          [<option>--enable-prof</option>]
1950        </term>
1951        <listitem><para>Reset all memory profile statistics, and optionally
1952        update the sample rate (see <link
1953        linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link>
1954        and <link
1955        linkend="prof.lg_sample"><mallctl>prof.lg_sample</mallctl></link>).
1956        </para></listitem>
1957      </varlistentry>
1958
1959      <varlistentry id="prof.lg_sample">
1960        <term>
1961          <mallctl>prof.lg_sample</mallctl>
1962          (<type>size_t</type>)
1963          <literal>r-</literal>
1964          [<option>--enable-prof</option>]
1965        </term>
1966        <listitem><para>Get the current sample rate (see <link
1967        linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link>).
1968        </para></listitem>
1969      </varlistentry>
1970
1971      <varlistentry id="prof.interval">
1972        <term>
1973          <mallctl>prof.interval</mallctl>
1974          (<type>uint64_t</type>)
1975          <literal>r-</literal>
1976          [<option>--enable-prof</option>]
1977        </term>
1978        <listitem><para>Average number of bytes allocated between
1979        inverval-based profile dumps.  See the
1980        <link
1981        linkend="opt.lg_prof_interval"><mallctl>opt.lg_prof_interval</mallctl></link>
1982        option for additional information.</para></listitem>
1983      </varlistentry>
1984
1985      <varlistentry id="stats.cactive">
1986        <term>
1987          <mallctl>stats.cactive</mallctl>
1988          (<type>size_t *</type>)
1989          <literal>r-</literal>
1990          [<option>--enable-stats</option>]
1991        </term>
1992        <listitem><para>Pointer to a counter that contains an approximate count
1993        of the current number of bytes in active pages.  The estimate may be
1994        high, but never low, because each arena rounds up when computing its
1995        contribution to the counter.  Note that the <link
1996        linkend="epoch"><mallctl>epoch</mallctl></link> mallctl has no bearing
1997        on this counter.  Furthermore, counter consistency is maintained via
1998        atomic operations, so it is necessary to use an atomic operation in
1999        order to guarantee a consistent read when dereferencing the pointer.
2000        </para></listitem>
2001      </varlistentry>
2002
2003      <varlistentry id="stats.allocated">
2004        <term>
2005          <mallctl>stats.allocated</mallctl>
2006          (<type>size_t</type>)
2007          <literal>r-</literal>
2008          [<option>--enable-stats</option>]
2009        </term>
2010        <listitem><para>Total number of bytes allocated by the
2011        application.</para></listitem>
2012      </varlistentry>
2013
2014      <varlistentry id="stats.active">
2015        <term>
2016          <mallctl>stats.active</mallctl>
2017          (<type>size_t</type>)
2018          <literal>r-</literal>
2019          [<option>--enable-stats</option>]
2020        </term>
2021        <listitem><para>Total number of bytes in active pages allocated by the
2022        application.  This is a multiple of the page size, and greater than or
2023        equal to <link
2024        linkend="stats.allocated"><mallctl>stats.allocated</mallctl></link>.
2025        This does not include <link linkend="stats.arenas.i.pdirty">
2026        <mallctl>stats.arenas.&lt;i&gt;.pdirty</mallctl></link>, nor pages
2027        entirely devoted to allocator metadata.</para></listitem>
2028      </varlistentry>
2029
2030      <varlistentry id="stats.metadata">
2031        <term>
2032          <mallctl>stats.metadata</mallctl>
2033          (<type>size_t</type>)
2034          <literal>r-</literal>
2035          [<option>--enable-stats</option>]
2036        </term>
2037        <listitem><para>Total number of bytes dedicated to metadata, which
2038        comprise base allocations used for bootstrap-sensitive internal
2039        allocator data structures, arena chunk headers (see <link
2040        linkend="stats.arenas.i.metadata.mapped"><mallctl>stats.arenas.&lt;i&gt;.metadata.mapped</mallctl></link>),
2041        and internal allocations (see <link
2042        linkend="stats.arenas.i.metadata.allocated"><mallctl>stats.arenas.&lt;i&gt;.metadata.allocated</mallctl></link>).</para></listitem>
2043      </varlistentry>
2044
2045      <varlistentry id="stats.resident">
2046        <term>
2047          <mallctl>stats.resident</mallctl>
2048          (<type>size_t</type>)
2049          <literal>r-</literal>
2050          [<option>--enable-stats</option>]
2051        </term>
2052        <listitem><para>Maximum number of bytes in physically resident data
2053        pages mapped by the allocator, comprising all pages dedicated to
2054        allocator metadata, pages backing active allocations, and unused dirty
2055        pages.  This is a maximum rather than precise because pages may not
2056        actually be physically resident if they correspond to demand-zeroed
2057        virtual memory that has not yet been touched.  This is a multiple of the
2058        page size, and is larger than <link
2059        linkend="stats.active"><mallctl>stats.active</mallctl></link>.</para></listitem>
2060      </varlistentry>
2061
2062      <varlistentry id="stats.mapped">
2063        <term>
2064          <mallctl>stats.mapped</mallctl>
2065          (<type>size_t</type>)
2066          <literal>r-</literal>
2067          [<option>--enable-stats</option>]
2068        </term>
2069        <listitem><para>Total number of bytes in active chunks mapped by the
2070        allocator.  This is a multiple of the chunk size, and is larger than
2071        <link linkend="stats.active"><mallctl>stats.active</mallctl></link>.
2072        This does not include inactive chunks, even those that contain unused
2073        dirty pages, which means that there is no strict ordering between this
2074        and <link
2075        linkend="stats.resident"><mallctl>stats.resident</mallctl></link>.</para></listitem>
2076      </varlistentry>
2077
2078      <varlistentry id="stats.arenas.i.dss">
2079        <term>
2080          <mallctl>stats.arenas.&lt;i&gt;.dss</mallctl>
2081          (<type>const char *</type>)
2082          <literal>r-</literal>
2083        </term>
2084        <listitem><para>dss (<citerefentry><refentrytitle>sbrk</refentrytitle>
2085        <manvolnum>2</manvolnum></citerefentry>) allocation precedence as
2086        related to <citerefentry><refentrytitle>mmap</refentrytitle>
2087        <manvolnum>2</manvolnum></citerefentry> allocation.  See <link
2088        linkend="opt.dss"><mallctl>opt.dss</mallctl></link> for details.
2089        </para></listitem>
2090      </varlistentry>
2091
2092      <varlistentry id="stats.arenas.i.lg_dirty_mult">
2093        <term>
2094          <mallctl>stats.arenas.&lt;i&gt;.lg_dirty_mult</mallctl>
2095          (<type>ssize_t</type>)
2096          <literal>r-</literal>
2097        </term>
2098        <listitem><para>Minimum ratio (log base 2) of active to dirty pages.
2099        See <link
2100        linkend="opt.lg_dirty_mult"><mallctl>opt.lg_dirty_mult</mallctl></link>
2101        for details.</para></listitem>
2102      </varlistentry>
2103
2104      <varlistentry id="stats.arenas.i.nthreads">
2105        <term>
2106          <mallctl>stats.arenas.&lt;i&gt;.nthreads</mallctl>
2107          (<type>unsigned</type>)
2108          <literal>r-</literal>
2109        </term>
2110        <listitem><para>Number of threads currently assigned to
2111        arena.</para></listitem>
2112      </varlistentry>
2113
2114      <varlistentry id="stats.arenas.i.pactive">
2115        <term>
2116          <mallctl>stats.arenas.&lt;i&gt;.pactive</mallctl>
2117          (<type>size_t</type>)
2118          <literal>r-</literal>
2119        </term>
2120        <listitem><para>Number of pages in active runs.</para></listitem>
2121      </varlistentry>
2122
2123      <varlistentry id="stats.arenas.i.pdirty">
2124        <term>
2125          <mallctl>stats.arenas.&lt;i&gt;.pdirty</mallctl>
2126          (<type>size_t</type>)
2127          <literal>r-</literal>
2128        </term>
2129        <listitem><para>Number of pages within unused runs that are potentially
2130        dirty, and for which <function>madvise<parameter>...</parameter>
2131        <parameter><constant>MADV_DONTNEED</constant></parameter></function> or
2132        similar has not been called.</para></listitem>
2133      </varlistentry>
2134
2135      <varlistentry id="stats.arenas.i.mapped">
2136        <term>
2137          <mallctl>stats.arenas.&lt;i&gt;.mapped</mallctl>
2138          (<type>size_t</type>)
2139          <literal>r-</literal>
2140          [<option>--enable-stats</option>]
2141        </term>
2142        <listitem><para>Number of mapped bytes.</para></listitem>
2143      </varlistentry>
2144
2145      <varlistentry id="stats.arenas.i.metadata.mapped">
2146        <term>
2147          <mallctl>stats.arenas.&lt;i&gt;.metadata.mapped</mallctl>
2148          (<type>size_t</type>)
2149          <literal>r-</literal>
2150          [<option>--enable-stats</option>]
2151        </term>
2152        <listitem><para>Number of mapped bytes in arena chunk headers, which
2153        track the states of the non-metadata pages.</para></listitem>
2154      </varlistentry>
2155
2156      <varlistentry id="stats.arenas.i.metadata.allocated">
2157        <term>
2158          <mallctl>stats.arenas.&lt;i&gt;.metadata.allocated</mallctl>
2159          (<type>size_t</type>)
2160          <literal>r-</literal>
2161          [<option>--enable-stats</option>]
2162        </term>
2163        <listitem><para>Number of bytes dedicated to internal allocations.
2164        Internal allocations differ from application-originated allocations in
2165        that they are for internal use, and that they are omitted from heap
2166        profiles.  This statistic is reported separately from <link
2167        linkend="stats.metadata"><mallctl>stats.metadata</mallctl></link> and
2168        <link
2169        linkend="stats.arenas.i.metadata.mapped"><mallctl>stats.arenas.&lt;i&gt;.metadata.mapped</mallctl></link>
2170        because it overlaps with e.g. the <link
2171        linkend="stats.allocated"><mallctl>stats.allocated</mallctl></link> and
2172        <link linkend="stats.active"><mallctl>stats.active</mallctl></link>
2173        statistics, whereas the other metadata statistics do
2174        not.</para></listitem>
2175      </varlistentry>
2176
2177      <varlistentry id="stats.arenas.i.npurge">
2178        <term>
2179          <mallctl>stats.arenas.&lt;i&gt;.npurge</mallctl>
2180          (<type>uint64_t</type>)
2181          <literal>r-</literal>
2182          [<option>--enable-stats</option>]
2183        </term>
2184        <listitem><para>Number of dirty page purge sweeps performed.
2185        </para></listitem>
2186      </varlistentry>
2187
2188      <varlistentry id="stats.arenas.i.nmadvise">
2189        <term>
2190          <mallctl>stats.arenas.&lt;i&gt;.nmadvise</mallctl>
2191          (<type>uint64_t</type>)
2192          <literal>r-</literal>
2193          [<option>--enable-stats</option>]
2194        </term>
2195        <listitem><para>Number of <function>madvise<parameter>...</parameter>
2196        <parameter><constant>MADV_DONTNEED</constant></parameter></function> or
2197        similar calls made to purge dirty pages.</para></listitem>
2198      </varlistentry>
2199
2200      <varlistentry id="stats.arenas.i.purged">
2201        <term>
2202          <mallctl>stats.arenas.&lt;i&gt;.purged</mallctl>
2203          (<type>uint64_t</type>)
2204          <literal>r-</literal>
2205          [<option>--enable-stats</option>]
2206        </term>
2207        <listitem><para>Number of pages purged.</para></listitem>
2208      </varlistentry>
2209
2210      <varlistentry id="stats.arenas.i.small.allocated">
2211        <term>
2212          <mallctl>stats.arenas.&lt;i&gt;.small.allocated</mallctl>
2213          (<type>size_t</type>)
2214          <literal>r-</literal>
2215          [<option>--enable-stats</option>]
2216        </term>
2217        <listitem><para>Number of bytes currently allocated by small objects.
2218        </para></listitem>
2219      </varlistentry>
2220
2221      <varlistentry id="stats.arenas.i.small.nmalloc">
2222        <term>
2223          <mallctl>stats.arenas.&lt;i&gt;.small.nmalloc</mallctl>
2224          (<type>uint64_t</type>)
2225          <literal>r-</literal>
2226          [<option>--enable-stats</option>]
2227        </term>
2228        <listitem><para>Cumulative number of allocation requests served by
2229        small bins.</para></listitem>
2230      </varlistentry>
2231
2232      <varlistentry id="stats.arenas.i.small.ndalloc">
2233        <term>
2234          <mallctl>stats.arenas.&lt;i&gt;.small.ndalloc</mallctl>
2235          (<type>uint64_t</type>)
2236          <literal>r-</literal>
2237          [<option>--enable-stats</option>]
2238        </term>
2239        <listitem><para>Cumulative number of small objects returned to bins.
2240        </para></listitem>
2241      </varlistentry>
2242
2243      <varlistentry id="stats.arenas.i.small.nrequests">
2244        <term>
2245          <mallctl>stats.arenas.&lt;i&gt;.small.nrequests</mallctl>
2246          (<type>uint64_t</type>)
2247          <literal>r-</literal>
2248          [<option>--enable-stats</option>]
2249        </term>
2250        <listitem><para>Cumulative number of small allocation requests.
2251        </para></listitem>
2252      </varlistentry>
2253
2254      <varlistentry id="stats.arenas.i.large.allocated">
2255        <term>
2256          <mallctl>stats.arenas.&lt;i&gt;.large.allocated</mallctl>
2257          (<type>size_t</type>)
2258          <literal>r-</literal>
2259          [<option>--enable-stats</option>]
2260        </term>
2261        <listitem><para>Number of bytes currently allocated by large objects.
2262        </para></listitem>
2263      </varlistentry>
2264
2265      <varlistentry id="stats.arenas.i.large.nmalloc">
2266        <term>
2267          <mallctl>stats.arenas.&lt;i&gt;.large.nmalloc</mallctl>
2268          (<type>uint64_t</type>)
2269          <literal>r-</literal>
2270          [<option>--enable-stats</option>]
2271        </term>
2272        <listitem><para>Cumulative number of large allocation requests served
2273        directly by the arena.</para></listitem>
2274      </varlistentry>
2275
2276      <varlistentry id="stats.arenas.i.large.ndalloc">
2277        <term>
2278          <mallctl>stats.arenas.&lt;i&gt;.large.ndalloc</mallctl>
2279          (<type>uint64_t</type>)
2280          <literal>r-</literal>
2281          [<option>--enable-stats</option>]
2282        </term>
2283        <listitem><para>Cumulative number of large deallocation requests served
2284        directly by the arena.</para></listitem>
2285      </varlistentry>
2286
2287      <varlistentry id="stats.arenas.i.large.nrequests">
2288        <term>
2289          <mallctl>stats.arenas.&lt;i&gt;.large.nrequests</mallctl>
2290          (<type>uint64_t</type>)
2291          <literal>r-</literal>
2292          [<option>--enable-stats</option>]
2293        </term>
2294        <listitem><para>Cumulative number of large allocation requests.
2295        </para></listitem>
2296      </varlistentry>
2297
2298      <varlistentry id="stats.arenas.i.huge.allocated">
2299        <term>
2300          <mallctl>stats.arenas.&lt;i&gt;.huge.allocated</mallctl>
2301          (<type>size_t</type>)
2302          <literal>r-</literal>
2303          [<option>--enable-stats</option>]
2304        </term>
2305        <listitem><para>Number of bytes currently allocated by huge objects.
2306        </para></listitem>
2307      </varlistentry>
2308
2309      <varlistentry id="stats.arenas.i.huge.nmalloc">
2310        <term>
2311          <mallctl>stats.arenas.&lt;i&gt;.huge.nmalloc</mallctl>
2312          (<type>uint64_t</type>)
2313          <literal>r-</literal>
2314          [<option>--enable-stats</option>]
2315        </term>
2316        <listitem><para>Cumulative number of huge allocation requests served
2317        directly by the arena.</para></listitem>
2318      </varlistentry>
2319
2320      <varlistentry id="stats.arenas.i.huge.ndalloc">
2321        <term>
2322          <mallctl>stats.arenas.&lt;i&gt;.huge.ndalloc</mallctl>
2323          (<type>uint64_t</type>)
2324          <literal>r-</literal>
2325          [<option>--enable-stats</option>]
2326        </term>
2327        <listitem><para>Cumulative number of huge deallocation requests served
2328        directly by the arena.</para></listitem>
2329      </varlistentry>
2330
2331      <varlistentry id="stats.arenas.i.huge.nrequests">
2332        <term>
2333          <mallctl>stats.arenas.&lt;i&gt;.huge.nrequests</mallctl>
2334          (<type>uint64_t</type>)
2335          <literal>r-</literal>
2336          [<option>--enable-stats</option>]
2337        </term>
2338        <listitem><para>Cumulative number of huge allocation requests.
2339        </para></listitem>
2340      </varlistentry>
2341
2342      <varlistentry id="stats.arenas.i.bins.j.nmalloc">
2343        <term>
2344          <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nmalloc</mallctl>
2345          (<type>uint64_t</type>)
2346          <literal>r-</literal>
2347          [<option>--enable-stats</option>]
2348        </term>
2349        <listitem><para>Cumulative number of allocations served by bin.
2350        </para></listitem>
2351      </varlistentry>
2352
2353      <varlistentry id="stats.arenas.i.bins.j.ndalloc">
2354        <term>
2355          <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.ndalloc</mallctl>
2356          (<type>uint64_t</type>)
2357          <literal>r-</literal>
2358          [<option>--enable-stats</option>]
2359        </term>
2360        <listitem><para>Cumulative number of allocations returned to bin.
2361        </para></listitem>
2362      </varlistentry>
2363
2364      <varlistentry id="stats.arenas.i.bins.j.nrequests">
2365        <term>
2366          <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nrequests</mallctl>
2367          (<type>uint64_t</type>)
2368          <literal>r-</literal>
2369          [<option>--enable-stats</option>]
2370        </term>
2371        <listitem><para>Cumulative number of allocation
2372        requests.</para></listitem>
2373      </varlistentry>
2374
2375      <varlistentry id="stats.arenas.i.bins.j.curregs">
2376        <term>
2377          <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.curregs</mallctl>
2378          (<type>size_t</type>)
2379          <literal>r-</literal>
2380          [<option>--enable-stats</option>]
2381        </term>
2382        <listitem><para>Current number of regions for this size
2383        class.</para></listitem>
2384      </varlistentry>
2385
2386      <varlistentry id="stats.arenas.i.bins.j.nfills">
2387        <term>
2388          <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nfills</mallctl>
2389          (<type>uint64_t</type>)
2390          <literal>r-</literal>
2391          [<option>--enable-stats</option> <option>--enable-tcache</option>]
2392        </term>
2393        <listitem><para>Cumulative number of tcache fills.</para></listitem>
2394      </varlistentry>
2395
2396      <varlistentry id="stats.arenas.i.bins.j.nflushes">
2397        <term>
2398          <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nflushes</mallctl>
2399          (<type>uint64_t</type>)
2400          <literal>r-</literal>
2401          [<option>--enable-stats</option> <option>--enable-tcache</option>]
2402        </term>
2403        <listitem><para>Cumulative number of tcache flushes.</para></listitem>
2404      </varlistentry>
2405
2406      <varlistentry id="stats.arenas.i.bins.j.nruns">
2407        <term>
2408          <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nruns</mallctl>
2409          (<type>uint64_t</type>)
2410          <literal>r-</literal>
2411          [<option>--enable-stats</option>]
2412        </term>
2413        <listitem><para>Cumulative number of runs created.</para></listitem>
2414      </varlistentry>
2415
2416      <varlistentry id="stats.arenas.i.bins.j.nreruns">
2417        <term>
2418          <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nreruns</mallctl>
2419          (<type>uint64_t</type>)
2420          <literal>r-</literal>
2421          [<option>--enable-stats</option>]
2422        </term>
2423        <listitem><para>Cumulative number of times the current run from which
2424        to allocate changed.</para></listitem>
2425      </varlistentry>
2426
2427      <varlistentry id="stats.arenas.i.bins.j.curruns">
2428        <term>
2429          <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.curruns</mallctl>
2430          (<type>size_t</type>)
2431          <literal>r-</literal>
2432          [<option>--enable-stats</option>]
2433        </term>
2434        <listitem><para>Current number of runs.</para></listitem>
2435      </varlistentry>
2436
2437      <varlistentry id="stats.arenas.i.lruns.j.nmalloc">
2438        <term>
2439          <mallctl>stats.arenas.&lt;i&gt;.lruns.&lt;j&gt;.nmalloc</mallctl>
2440          (<type>uint64_t</type>)
2441          <literal>r-</literal>
2442          [<option>--enable-stats</option>]
2443        </term>
2444        <listitem><para>Cumulative number of allocation requests for this size
2445        class served directly by the arena.</para></listitem>
2446      </varlistentry>
2447
2448      <varlistentry id="stats.arenas.i.lruns.j.ndalloc">
2449        <term>
2450          <mallctl>stats.arenas.&lt;i&gt;.lruns.&lt;j&gt;.ndalloc</mallctl>
2451          (<type>uint64_t</type>)
2452          <literal>r-</literal>
2453          [<option>--enable-stats</option>]
2454        </term>
2455        <listitem><para>Cumulative number of deallocation requests for this
2456        size class served directly by the arena.</para></listitem>
2457      </varlistentry>
2458
2459      <varlistentry id="stats.arenas.i.lruns.j.nrequests">
2460        <term>
2461          <mallctl>stats.arenas.&lt;i&gt;.lruns.&lt;j&gt;.nrequests</mallctl>
2462          (<type>uint64_t</type>)
2463          <literal>r-</literal>
2464          [<option>--enable-stats</option>]
2465        </term>
2466        <listitem><para>Cumulative number of allocation requests for this size
2467        class.</para></listitem>
2468      </varlistentry>
2469
2470      <varlistentry id="stats.arenas.i.lruns.j.curruns">
2471        <term>
2472          <mallctl>stats.arenas.&lt;i&gt;.lruns.&lt;j&gt;.curruns</mallctl>
2473          (<type>size_t</type>)
2474          <literal>r-</literal>
2475          [<option>--enable-stats</option>]
2476        </term>
2477        <listitem><para>Current number of runs for this size class.
2478        </para></listitem>
2479      </varlistentry>
2480
2481      <varlistentry id="stats.arenas.i.hchunks.j.nmalloc">
2482        <term>
2483          <mallctl>stats.arenas.&lt;i&gt;.hchunks.&lt;j&gt;.nmalloc</mallctl>
2484          (<type>uint64_t</type>)
2485          <literal>r-</literal>
2486          [<option>--enable-stats</option>]
2487        </term>
2488        <listitem><para>Cumulative number of allocation requests for this size
2489        class served directly by the arena.</para></listitem>
2490      </varlistentry>
2491
2492      <varlistentry id="stats.arenas.i.hchunks.j.ndalloc">
2493        <term>
2494          <mallctl>stats.arenas.&lt;i&gt;.hchunks.&lt;j&gt;.ndalloc</mallctl>
2495          (<type>uint64_t</type>)
2496          <literal>r-</literal>
2497          [<option>--enable-stats</option>]
2498        </term>
2499        <listitem><para>Cumulative number of deallocation requests for this
2500        size class served directly by the arena.</para></listitem>
2501      </varlistentry>
2502
2503      <varlistentry id="stats.arenas.i.hchunks.j.nrequests">
2504        <term>
2505          <mallctl>stats.arenas.&lt;i&gt;.hchunks.&lt;j&gt;.nrequests</mallctl>
2506          (<type>uint64_t</type>)
2507          <literal>r-</literal>
2508          [<option>--enable-stats</option>]
2509        </term>
2510        <listitem><para>Cumulative number of allocation requests for this size
2511        class.</para></listitem>
2512      </varlistentry>
2513
2514      <varlistentry id="stats.arenas.i.hchunks.j.curhchunks">
2515        <term>
2516          <mallctl>stats.arenas.&lt;i&gt;.hchunks.&lt;j&gt;.curhchunks</mallctl>
2517          (<type>size_t</type>)
2518          <literal>r-</literal>
2519          [<option>--enable-stats</option>]
2520        </term>
2521        <listitem><para>Current number of huge allocations for this size class.
2522        </para></listitem>
2523      </varlistentry>
2524    </variablelist>
2525  </refsect1>
2526  <refsect1 id="debugging_malloc_problems">
2527    <title>DEBUGGING MALLOC PROBLEMS</title>
2528    <para>When debugging, it is a good idea to configure/build jemalloc with
2529    the <option>--enable-debug</option> and <option>--enable-fill</option>
2530    options, and recompile the program with suitable options and symbols for
2531    debugger support.  When so configured, jemalloc incorporates a wide variety
2532    of run-time assertions that catch application errors such as double-free,
2533    write-after-free, etc.</para>
2534
2535    <para>Programs often accidentally depend on &ldquo;uninitialized&rdquo;
2536    memory actually being filled with zero bytes.  Junk filling
2537    (see the <link linkend="opt.junk"><mallctl>opt.junk</mallctl></link>
2538    option) tends to expose such bugs in the form of obviously incorrect
2539    results and/or coredumps.  Conversely, zero
2540    filling (see the <link
2541    linkend="opt.zero"><mallctl>opt.zero</mallctl></link> option) eliminates
2542    the symptoms of such bugs.  Between these two options, it is usually
2543    possible to quickly detect, diagnose, and eliminate such bugs.</para>
2544
2545    <para>This implementation does not provide much detail about the problems
2546    it detects, because the performance impact for storing such information
2547    would be prohibitive.  However, jemalloc does integrate with the most
2548    excellent <ulink url="http://valgrind.org/">Valgrind</ulink> tool if the
2549    <option>--enable-valgrind</option> configuration option is enabled.</para>
2550  </refsect1>
2551  <refsect1 id="diagnostic_messages">
2552    <title>DIAGNOSTIC MESSAGES</title>
2553    <para>If any of the memory allocation/deallocation functions detect an
2554    error or warning condition, a message will be printed to file descriptor
2555    <constant>STDERR_FILENO</constant>.  Errors will result in the process
2556    dumping core.  If the <link
2557    linkend="opt.abort"><mallctl>opt.abort</mallctl></link> option is set, most
2558    warnings are treated as errors.</para>
2559
2560    <para>The <varname>malloc_message</varname> variable allows the programmer
2561    to override the function which emits the text strings forming the errors
2562    and warnings if for some reason the <constant>STDERR_FILENO</constant> file
2563    descriptor is not suitable for this.
2564    <function>malloc_message<parameter/></function> takes the
2565    <parameter>cbopaque</parameter> pointer argument that is
2566    <constant>NULL</constant> unless overridden by the arguments in a call to
2567    <function>malloc_stats_print<parameter/></function>, followed by a string
2568    pointer.  Please note that doing anything which tries to allocate memory in
2569    this function is likely to result in a crash or deadlock.</para>
2570
2571    <para>All messages are prefixed by
2572    &ldquo;<computeroutput>&lt;jemalloc&gt;: </computeroutput>&rdquo;.</para>
2573  </refsect1>
2574  <refsect1 id="return_values">
2575    <title>RETURN VALUES</title>
2576    <refsect2>
2577      <title>Standard API</title>
2578      <para>The <function>malloc<parameter/></function> and
2579      <function>calloc<parameter/></function> functions return a pointer to the
2580      allocated memory if successful; otherwise a <constant>NULL</constant>
2581      pointer is returned and <varname>errno</varname> is set to
2582      <errorname>ENOMEM</errorname>.</para>
2583
2584      <para>The <function>posix_memalign<parameter/></function> function
2585      returns the value 0 if successful; otherwise it returns an error value.
2586      The <function>posix_memalign<parameter/></function> function will fail
2587      if:
2588        <variablelist>
2589          <varlistentry>
2590            <term><errorname>EINVAL</errorname></term>
2591
2592            <listitem><para>The <parameter>alignment</parameter> parameter is
2593            not a power of 2 at least as large as
2594            <code language="C">sizeof(<type>void *</type>)</code>.
2595            </para></listitem>
2596          </varlistentry>
2597          <varlistentry>
2598            <term><errorname>ENOMEM</errorname></term>
2599
2600            <listitem><para>Memory allocation error.</para></listitem>
2601          </varlistentry>
2602        </variablelist>
2603      </para>
2604
2605      <para>The <function>aligned_alloc<parameter/></function> function returns
2606      a pointer to the allocated memory if successful; otherwise a
2607      <constant>NULL</constant> pointer is returned and
2608      <varname>errno</varname> is set.  The
2609      <function>aligned_alloc<parameter/></function> function will fail if:
2610        <variablelist>
2611          <varlistentry>
2612            <term><errorname>EINVAL</errorname></term>
2613
2614            <listitem><para>The <parameter>alignment</parameter> parameter is
2615            not a power of 2.
2616            </para></listitem>
2617          </varlistentry>
2618          <varlistentry>
2619            <term><errorname>ENOMEM</errorname></term>
2620
2621            <listitem><para>Memory allocation error.</para></listitem>
2622          </varlistentry>
2623        </variablelist>
2624      </para>
2625
2626      <para>The <function>realloc<parameter/></function> function returns a
2627      pointer, possibly identical to <parameter>ptr</parameter>, to the
2628      allocated memory if successful; otherwise a <constant>NULL</constant>
2629      pointer is returned, and <varname>errno</varname> is set to
2630      <errorname>ENOMEM</errorname> if the error was the result of an
2631      allocation failure.  The <function>realloc<parameter/></function>
2632      function always leaves the original buffer intact when an error occurs.
2633      </para>
2634
2635      <para>The <function>free<parameter/></function> function returns no
2636      value.</para>
2637    </refsect2>
2638    <refsect2>
2639      <title>Non-standard API</title>
2640      <para>The <function>mallocx<parameter/></function> and
2641      <function>rallocx<parameter/></function> functions return a pointer to
2642      the allocated memory if successful; otherwise a <constant>NULL</constant>
2643      pointer is returned to indicate insufficient contiguous memory was
2644      available to service the allocation request.  </para>
2645
2646      <para>The <function>xallocx<parameter/></function> function returns the
2647      real size of the resulting resized allocation pointed to by
2648      <parameter>ptr</parameter>, which is a value less than
2649      <parameter>size</parameter> if the allocation could not be adequately
2650      grown in place.  </para>
2651
2652      <para>The <function>sallocx<parameter/></function> function returns the
2653      real size of the allocation pointed to by <parameter>ptr</parameter>.
2654      </para>
2655
2656      <para>The <function>nallocx<parameter/></function> returns the real size
2657      that would result from a successful equivalent
2658      <function>mallocx<parameter/></function> function call, or zero if
2659      insufficient memory is available to perform the size computation.  </para>
2660
2661      <para>The <function>mallctl<parameter/></function>,
2662      <function>mallctlnametomib<parameter/></function>, and
2663      <function>mallctlbymib<parameter/></function> functions return 0 on
2664      success; otherwise they return an error value.  The functions will fail
2665      if:
2666        <variablelist>
2667          <varlistentry>
2668            <term><errorname>EINVAL</errorname></term>
2669
2670            <listitem><para><parameter>newp</parameter> is not
2671            <constant>NULL</constant>, and <parameter>newlen</parameter> is too
2672            large or too small.  Alternatively, <parameter>*oldlenp</parameter>
2673            is too large or too small; in this case as much data as possible
2674            are read despite the error.</para></listitem>
2675          </varlistentry>
2676          <varlistentry>
2677            <term><errorname>ENOENT</errorname></term>
2678
2679            <listitem><para><parameter>name</parameter> or
2680            <parameter>mib</parameter> specifies an unknown/invalid
2681            value.</para></listitem>
2682          </varlistentry>
2683          <varlistentry>
2684            <term><errorname>EPERM</errorname></term>
2685
2686            <listitem><para>Attempt to read or write void value, or attempt to
2687            write read-only value.</para></listitem>
2688          </varlistentry>
2689          <varlistentry>
2690            <term><errorname>EAGAIN</errorname></term>
2691
2692            <listitem><para>A memory allocation failure
2693            occurred.</para></listitem>
2694          </varlistentry>
2695          <varlistentry>
2696            <term><errorname>EFAULT</errorname></term>
2697
2698            <listitem><para>An interface with side effects failed in some way
2699            not directly related to <function>mallctl*<parameter/></function>
2700            read/write processing.</para></listitem>
2701          </varlistentry>
2702        </variablelist>
2703      </para>
2704
2705      <para>The <function>malloc_usable_size<parameter/></function> function
2706      returns the usable size of the allocation pointed to by
2707      <parameter>ptr</parameter>.  </para>
2708    </refsect2>
2709  </refsect1>
2710  <refsect1 id="environment">
2711    <title>ENVIRONMENT</title>
2712    <para>The following environment variable affects the execution of the
2713    allocation functions:
2714      <variablelist>
2715        <varlistentry>
2716          <term><envar>MALLOC_CONF</envar></term>
2717
2718          <listitem><para>If the environment variable
2719          <envar>MALLOC_CONF</envar> is set, the characters it contains
2720          will be interpreted as options.</para></listitem>
2721        </varlistentry>
2722      </variablelist>
2723    </para>
2724  </refsect1>
2725  <refsect1 id="examples">
2726    <title>EXAMPLES</title>
2727    <para>To dump core whenever a problem occurs:
2728      <screen>ln -s 'abort:true' /etc/malloc.conf</screen>
2729    </para>
2730    <para>To specify in the source a chunk size that is 16 MiB:
2731      <programlisting language="C"><![CDATA[
2732malloc_conf = "lg_chunk:24";]]></programlisting></para>
2733  </refsect1>
2734  <refsect1 id="see_also">
2735    <title>SEE ALSO</title>
2736    <para><citerefentry><refentrytitle>madvise</refentrytitle>
2737    <manvolnum>2</manvolnum></citerefentry>,
2738    <citerefentry><refentrytitle>mmap</refentrytitle>
2739    <manvolnum>2</manvolnum></citerefentry>,
2740    <citerefentry><refentrytitle>sbrk</refentrytitle>
2741    <manvolnum>2</manvolnum></citerefentry>,
2742    <citerefentry><refentrytitle>utrace</refentrytitle>
2743    <manvolnum>2</manvolnum></citerefentry>,
2744    <citerefentry><refentrytitle>alloca</refentrytitle>
2745    <manvolnum>3</manvolnum></citerefentry>,
2746    <citerefentry><refentrytitle>atexit</refentrytitle>
2747    <manvolnum>3</manvolnum></citerefentry>,
2748    <citerefentry><refentrytitle>getpagesize</refentrytitle>
2749    <manvolnum>3</manvolnum></citerefentry></para>
2750  </refsect1>
2751  <refsect1 id="standards">
2752    <title>STANDARDS</title>
2753    <para>The <function>malloc<parameter/></function>,
2754    <function>calloc<parameter/></function>,
2755    <function>realloc<parameter/></function>, and
2756    <function>free<parameter/></function> functions conform to ISO/IEC
2757    9899:1990 (&ldquo;ISO C90&rdquo;).</para>
2758
2759    <para>The <function>posix_memalign<parameter/></function> function conforms
2760    to IEEE Std 1003.1-2001 (&ldquo;POSIX.1&rdquo;).</para>
2761  </refsect1>
2762</refentry>
2763