1<?xml version="1.0" encoding="utf-8"?> 2<html><head><title>JEMALLOC</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"/></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry"><a name="idm140689766630352"/><div class="titlepage"/><div class="refnamediv"><h2>Name</h2><p>jemalloc — general purpose memory allocation functions</p></div><div class="refsect1"><a name="library"/><h2>LIBRARY</h2><p>This manual describes jemalloc 5.1.0-0-g61efbda7098de6fe64c362d309824864308c36d4. More information 3 can be found at the <a class="ulink" href="http://jemalloc.net/" target="_top">jemalloc website</a>.</p></div><div class="refsynopsisdiv"><h2>SYNOPSIS</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include <<code class="filename">jemalloc/jemalloc.h</code>></pre><div class="refsect2"><a name="idm140689767408528"/><h3>Standard API</h3><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void *<b class="fsfunc">malloc</b>(</code></td><td>size_t <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void *<b class="fsfunc">calloc</b>(</code></td><td>size_t <var class="pdparam">number</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">posix_memalign</b>(</code></td><td>void **<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">alignment</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void *<b class="fsfunc">aligned_alloc</b>(</code></td><td>size_t <var class="pdparam">alignment</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void *<b class="fsfunc">realloc</b>(</code></td><td>void *<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">free</b>(</code></td><td>void *<var class="pdparam">ptr</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div><div class="refsect2"><a name="idm140689770688880"/><h3>Non-standard API</h3><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void *<b class="fsfunc">mallocx</b>(</code></td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void *<b class="fsfunc">rallocx</b>(</code></td><td>void *<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">size_t <b class="fsfunc">xallocx</b>(</code></td><td>void *<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">extra</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">size_t <b class="fsfunc">sallocx</b>(</code></td><td>void *<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">dallocx</b>(</code></td><td>void *<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">sdallocx</b>(</code></td><td>void *<var class="pdparam">ptr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">size_t <b class="fsfunc">nallocx</b>(</code></td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">mallctl</b>(</code></td><td>const char *<var class="pdparam">name</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">oldp</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">oldlenp</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">newp</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">newlen</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">mallctlnametomib</b>(</code></td><td>const char *<var class="pdparam">name</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">mibp</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">miblenp</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">mallctlbymib</b>(</code></td><td>const size_t *<var class="pdparam">mib</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">miblen</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">oldp</var>, </td></tr><tr><td> </td><td>size_t *<var class="pdparam">oldlenp</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">newp</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">newlen</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">malloc_stats_print</b>(</code></td><td>void <var class="pdparam">(*write_cb)</var> 4 <code>(</code>void *, const char *<code>)</code> 5 , </td></tr><tr><td> </td><td>void *<var class="pdparam">cbopaque</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">opts</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">size_t <b class="fsfunc">malloc_usable_size</b>(</code></td><td>const void *<var class="pdparam">ptr</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">(*malloc_message)</b>(</code></td><td>void *<var class="pdparam">cbopaque</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">s</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><p><span class="type">const char *</span><code class="varname">malloc_conf</code>;</p></div></div></div><div class="refsect1"><a name="description"/><h2>DESCRIPTION</h2><div class="refsect2"><a name="idm140689765494448"/><h3>Standard API</h3><p>The <code class="function">malloc()</code> function allocates 6 <em class="parameter"><code>size</code></em> bytes of uninitialized memory. The allocated 7 space is suitably aligned (after possible pointer coercion) for storage 8 of any type of object.</p><p>The <code class="function">calloc()</code> function allocates 9 space for <em class="parameter"><code>number</code></em> objects, each 10 <em class="parameter"><code>size</code></em> bytes in length. The result is identical to 11 calling <code class="function">malloc()</code> with an argument of 12 <em class="parameter"><code>number</code></em> * <em class="parameter"><code>size</code></em>, with the 13 exception that the allocated memory is explicitly initialized to zero 14 bytes.</p><p>The <code class="function">posix_memalign()</code> function 15 allocates <em class="parameter"><code>size</code></em> bytes of memory such that the 16 allocation's base address is a multiple of 17 <em class="parameter"><code>alignment</code></em>, and returns the allocation in the value 18 pointed to by <em class="parameter"><code>ptr</code></em>. The requested 19 <em class="parameter"><code>alignment</code></em> must be a power of 2 at least as large as 20 <code class="code">sizeof(<span class="type">void *</span>)</code>.</p><p>The <code class="function">aligned_alloc()</code> function 21 allocates <em class="parameter"><code>size</code></em> bytes of memory such that the 22 allocation's base address is a multiple of 23 <em class="parameter"><code>alignment</code></em>. The requested 24 <em class="parameter"><code>alignment</code></em> must be a power of 2. Behavior is 25 undefined if <em class="parameter"><code>size</code></em> is not an integral multiple of 26 <em class="parameter"><code>alignment</code></em>.</p><p>The <code class="function">realloc()</code> function changes the 27 size of the previously allocated memory referenced by 28 <em class="parameter"><code>ptr</code></em> to <em class="parameter"><code>size</code></em> bytes. The 29 contents of the memory are unchanged up to the lesser of the new and old 30 sizes. If the new size is larger, the contents of the newly allocated 31 portion of the memory are undefined. Upon success, the memory referenced 32 by <em class="parameter"><code>ptr</code></em> is freed and a pointer to the newly 33 allocated memory is returned. Note that 34 <code class="function">realloc()</code> may move the memory allocation, 35 resulting in a different return value than <em class="parameter"><code>ptr</code></em>. 36 If <em class="parameter"><code>ptr</code></em> is <code class="constant">NULL</code>, the 37 <code class="function">realloc()</code> function behaves identically to 38 <code class="function">malloc()</code> for the specified size.</p><p>The <code class="function">free()</code> function causes the 39 allocated memory referenced by <em class="parameter"><code>ptr</code></em> to be made 40 available for future allocations. If <em class="parameter"><code>ptr</code></em> is 41 <code class="constant">NULL</code>, no action occurs.</p></div><div class="refsect2"><a name="idm140689765469472"/><h3>Non-standard API</h3><p>The <code class="function">mallocx()</code>, 42 <code class="function">rallocx()</code>, 43 <code class="function">xallocx()</code>, 44 <code class="function">sallocx()</code>, 45 <code class="function">dallocx()</code>, 46 <code class="function">sdallocx()</code>, and 47 <code class="function">nallocx()</code> functions all have a 48 <em class="parameter"><code>flags</code></em> argument that can be used to specify 49 options. The functions only check the options that are contextually 50 relevant. Use bitwise or (<code class="code">|</code>) operations to 51 specify one or more of the following: 52 </p><div class="variablelist"><dl class="variablelist"><dt><a name="MALLOCX_LG_ALIGN"/><span class="term"><code class="constant">MALLOCX_LG_ALIGN(<em class="parameter"><code>la</code></em>) 53 </code></span></dt><dd><p>Align the memory allocation to start at an address 54 that is a multiple of <code class="code">(1 << 55 <em class="parameter"><code>la</code></em>)</code>. This macro does not validate 56 that <em class="parameter"><code>la</code></em> is within the valid 57 range.</p></dd><dt><a name="MALLOCX_ALIGN"/><span class="term"><code class="constant">MALLOCX_ALIGN(<em class="parameter"><code>a</code></em>) 58 </code></span></dt><dd><p>Align the memory allocation to start at an address 59 that is a multiple of <em class="parameter"><code>a</code></em>, where 60 <em class="parameter"><code>a</code></em> is a power of two. This macro does not 61 validate that <em class="parameter"><code>a</code></em> is a power of 2. 62 </p></dd><dt><a name="MALLOCX_ZERO"/><span class="term"><code class="constant">MALLOCX_ZERO</code></span></dt><dd><p>Initialize newly allocated memory to contain zero 63 bytes. In the growing reallocation case, the real size prior to 64 reallocation defines the boundary between untouched bytes and those 65 that are initialized to contain zero bytes. If this macro is 66 absent, newly allocated memory is uninitialized.</p></dd><dt><a name="MALLOCX_TCACHE"/><span class="term"><code class="constant">MALLOCX_TCACHE(<em class="parameter"><code>tc</code></em>) 67 </code></span></dt><dd><p>Use the thread-specific cache (tcache) specified by 68 the identifier <em class="parameter"><code>tc</code></em>, which must have been 69 acquired via the <a class="link" href="#tcache.create"><quote><code class="mallctl">tcache.create</code></quote></a> 70 mallctl. This macro does not validate that 71 <em class="parameter"><code>tc</code></em> specifies a valid 72 identifier.</p></dd><dt><a name="MALLOC_TCACHE_NONE"/><span class="term"><code class="constant">MALLOCX_TCACHE_NONE</code></span></dt><dd><p>Do not use a thread-specific cache (tcache). Unless 73 <code class="constant">MALLOCX_TCACHE(<em class="parameter"><code>tc</code></em>)</code> or 74 <code class="constant">MALLOCX_TCACHE_NONE</code> is specified, an 75 automatically managed tcache will be used under many circumstances. 76 This macro cannot be used in the same <em class="parameter"><code>flags</code></em> 77 argument as 78 <code class="constant">MALLOCX_TCACHE(<em class="parameter"><code>tc</code></em>)</code>.</p></dd><dt><a name="MALLOCX_ARENA"/><span class="term"><code class="constant">MALLOCX_ARENA(<em class="parameter"><code>a</code></em>) 79 </code></span></dt><dd><p>Use the arena specified by the index 80 <em class="parameter"><code>a</code></em>. This macro has no effect for regions that 81 were allocated via an arena other than the one specified. This 82 macro does not validate that <em class="parameter"><code>a</code></em> specifies an 83 arena index in the valid range.</p></dd></dl></div><p> 84 </p><p>The <code class="function">mallocx()</code> function allocates at 85 least <em class="parameter"><code>size</code></em> bytes of memory, and returns a pointer 86 to the base address of the allocation. Behavior is undefined if 87 <em class="parameter"><code>size</code></em> is <code class="constant">0</code>.</p><p>The <code class="function">rallocx()</code> function resizes the 88 allocation at <em class="parameter"><code>ptr</code></em> to be at least 89 <em class="parameter"><code>size</code></em> bytes, and returns a pointer to the base 90 address of the resulting allocation, which may or may not have moved from 91 its original location. Behavior is undefined if 92 <em class="parameter"><code>size</code></em> is <code class="constant">0</code>.</p><p>The <code class="function">xallocx()</code> function resizes the 93 allocation at <em class="parameter"><code>ptr</code></em> in place to be at least 94 <em class="parameter"><code>size</code></em> bytes, and returns the real size of the 95 allocation. If <em class="parameter"><code>extra</code></em> is non-zero, an attempt is 96 made to resize the allocation to be at least <code class="code">(<em class="parameter"><code>size</code></em> + 97 <em class="parameter"><code>extra</code></em>)</code> bytes, though inability to allocate 98 the extra byte(s) will not by itself result in failure to resize. 99 Behavior is undefined if <em class="parameter"><code>size</code></em> is 100 <code class="constant">0</code>, or if <code class="code">(<em class="parameter"><code>size</code></em> + <em class="parameter"><code>extra</code></em> 101 > <code class="constant">SIZE_T_MAX</code>)</code>.</p><p>The <code class="function">sallocx()</code> function returns the 102 real size of the allocation at <em class="parameter"><code>ptr</code></em>.</p><p>The <code class="function">dallocx()</code> function causes the 103 memory referenced by <em class="parameter"><code>ptr</code></em> to be made available for 104 future allocations.</p><p>The <code class="function">sdallocx()</code> function is an 105 extension of <code class="function">dallocx()</code> with a 106 <em class="parameter"><code>size</code></em> parameter to allow the caller to pass in the 107 allocation size as an optimization. The minimum valid input size is the 108 original requested size of the allocation, and the maximum valid input 109 size is the corresponding value returned by 110 <code class="function">nallocx()</code> or 111 <code class="function">sallocx()</code>.</p><p>The <code class="function">nallocx()</code> function allocates no 112 memory, but it performs the same size computation as the 113 <code class="function">mallocx()</code> function, and returns the real 114 size of the allocation that would result from the equivalent 115 <code class="function">mallocx()</code> function call, or 116 <code class="constant">0</code> if the inputs exceed the maximum supported size 117 class and/or alignment. Behavior is undefined if 118 <em class="parameter"><code>size</code></em> is <code class="constant">0</code>.</p><p>The <code class="function">mallctl()</code> function provides a 119 general interface for introspecting the memory allocator, as well as 120 setting modifiable parameters and triggering actions. The 121 period-separated <em class="parameter"><code>name</code></em> argument specifies a 122 location in a tree-structured namespace; see the <a class="xref" href="#mallctl_namespace" title="MALLCTL NAMESPACE">MALLCTL NAMESPACE</a> section for 123 documentation on the tree contents. To read a value, pass a pointer via 124 <em class="parameter"><code>oldp</code></em> to adequate space to contain the value, and a 125 pointer to its length via <em class="parameter"><code>oldlenp</code></em>; otherwise pass 126 <code class="constant">NULL</code> and <code class="constant">NULL</code>. Similarly, to 127 write a value, pass a pointer to the value via 128 <em class="parameter"><code>newp</code></em>, and its length via 129 <em class="parameter"><code>newlen</code></em>; otherwise pass <code class="constant">NULL</code> 130 and <code class="constant">0</code>.</p><p>The <code class="function">mallctlnametomib()</code> function 131 provides a way to avoid repeated name lookups for applications that 132 repeatedly query the same portion of the namespace, by translating a name 133 to a <span class="quote">“<span class="quote">Management Information Base</span>”</span> (MIB) that can be passed 134 repeatedly to <code class="function">mallctlbymib()</code>. Upon 135 successful return from <code class="function">mallctlnametomib()</code>, 136 <em class="parameter"><code>mibp</code></em> contains an array of 137 <em class="parameter"><code>*miblenp</code></em> integers, where 138 <em class="parameter"><code>*miblenp</code></em> is the lesser of the number of components 139 in <em class="parameter"><code>name</code></em> and the input value of 140 <em class="parameter"><code>*miblenp</code></em>. Thus it is possible to pass a 141 <em class="parameter"><code>*miblenp</code></em> that is smaller than the number of 142 period-separated name components, which results in a partial MIB that can 143 be used as the basis for constructing a complete MIB. For name 144 components that are integers (e.g. the 2 in 145 <a class="link" href="#arenas.bin.i.size"><quote><code class="mallctl">arenas.bin.2.size</code></quote></a>), 146 the corresponding MIB component will always be that integer. Therefore, 147 it is legitimate to construct code like the following: </p><pre class="programlisting"> 148unsigned nbins, i; 149size_t mib[4]; 150size_t len, miblen; 151 152len = sizeof(nbins); 153mallctl("arenas.nbins", &nbins, &len, NULL, 0); 154 155miblen = 4; 156mallctlnametomib("arenas.bin.0.size", mib, &miblen); 157for (i = 0; i < nbins; i++) { 158 size_t bin_size; 159 160 mib[2] = i; 161 len = sizeof(bin_size); 162 mallctlbymib(mib, miblen, (void *)&bin_size, &len, NULL, 0); 163 /* Do something with bin_size... */ 164}</pre><dt><a name="malloc_stats_print_opts"/></dt><dd/><p>The <code class="function">malloc_stats_print()</code> function writes 165 summary statistics via the <em class="parameter"><code>write_cb</code></em> callback 166 function pointer and <em class="parameter"><code>cbopaque</code></em> data passed to 167 <em class="parameter"><code>write_cb</code></em>, or <code class="function">malloc_message()</code> 168 if <em class="parameter"><code>write_cb</code></em> is <code class="constant">NULL</code>. The 169 statistics are presented in human-readable form unless <span class="quote">“<span class="quote">J</span>”</span> is 170 specified as a character within the <em class="parameter"><code>opts</code></em> string, in 171 which case the statistics are presented in <a class="ulink" href="http://www.json.org/" target="_top">JSON format</a>. This function can be 172 called repeatedly. General information that never changes during 173 execution can be omitted by specifying <span class="quote">“<span class="quote">g</span>”</span> as a character 174 within the <em class="parameter"><code>opts</code></em> string. Note that 175 <code class="function">malloc_message()</code> uses the 176 <code class="function">mallctl*()</code> functions internally, so inconsistent 177 statistics can be reported if multiple threads use these functions 178 simultaneously. If <code class="option">--enable-stats</code> is specified during 179 configuration, <span class="quote">“<span class="quote">m</span>”</span>, <span class="quote">“<span class="quote">d</span>”</span>, and <span class="quote">“<span class="quote">a</span>”</span> 180 can be specified to omit merged arena, destroyed merged arena, and per 181 arena statistics, respectively; <span class="quote">“<span class="quote">b</span>”</span> and <span class="quote">“<span class="quote">l</span>”</span> can 182 be specified to omit per size class statistics for bins and large objects, 183 respectively; <span class="quote">“<span class="quote">x</span>”</span> can be specified to omit all mutex 184 statistics. Unrecognized characters are silently ignored. Note that 185 thread caching may prevent some statistics from being completely up to 186 date, since extra locking would be required to merge counters that track 187 thread cache operations.</p><p>The <code class="function">malloc_usable_size()</code> function 188 returns the usable size of the allocation pointed to by 189 <em class="parameter"><code>ptr</code></em>. The return value may be larger than the size 190 that was requested during allocation. The 191 <code class="function">malloc_usable_size()</code> function is not a 192 mechanism for in-place <code class="function">realloc()</code>; rather 193 it is provided solely as a tool for introspection purposes. Any 194 discrepancy between the requested allocation size and the size reported 195 by <code class="function">malloc_usable_size()</code> should not be 196 depended on, since such behavior is entirely implementation-dependent. 197 </p></div></div><div class="refsect1"><a name="tuning"/><h2>TUNING</h2><p>Once, when the first call is made to one of the memory allocation 198 routines, the allocator initializes its internals based in part on various 199 options that can be specified at compile- or run-time.</p><p>The string specified via <code class="option">--with-malloc-conf</code>, the 200 string pointed to by the global variable <code class="varname">malloc_conf</code>, the 201 <span class="quote">“<span class="quote">name</span>”</span> of the file referenced by the symbolic link named 202 <code class="filename">/etc/malloc.conf</code>, and the value of the 203 environment variable <code class="envar">MALLOC_CONF</code>, will be interpreted, in 204 that order, from left to right as options. Note that 205 <code class="varname">malloc_conf</code> may be read before 206 <code class="function">main()</code> is entered, so the declaration of 207 <code class="varname">malloc_conf</code> should specify an initializer that contains 208 the final value to be read by jemalloc. <code class="option">--with-malloc-conf</code> 209 and <code class="varname">malloc_conf</code> are compile-time mechanisms, whereas 210 <code class="filename">/etc/malloc.conf</code> and 211 <code class="envar">MALLOC_CONF</code> can be safely set any time prior to program 212 invocation.</p><p>An options string is a comma-separated list of option:value pairs. 213 There is one key corresponding to each <a class="link" href="#opt.abort"><quote><code class="mallctl">opt.*</code></quote></a> mallctl (see the <a class="xref" href="#mallctl_namespace" title="MALLCTL NAMESPACE">MALLCTL NAMESPACE</a> section for options 214 documentation). For example, <code class="literal">abort:true,narenas:1</code> sets 215 the <a class="link" href="#opt.abort"><quote><code class="mallctl">opt.abort</code></quote></a> and <a class="link" href="#opt.narenas"><quote><code class="mallctl">opt.narenas</code></quote></a> options. Some 216 options have boolean values (true/false), others have integer values (base 217 8, 10, or 16, depending on prefix), and yet others have raw string 218 values.</p></div><div class="refsect1"><a name="implementation_notes"/><h2>IMPLEMENTATION NOTES</h2><p>Traditionally, allocators have used 219 <span class="citerefentry"><span class="refentrytitle">sbrk</span>(2)</span> to obtain memory, which is 220 suboptimal for several reasons, including race conditions, increased 221 fragmentation, and artificial limitations on maximum usable memory. If 222 <span class="citerefentry"><span class="refentrytitle">sbrk</span>(2)</span> is supported by the operating 223 system, this allocator uses both 224 <span class="citerefentry"><span class="refentrytitle">mmap</span>(2)</span> and 225 <span class="citerefentry"><span class="refentrytitle">sbrk</span>(2)</span>, in that order of preference; 226 otherwise only <span class="citerefentry"><span class="refentrytitle">mmap</span>(2)</span> is used.</p><p>This allocator uses multiple arenas in order to reduce lock 227 contention for threaded programs on multi-processor systems. This works 228 well with regard to threading scalability, but incurs some costs. There is 229 a small fixed per-arena overhead, and additionally, arenas manage memory 230 completely independently of each other, which means a small fixed increase 231 in overall memory fragmentation. These overheads are not generally an 232 issue, given the number of arenas normally used. Note that using 233 substantially more arenas than the default is not likely to improve 234 performance, mainly due to reduced cache performance. However, it may make 235 sense to reduce the number of arenas if an application does not make much 236 use of the allocation functions.</p><p>In addition to multiple arenas, this allocator supports 237 thread-specific caching, in order to make it possible to completely avoid 238 synchronization for most allocation requests. Such caching allows very fast 239 allocation in the common case, but it increases memory usage and 240 fragmentation, since a bounded number of objects can remain allocated in 241 each thread cache.</p><p>Memory is conceptually broken into extents. Extents are always 242 aligned to multiples of the page size. This alignment makes it possible to 243 find metadata for user objects quickly. User objects are broken into two 244 categories according to size: small and large. Contiguous small objects 245 comprise a slab, which resides within a single extent, whereas large objects 246 each have their own extents backing them.</p><p>Small objects are managed in groups by slabs. Each slab maintains 247 a bitmap to track which regions are in use. Allocation requests that are no 248 more than half the quantum (8 or 16, depending on architecture) are rounded 249 up to the nearest power of two that is at least <code class="code">sizeof(<span class="type">double</span>)</code>. All other object size 250 classes are multiples of the quantum, spaced such that there are four size 251 classes for each doubling in size, which limits internal fragmentation to 252 approximately 20% for all but the smallest size classes. Small size classes 253 are smaller than four times the page size, and large size classes extend 254 from four times the page size up to the largest size class that does not 255 exceed <code class="constant">PTRDIFF_MAX</code>.</p><p>Allocations are packed tightly together, which can be an issue for 256 multi-threaded applications. If you need to assure that allocations do not 257 suffer from cacheline sharing, round your allocation requests up to the 258 nearest multiple of the cacheline size, or specify cacheline alignment when 259 allocating.</p><p>The <code class="function">realloc()</code>, 260 <code class="function">rallocx()</code>, and 261 <code class="function">xallocx()</code> functions may resize allocations 262 without moving them under limited circumstances. Unlike the 263 <code class="function">*allocx()</code> API, the standard API does not 264 officially round up the usable size of an allocation to the nearest size 265 class, so technically it is necessary to call 266 <code class="function">realloc()</code> to grow e.g. a 9-byte allocation to 267 16 bytes, or shrink a 16-byte allocation to 9 bytes. Growth and shrinkage 268 trivially succeeds in place as long as the pre-size and post-size both round 269 up to the same size class. No other API guarantees are made regarding 270 in-place resizing, but the current implementation also tries to resize large 271 allocations in place, as long as the pre-size and post-size are both large. 272 For shrinkage to succeed, the extent allocator must support splitting (see 273 <a class="link" href="#arena.i.extent_hooks"><quote><code class="mallctl">arena.<i>.extent_hooks</code></quote></a>). 274 Growth only succeeds if the trailing memory is currently available, and the 275 extent allocator supports merging.</p><p>Assuming 4 KiB pages and a 16-byte quantum on a 64-bit system, the 276 size classes in each category are as shown in <a class="xref" href="#size_classes" title="Table 1. Size classes">Table 1</a>.</p><div class="table"><a name="size_classes"/><p class="title"><b>Table 1. Size classes</b></p><div class="table-contents"><table summary="Size classes" border="1"><colgroup><col align="left" class="c1"/><col align="right" class="c2"/><col align="left" class="c3"/></colgroup><thead><tr><th align="left">Category</th><th align="right">Spacing</th><th align="left">Size</th></tr></thead><tbody><tr><td rowspan="9" align="left">Small</td><td align="right">lg</td><td align="left">[8]</td></tr><tr><td align="right">16</td><td align="left">[16, 32, 48, 64, 80, 96, 112, 128]</td></tr><tr><td align="right">32</td><td align="left">[160, 192, 224, 256]</td></tr><tr><td align="right">64</td><td align="left">[320, 384, 448, 512]</td></tr><tr><td align="right">128</td><td align="left">[640, 768, 896, 1024]</td></tr><tr><td align="right">256</td><td align="left">[1280, 1536, 1792, 2048]</td></tr><tr><td align="right">512</td><td align="left">[2560, 3072, 3584, 4096]</td></tr><tr><td align="right">1 KiB</td><td align="left">[5 KiB, 6 KiB, 7 KiB, 8 KiB]</td></tr><tr><td align="right">2 KiB</td><td align="left">[10 KiB, 12 KiB, 14 KiB]</td></tr><tr><td rowspan="16" align="left">Large</td><td align="right">2 KiB</td><td align="left">[16 KiB]</td></tr><tr><td align="right">4 KiB</td><td align="left">[20 KiB, 24 KiB, 28 KiB, 32 KiB]</td></tr><tr><td align="right">8 KiB</td><td align="left">[40 KiB, 48 KiB, 54 KiB, 64 KiB]</td></tr><tr><td align="right">16 KiB</td><td align="left">[80 KiB, 96 KiB, 112 KiB, 128 KiB]</td></tr><tr><td align="right">32 KiB</td><td align="left">[160 KiB, 192 KiB, 224 KiB, 256 KiB]</td></tr><tr><td align="right">64 KiB</td><td align="left">[320 KiB, 384 KiB, 448 KiB, 512 KiB]</td></tr><tr><td align="right">128 KiB</td><td align="left">[640 KiB, 768 KiB, 896 KiB, 1 MiB]</td></tr><tr><td align="right">256 KiB</td><td align="left">[1280 KiB, 1536 KiB, 1792 KiB, 2 MiB]</td></tr><tr><td align="right">512 KiB</td><td align="left">[2560 KiB, 3 MiB, 3584 KiB, 4 MiB]</td></tr><tr><td align="right">1 MiB</td><td align="left">[5 MiB, 6 MiB, 7 MiB, 8 MiB]</td></tr><tr><td align="right">2 MiB</td><td align="left">[10 MiB, 12 MiB, 14 MiB, 16 MiB]</td></tr><tr><td align="right">4 MiB</td><td align="left">[20 MiB, 24 MiB, 28 MiB, 32 MiB]</td></tr><tr><td align="right">8 MiB</td><td align="left">[40 MiB, 48 MiB, 56 MiB, 64 MiB]</td></tr><tr><td align="right">...</td><td align="left">...</td></tr><tr><td align="right">512 PiB</td><td align="left">[2560 PiB, 3 EiB, 3584 PiB, 4 EiB]</td></tr><tr><td align="right">1 EiB</td><td align="left">[5 EiB, 6 EiB, 7 EiB]</td></tr></tbody></table></div></div><br class="table-break"/></div><div class="refsect1"><a name="mallctl_namespace"/><h2>MALLCTL NAMESPACE</h2><p>The following names are defined in the namespace accessible via the 277 <code class="function">mallctl*()</code> functions. Value types are specified in 278 parentheses, their readable/writable statuses are encoded as 279 <code class="literal">rw</code>, <code class="literal">r-</code>, <code class="literal">-w</code>, or 280 <code class="literal">--</code>, and required build configuration flags follow, if 281 any. A name element encoded as <code class="literal"><i></code> or 282 <code class="literal"><j></code> indicates an integer component, where the 283 integer varies from 0 to some upper value that must be determined via 284 introspection. In the case of <quote><code class="mallctl">stats.arenas.<i>.*</code></quote> 285 and <quote><code class="mallctl">arena.<i>.{initialized,purge,decay,dss}</code></quote>, 286 <code class="literal"><i></code> equal to 287 <code class="constant">MALLCTL_ARENAS_ALL</code> can be used to operate on all arenas 288 or access the summation of statistics from all arenas; similarly 289 <code class="literal"><i></code> equal to 290 <code class="constant">MALLCTL_ARENAS_DESTROYED</code> can be used to access the 291 summation of statistics from all destroyed arenas. These constants can be 292 utilized either via <code class="function">mallctlnametomib()</code> followed by 293 <code class="function">mallctlbymib()</code>, or via code such as the following: 294 </p><pre class="programlisting"> 295#define STRINGIFY_HELPER(x) #x 296#define STRINGIFY(x) STRINGIFY_HELPER(x) 297 298mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".decay", 299 NULL, NULL, NULL, 0);</pre><p> 300 Take special note of the <a class="link" href="#epoch"><quote><code class="mallctl">epoch</code></quote></a> mallctl, which controls 301 refreshing of cached dynamic statistics.</p><div class="variablelist"><dl class="variablelist"><dt><a name="version"/><span class="term"> 302 <quote><code class="mallctl">version</code></quote> 303 (<span class="type">const char *</span>) 304 <code class="literal">r-</code> 305 </span></dt><dd><p>Return the jemalloc version string.</p></dd><dt><a name="epoch"/><span class="term"> 306 <quote><code class="mallctl">epoch</code></quote> 307 (<span class="type">uint64_t</span>) 308 <code class="literal">rw</code> 309 </span></dt><dd><p>If a value is passed in, refresh the data from which 310 the <code class="function">mallctl*()</code> functions report values, 311 and increment the epoch. Return the current epoch. This is useful for 312 detecting whether another thread caused a refresh.</p></dd><dt><a name="background_thread"/><span class="term"> 313 <quote><code class="mallctl">background_thread</code></quote> 314 (<span class="type">bool</span>) 315 <code class="literal">rw</code> 316 </span></dt><dd><p>Enable/disable internal background worker threads. When 317 set to true, background threads are created on demand (the number of 318 background threads will be no more than the number of CPUs or active 319 arenas). Threads run periodically, and handle <a class="link" href="#arena.i.decay">purging</a> asynchronously. When switching 320 off, background threads are terminated synchronously. Note that after 321 <span class="citerefentry"><span class="refentrytitle">fork</span>(2)</span> 322 function, the state in the child process will be disabled regardless 323 the state in parent process. See <a class="link" href="#stats.background_thread.num_threads"><quote><code class="mallctl">stats.background_thread</code></quote></a> 324 for related stats. <a class="link" href="#opt.background_thread"><quote><code class="mallctl">opt.background_thread</code></quote></a> 325 can be used to set the default option. This option is only available on 326 selected pthread-based platforms.</p></dd><dt><a name="max_background_threads"/><span class="term"> 327 <quote><code class="mallctl">max_background_threads</code></quote> 328 (<span class="type">size_t</span>) 329 <code class="literal">rw</code> 330 </span></dt><dd><p>Maximum number of background worker threads that will 331 be created. This value is capped at <a class="link" href="#opt.max_background_threads"><quote><code class="mallctl">opt.max_background_threads</code></quote></a> at 332 startup.</p></dd><dt><a name="config.cache_oblivious"/><span class="term"> 333 <quote><code class="mallctl">config.cache_oblivious</code></quote> 334 (<span class="type">bool</span>) 335 <code class="literal">r-</code> 336 </span></dt><dd><p><code class="option">--enable-cache-oblivious</code> was specified 337 during build configuration.</p></dd><dt><a name="config.debug"/><span class="term"> 338 <quote><code class="mallctl">config.debug</code></quote> 339 (<span class="type">bool</span>) 340 <code class="literal">r-</code> 341 </span></dt><dd><p><code class="option">--enable-debug</code> was specified during 342 build configuration.</p></dd><dt><a name="config.fill"/><span class="term"> 343 <quote><code class="mallctl">config.fill</code></quote> 344 (<span class="type">bool</span>) 345 <code class="literal">r-</code> 346 </span></dt><dd><p><code class="option">--enable-fill</code> was specified during 347 build configuration.</p></dd><dt><a name="config.lazy_lock"/><span class="term"> 348 <quote><code class="mallctl">config.lazy_lock</code></quote> 349 (<span class="type">bool</span>) 350 <code class="literal">r-</code> 351 </span></dt><dd><p><code class="option">--enable-lazy-lock</code> was specified 352 during build configuration.</p></dd><dt><a name="config.malloc_conf"/><span class="term"> 353 <quote><code class="mallctl">config.malloc_conf</code></quote> 354 (<span class="type">const char *</span>) 355 <code class="literal">r-</code> 356 </span></dt><dd><p>Embedded configure-time-specified run-time options 357 string, empty unless <code class="option">--with-malloc-conf</code> was specified 358 during build configuration.</p></dd><dt><a name="config.prof"/><span class="term"> 359 <quote><code class="mallctl">config.prof</code></quote> 360 (<span class="type">bool</span>) 361 <code class="literal">r-</code> 362 </span></dt><dd><p><code class="option">--enable-prof</code> was specified during 363 build configuration.</p></dd><dt><a name="config.prof_libgcc"/><span class="term"> 364 <quote><code class="mallctl">config.prof_libgcc</code></quote> 365 (<span class="type">bool</span>) 366 <code class="literal">r-</code> 367 </span></dt><dd><p><code class="option">--disable-prof-libgcc</code> was not 368 specified during build configuration.</p></dd><dt><a name="config.prof_libunwind"/><span class="term"> 369 <quote><code class="mallctl">config.prof_libunwind</code></quote> 370 (<span class="type">bool</span>) 371 <code class="literal">r-</code> 372 </span></dt><dd><p><code class="option">--enable-prof-libunwind</code> was specified 373 during build configuration.</p></dd><dt><a name="config.stats"/><span class="term"> 374 <quote><code class="mallctl">config.stats</code></quote> 375 (<span class="type">bool</span>) 376 <code class="literal">r-</code> 377 </span></dt><dd><p><code class="option">--enable-stats</code> was specified during 378 build configuration.</p></dd><dt><a name="config.utrace"/><span class="term"> 379 <quote><code class="mallctl">config.utrace</code></quote> 380 (<span class="type">bool</span>) 381 <code class="literal">r-</code> 382 </span></dt><dd><p><code class="option">--enable-utrace</code> was specified during 383 build configuration.</p></dd><dt><a name="config.xmalloc"/><span class="term"> 384 <quote><code class="mallctl">config.xmalloc</code></quote> 385 (<span class="type">bool</span>) 386 <code class="literal">r-</code> 387 </span></dt><dd><p><code class="option">--enable-xmalloc</code> was specified during 388 build configuration.</p></dd><dt><a name="opt.abort"/><span class="term"> 389 <quote><code class="mallctl">opt.abort</code></quote> 390 (<span class="type">bool</span>) 391 <code class="literal">r-</code> 392 </span></dt><dd><p>Abort-on-warning enabled/disabled. If true, most 393 warnings are fatal. Note that runtime option warnings are not included 394 (see <a class="link" href="#opt.abort_conf"><quote><code class="mallctl">opt.abort_conf</code></quote></a> for 395 that). The process will call 396 <span class="citerefentry"><span class="refentrytitle">abort</span>(3)</span> in these cases. This option is 397 disabled by default unless <code class="option">--enable-debug</code> is 398 specified during configuration, in which case it is enabled by default. 399 </p></dd><dt><a name="opt.abort_conf"/><span class="term"> 400 <quote><code class="mallctl">opt.abort_conf</code></quote> 401 (<span class="type">bool</span>) 402 <code class="literal">r-</code> 403 </span></dt><dd><p>Abort-on-invalid-configuration enabled/disabled. If 404 true, invalid runtime options are fatal. The process will call 405 <span class="citerefentry"><span class="refentrytitle">abort</span>(3)</span> in these cases. This option is 406 disabled by default unless <code class="option">--enable-debug</code> is 407 specified during configuration, in which case it is enabled by default. 408 </p></dd><dt><a name="opt.metadata_thp"/><span class="term"> 409 <quote><code class="mallctl">opt.metadata_thp</code></quote> 410 (<span class="type">const char *</span>) 411 <code class="literal">r-</code> 412 </span></dt><dd><p>Controls whether to allow jemalloc to use transparent 413 huge page (THP) for internal metadata (see <a class="link" href="#stats.metadata">stats.metadata</a>). <span class="quote">“<span class="quote">always</span>”</span> 414 allows such usage. <span class="quote">“<span class="quote">auto</span>”</span> uses no THP initially, but may 415 begin to do so when metadata usage reaches certain level. The default 416 is <span class="quote">“<span class="quote">disabled</span>”</span>.</p></dd><dt><a name="opt.retain"/><span class="term"> 417 <quote><code class="mallctl">opt.retain</code></quote> 418 (<span class="type">bool</span>) 419 <code class="literal">r-</code> 420 </span></dt><dd><p>If true, retain unused virtual memory for later reuse 421 rather than discarding it by calling 422 <span class="citerefentry"><span class="refentrytitle">munmap</span>(2)</span> or equivalent (see <a class="link" href="#stats.retained">stats.retained</a> for related details). 423 This option is disabled by default unless discarding virtual memory is 424 known to trigger 425 platform-specific performance problems, e.g. for [64-bit] Linux, which 426 has a quirk in its virtual memory allocation algorithm that causes 427 semi-permanent VM map holes under normal jemalloc operation. Although 428 <span class="citerefentry"><span class="refentrytitle">munmap</span>(2)</span> causes issues on 32-bit Linux as 429 well, retaining virtual memory for 32-bit Linux is disabled by default 430 due to the practical possibility of address space exhaustion. 431 </p></dd><dt><a name="opt.dss"/><span class="term"> 432 <quote><code class="mallctl">opt.dss</code></quote> 433 (<span class="type">const char *</span>) 434 <code class="literal">r-</code> 435 </span></dt><dd><p>dss (<span class="citerefentry"><span class="refentrytitle">sbrk</span>(2)</span>) allocation precedence as 436 related to <span class="citerefentry"><span class="refentrytitle">mmap</span>(2)</span> allocation. The following 437 settings are supported if 438 <span class="citerefentry"><span class="refentrytitle">sbrk</span>(2)</span> is supported by the operating 439 system: <span class="quote">“<span class="quote">disabled</span>”</span>, <span class="quote">“<span class="quote">primary</span>”</span>, and 440 <span class="quote">“<span class="quote">secondary</span>”</span>; otherwise only <span class="quote">“<span class="quote">disabled</span>”</span> is 441 supported. The default is <span class="quote">“<span class="quote">secondary</span>”</span> if 442 <span class="citerefentry"><span class="refentrytitle">sbrk</span>(2)</span> is supported by the operating 443 system; <span class="quote">“<span class="quote">disabled</span>”</span> otherwise. 444 </p></dd><dt><a name="opt.narenas"/><span class="term"> 445 <quote><code class="mallctl">opt.narenas</code></quote> 446 (<span class="type">unsigned</span>) 447 <code class="literal">r-</code> 448 </span></dt><dd><p>Maximum number of arenas to use for automatic 449 multiplexing of threads and arenas. The default is four times the 450 number of CPUs, or one if there is a single CPU.</p></dd><dt><a name="opt.percpu_arena"/><span class="term"> 451 <quote><code class="mallctl">opt.percpu_arena</code></quote> 452 (<span class="type">const char *</span>) 453 <code class="literal">r-</code> 454 </span></dt><dd><p>Per CPU arena mode. Use the <span class="quote">“<span class="quote">percpu</span>”</span> 455 setting to enable this feature, which uses number of CPUs to determine 456 number of arenas, and bind threads to arenas dynamically based on the 457 CPU the thread runs on currently. <span class="quote">“<span class="quote">phycpu</span>”</span> setting uses 458 one arena per physical CPU, which means the two hyper threads on the 459 same CPU share one arena. Note that no runtime checking regarding the 460 availability of hyper threading is done at the moment. When set to 461 <span class="quote">“<span class="quote">disabled</span>”</span>, narenas and thread to arena association will 462 not be impacted by this option. The default is <span class="quote">“<span class="quote">disabled</span>”</span>. 463 </p></dd><dt><a name="opt.background_thread"/><span class="term"> 464 <quote><code class="mallctl">opt.background_thread</code></quote> 465 (<span class="type">const bool</span>) 466 <code class="literal">r-</code> 467 </span></dt><dd><p>Internal background worker threads enabled/disabled. 468 Because of potential circular dependencies, enabling background thread 469 using this option may cause crash or deadlock during initialization. For 470 a reliable way to use this feature, see <a class="link" href="#background_thread">background_thread</a> for dynamic control 471 options and details. This option is disabled by 472 default.</p></dd><dt><a name="opt.max_background_threads"/><span class="term"> 473 <quote><code class="mallctl">opt.max_background_threads</code></quote> 474 (<span class="type">const size_t</span>) 475 <code class="literal">r-</code> 476 </span></dt><dd><p>Maximum number of background threads that will be created 477 if <a class="link" href="#background_thread">background_thread</a> is set. 478 Defaults to number of cpus.</p></dd><dt><a name="opt.dirty_decay_ms"/><span class="term"> 479 <quote><code class="mallctl">opt.dirty_decay_ms</code></quote> 480 (<span class="type">ssize_t</span>) 481 <code class="literal">r-</code> 482 </span></dt><dd><p>Approximate time in milliseconds from the creation of a 483 set of unused dirty pages until an equivalent set of unused dirty pages 484 is purged (i.e. converted to muzzy via e.g. 485 <code class="function">madvise(<em class="parameter"><code>...</code></em><em class="parameter"><code><code class="constant">MADV_FREE</code></code></em>)</code> 486 if supported by the operating system, or converted to clean otherwise) 487 and/or reused. Dirty pages are defined as previously having been 488 potentially written to by the application, and therefore consuming 489 physical memory, yet having no current use. The pages are incrementally 490 purged according to a sigmoidal decay curve that starts and ends with 491 zero purge rate. A decay time of 0 causes all unused dirty pages to be 492 purged immediately upon creation. A decay time of -1 disables purging. 493 The default decay time is 10 seconds. See <a class="link" href="#arenas.dirty_decay_ms"><quote><code class="mallctl">arenas.dirty_decay_ms</code></quote></a> 494 and <a class="link" href="#arena.i.dirty_decay_ms"><quote><code class="mallctl">arena.<i>.dirty_decay_ms</code></quote></a> 495 for related dynamic control options. See <a class="link" href="#opt.muzzy_decay_ms"><quote><code class="mallctl">opt.muzzy_decay_ms</code></quote></a> 496 for a description of muzzy pages.</p></dd><dt><a name="opt.muzzy_decay_ms"/><span class="term"> 497 <quote><code class="mallctl">opt.muzzy_decay_ms</code></quote> 498 (<span class="type">ssize_t</span>) 499 <code class="literal">r-</code> 500 </span></dt><dd><p>Approximate time in milliseconds from the creation of a 501 set of unused muzzy pages until an equivalent set of unused muzzy pages 502 is purged (i.e. converted to clean) and/or reused. Muzzy pages are 503 defined as previously having been unused dirty pages that were 504 subsequently purged in a manner that left them subject to the 505 reclamation whims of the operating system (e.g. 506 <code class="function">madvise(<em class="parameter"><code>...</code></em><em class="parameter"><code><code class="constant">MADV_FREE</code></code></em>)</code>), 507 and therefore in an indeterminate state. The pages are incrementally 508 purged according to a sigmoidal decay curve that starts and ends with 509 zero purge rate. A decay time of 0 causes all unused muzzy pages to be 510 purged immediately upon creation. A decay time of -1 disables purging. 511 The default decay time is 10 seconds. See <a class="link" href="#arenas.muzzy_decay_ms"><quote><code class="mallctl">arenas.muzzy_decay_ms</code></quote></a> 512 and <a class="link" href="#arena.i.muzzy_decay_ms"><quote><code class="mallctl">arena.<i>.muzzy_decay_ms</code></quote></a> 513 for related dynamic control options.</p></dd><dt><a name="opt.lg_extent_max_active_fit"/><span class="term"> 514 <quote><code class="mallctl">opt.lg_extent_max_active_fit</code></quote> 515 (<span class="type">size_t</span>) 516 <code class="literal">r-</code> 517 </span></dt><dd><p>When reusing dirty extents, this determines the (log 518 base 2 of the) maximum ratio between the size of the active extent 519 selected (to split off from) and the size of the requested allocation. 520 This prevents the splitting of large active extents for smaller 521 allocations, which can reduce fragmentation over the long run 522 (especially for non-active extents). Lower value may reduce 523 fragmentation, at the cost of extra active extents. The default value 524 is 6, which gives a maximum ratio of 64 (2^6).</p></dd><dt><a name="opt.stats_print"/><span class="term"> 525 <quote><code class="mallctl">opt.stats_print</code></quote> 526 (<span class="type">bool</span>) 527 <code class="literal">r-</code> 528 </span></dt><dd><p>Enable/disable statistics printing at exit. If 529 enabled, the <code class="function">malloc_stats_print()</code> 530 function is called at program exit via an 531 <span class="citerefentry"><span class="refentrytitle">atexit</span>(3)</span> function. <a class="link" href="#opt.stats_print_opts"><quote><code class="mallctl">opt.stats_print_opts</code></quote></a> 532 can be combined to specify output options. If 533 <code class="option">--enable-stats</code> is specified during configuration, this 534 has the potential to cause deadlock for a multi-threaded process that 535 exits while one or more threads are executing in the memory allocation 536 functions. Furthermore, <code class="function">atexit()</code> may 537 allocate memory during application initialization and then deadlock 538 internally when jemalloc in turn calls 539 <code class="function">atexit()</code>, so this option is not 540 universally usable (though the application can register its own 541 <code class="function">atexit()</code> function with equivalent 542 functionality). Therefore, this option should only be used with care; 543 it is primarily intended as a performance tuning aid during application 544 development. This option is disabled by default.</p></dd><dt><a name="opt.stats_print_opts"/><span class="term"> 545 <quote><code class="mallctl">opt.stats_print_opts</code></quote> 546 (<span class="type">const char *</span>) 547 <code class="literal">r-</code> 548 </span></dt><dd><p>Options (the <em class="parameter"><code>opts</code></em> string) to pass 549 to the <code class="function">malloc_stats_print()</code> at exit (enabled 550 through <a class="link" href="#opt.stats_print"><quote><code class="mallctl">opt.stats_print</code></quote></a>). See 551 available options in <a class="link" href="#malloc_stats_print_opts"><code class="function">malloc_stats_print()</code></a>. 552 Has no effect unless <a class="link" href="#opt.stats_print"><quote><code class="mallctl">opt.stats_print</code></quote></a> is 553 enabled. The default is <span class="quote">“<span class="quote"/>”</span>.</p></dd><dt><a name="opt.junk"/><span class="term"> 554 <quote><code class="mallctl">opt.junk</code></quote> 555 (<span class="type">const char *</span>) 556 <code class="literal">r-</code> 557 [<code class="option">--enable-fill</code>] 558 </span></dt><dd><p>Junk filling. If set to <span class="quote">“<span class="quote">alloc</span>”</span>, each byte 559 of uninitialized allocated memory will be initialized to 560 <code class="literal">0xa5</code>. If set to <span class="quote">“<span class="quote">free</span>”</span>, all deallocated 561 memory will be initialized to <code class="literal">0x5a</code>. If set to 562 <span class="quote">“<span class="quote">true</span>”</span>, both allocated and deallocated memory will be 563 initialized, and if set to <span class="quote">“<span class="quote">false</span>”</span>, junk filling be 564 disabled entirely. This is intended for debugging and will impact 565 performance negatively. This option is <span class="quote">“<span class="quote">false</span>”</span> by default 566 unless <code class="option">--enable-debug</code> is specified during 567 configuration, in which case it is <span class="quote">“<span class="quote">true</span>”</span> by 568 default.</p></dd><dt><a name="opt.zero"/><span class="term"> 569 <quote><code class="mallctl">opt.zero</code></quote> 570 (<span class="type">bool</span>) 571 <code class="literal">r-</code> 572 [<code class="option">--enable-fill</code>] 573 </span></dt><dd><p>Zero filling enabled/disabled. If enabled, each byte 574 of uninitialized allocated memory will be initialized to 0. Note that 575 this initialization only happens once for each byte, so 576 <code class="function">realloc()</code> and 577 <code class="function">rallocx()</code> calls do not zero memory that 578 was previously allocated. This is intended for debugging and will 579 impact performance negatively. This option is disabled by default. 580 </p></dd><dt><a name="opt.utrace"/><span class="term"> 581 <quote><code class="mallctl">opt.utrace</code></quote> 582 (<span class="type">bool</span>) 583 <code class="literal">r-</code> 584 [<code class="option">--enable-utrace</code>] 585 </span></dt><dd><p>Allocation tracing based on 586 <span class="citerefentry"><span class="refentrytitle">utrace</span>(2)</span> enabled/disabled. This option 587 is disabled by default.</p></dd><dt><a name="opt.xmalloc"/><span class="term"> 588 <quote><code class="mallctl">opt.xmalloc</code></quote> 589 (<span class="type">bool</span>) 590 <code class="literal">r-</code> 591 [<code class="option">--enable-xmalloc</code>] 592 </span></dt><dd><p>Abort-on-out-of-memory enabled/disabled. If enabled, 593 rather than returning failure for any allocation function, display a 594 diagnostic message on <code class="constant">STDERR_FILENO</code> and cause the 595 program to drop core (using 596 <span class="citerefentry"><span class="refentrytitle">abort</span>(3)</span>). If an application is 597 designed to depend on this behavior, set the option at compile time by 598 including the following in the source code: 599 </p><pre class="programlisting"> 600malloc_conf = "xmalloc:true";</pre><p> 601 This option is disabled by default.</p></dd><dt><a name="opt.tcache"/><span class="term"> 602 <quote><code class="mallctl">opt.tcache</code></quote> 603 (<span class="type">bool</span>) 604 <code class="literal">r-</code> 605 </span></dt><dd><p>Thread-specific caching (tcache) enabled/disabled. When 606 there are multiple threads, each thread uses a tcache for objects up to 607 a certain size. Thread-specific caching allows many allocations to be 608 satisfied without performing any thread synchronization, at the cost of 609 increased memory use. See the <a class="link" href="#opt.lg_tcache_max"><quote><code class="mallctl">opt.lg_tcache_max</code></quote></a> 610 option for related tuning information. This option is enabled by 611 default.</p></dd><dt><a name="opt.lg_tcache_max"/><span class="term"> 612 <quote><code class="mallctl">opt.lg_tcache_max</code></quote> 613 (<span class="type">size_t</span>) 614 <code class="literal">r-</code> 615 </span></dt><dd><p>Maximum size class (log base 2) to cache in the 616 thread-specific cache (tcache). At a minimum, all small size classes 617 are cached, and at a maximum all large size classes are cached. The 618 default maximum is 32 KiB (2^15).</p></dd><dt><a name="opt.thp"/><span class="term"> 619 <quote><code class="mallctl">opt.thp</code></quote> 620 (<span class="type">const char *</span>) 621 <code class="literal">r-</code> 622 </span></dt><dd><p>Transparent hugepage (THP) mode. Settings "always", 623 "never" and "default" are available if THP is supported by the operating 624 system. The "always" setting enables transparent hugepage for all user 625 memory mappings with 626 <em class="parameter"><code><code class="constant">MADV_HUGEPAGE</code></code></em>; "never" 627 ensures no transparent hugepage with 628 <em class="parameter"><code><code class="constant">MADV_NOHUGEPAGE</code></code></em>; the default 629 setting "default" makes no changes. Note that: this option does not 630 affect THP for jemalloc internal metadata (see <a class="link" href="#opt.metadata_thp"><quote><code class="mallctl">opt.metadata_thp</code></quote></a>); 631 in addition, for arenas with customized <a class="link" href="#arena.i.extent_hooks"><quote><code class="mallctl">extent_hooks</code></quote></a>, 632 this option is bypassed as it is implemented as part of the default 633 extent hooks.</p></dd><dt><a name="opt.prof"/><span class="term"> 634 <quote><code class="mallctl">opt.prof</code></quote> 635 (<span class="type">bool</span>) 636 <code class="literal">r-</code> 637 [<code class="option">--enable-prof</code>] 638 </span></dt><dd><p>Memory profiling enabled/disabled. If enabled, profile 639 memory allocation activity. See the <a class="link" href="#opt.prof_active"><quote><code class="mallctl">opt.prof_active</code></quote></a> 640 option for on-the-fly activation/deactivation. See the <a class="link" href="#opt.lg_prof_sample"><quote><code class="mallctl">opt.lg_prof_sample</code></quote></a> 641 option for probabilistic sampling control. See the <a class="link" href="#opt.prof_accum"><quote><code class="mallctl">opt.prof_accum</code></quote></a> 642 option for control of cumulative sample reporting. See the <a class="link" href="#opt.lg_prof_interval"><quote><code class="mallctl">opt.lg_prof_interval</code></quote></a> 643 option for information on interval-triggered profile dumping, the <a class="link" href="#opt.prof_gdump"><quote><code class="mallctl">opt.prof_gdump</code></quote></a> 644 option for information on high-water-triggered profile dumping, and the 645 <a class="link" href="#opt.prof_final"><quote><code class="mallctl">opt.prof_final</code></quote></a> 646 option for final profile dumping. Profile output is compatible with 647 the <span class="command"><strong>jeprof</strong></span> command, which is based on the 648 <span class="command"><strong>pprof</strong></span> that is developed as part of the <a class="ulink" href="http://code.google.com/p/gperftools/" target="_top">gperftools 649 package</a>. See <a class="link" href="#heap_profile_format" title="HEAP PROFILE FORMAT">HEAP PROFILE 650 FORMAT</a> for heap profile format documentation.</p></dd><dt><a name="opt.prof_prefix"/><span class="term"> 651 <quote><code class="mallctl">opt.prof_prefix</code></quote> 652 (<span class="type">const char *</span>) 653 <code class="literal">r-</code> 654 [<code class="option">--enable-prof</code>] 655 </span></dt><dd><p>Filename prefix for profile dumps. If the prefix is 656 set to the empty string, no automatic dumps will occur; this is 657 primarily useful for disabling the automatic final heap dump (which 658 also disables leak reporting, if enabled). The default prefix is 659 <code class="filename">jeprof</code>.</p></dd><dt><a name="opt.prof_active"/><span class="term"> 660 <quote><code class="mallctl">opt.prof_active</code></quote> 661 (<span class="type">bool</span>) 662 <code class="literal">r-</code> 663 [<code class="option">--enable-prof</code>] 664 </span></dt><dd><p>Profiling activated/deactivated. This is a secondary 665 control mechanism that makes it possible to start the application with 666 profiling enabled (see the <a class="link" href="#opt.prof"><quote><code class="mallctl">opt.prof</code></quote></a> option) but 667 inactive, then toggle profiling at any time during program execution 668 with the <a class="link" href="#prof.active"><quote><code class="mallctl">prof.active</code></quote></a> mallctl. 669 This option is enabled by default.</p></dd><dt><a name="opt.prof_thread_active_init"/><span class="term"> 670 <quote><code class="mallctl">opt.prof_thread_active_init</code></quote> 671 (<span class="type">bool</span>) 672 <code class="literal">r-</code> 673 [<code class="option">--enable-prof</code>] 674 </span></dt><dd><p>Initial setting for <a class="link" href="#thread.prof.active"><quote><code class="mallctl">thread.prof.active</code></quote></a> 675 in newly created threads. The initial setting for newly created threads 676 can also be changed during execution via the <a class="link" href="#prof.thread_active_init"><quote><code class="mallctl">prof.thread_active_init</code></quote></a> 677 mallctl. This option is enabled by default.</p></dd><dt><a name="opt.lg_prof_sample"/><span class="term"> 678 <quote><code class="mallctl">opt.lg_prof_sample</code></quote> 679 (<span class="type">size_t</span>) 680 <code class="literal">r-</code> 681 [<code class="option">--enable-prof</code>] 682 </span></dt><dd><p>Average interval (log base 2) between allocation 683 samples, as measured in bytes of allocation activity. Increasing the 684 sampling interval decreases profile fidelity, but also decreases the 685 computational overhead. The default sample interval is 512 KiB (2^19 686 B).</p></dd><dt><a name="opt.prof_accum"/><span class="term"> 687 <quote><code class="mallctl">opt.prof_accum</code></quote> 688 (<span class="type">bool</span>) 689 <code class="literal">r-</code> 690 [<code class="option">--enable-prof</code>] 691 </span></dt><dd><p>Reporting of cumulative object/byte counts in profile 692 dumps enabled/disabled. If this option is enabled, every unique 693 backtrace must be stored for the duration of execution. Depending on 694 the application, this can impose a large memory overhead, and the 695 cumulative counts are not always of interest. This option is disabled 696 by default.</p></dd><dt><a name="opt.lg_prof_interval"/><span class="term"> 697 <quote><code class="mallctl">opt.lg_prof_interval</code></quote> 698 (<span class="type">ssize_t</span>) 699 <code class="literal">r-</code> 700 [<code class="option">--enable-prof</code>] 701 </span></dt><dd><p>Average interval (log base 2) between memory profile 702 dumps, as measured in bytes of allocation activity. The actual 703 interval between dumps may be sporadic because decentralized allocation 704 counters are used to avoid synchronization bottlenecks. Profiles are 705 dumped to files named according to the pattern 706 <code class="filename"><prefix>.<pid>.<seq>.i<iseq>.heap</code>, 707 where <code class="literal"><prefix></code> is controlled by the 708 <a class="link" href="#opt.prof_prefix"><quote><code class="mallctl">opt.prof_prefix</code></quote></a> 709 option. By default, interval-triggered profile dumping is disabled 710 (encoded as -1). 711 </p></dd><dt><a name="opt.prof_gdump"/><span class="term"> 712 <quote><code class="mallctl">opt.prof_gdump</code></quote> 713 (<span class="type">bool</span>) 714 <code class="literal">r-</code> 715 [<code class="option">--enable-prof</code>] 716 </span></dt><dd><p>Set the initial state of <a class="link" href="#prof.gdump"><quote><code class="mallctl">prof.gdump</code></quote></a>, which when 717 enabled triggers a memory profile dump every time the total virtual 718 memory exceeds the previous maximum. This option is disabled by 719 default.</p></dd><dt><a name="opt.prof_final"/><span class="term"> 720 <quote><code class="mallctl">opt.prof_final</code></quote> 721 (<span class="type">bool</span>) 722 <code class="literal">r-</code> 723 [<code class="option">--enable-prof</code>] 724 </span></dt><dd><p>Use an 725 <span class="citerefentry"><span class="refentrytitle">atexit</span>(3)</span> function to dump final memory 726 usage to a file named according to the pattern 727 <code class="filename"><prefix>.<pid>.<seq>.f.heap</code>, 728 where <code class="literal"><prefix></code> is controlled by the <a class="link" href="#opt.prof_prefix"><quote><code class="mallctl">opt.prof_prefix</code></quote></a> 729 option. Note that <code class="function">atexit()</code> may allocate 730 memory during application initialization and then deadlock internally 731 when jemalloc in turn calls <code class="function">atexit()</code>, so 732 this option is not universally usable (though the application can 733 register its own <code class="function">atexit()</code> function with 734 equivalent functionality). This option is disabled by 735 default.</p></dd><dt><a name="opt.prof_leak"/><span class="term"> 736 <quote><code class="mallctl">opt.prof_leak</code></quote> 737 (<span class="type">bool</span>) 738 <code class="literal">r-</code> 739 [<code class="option">--enable-prof</code>] 740 </span></dt><dd><p>Leak reporting enabled/disabled. If enabled, use an 741 <span class="citerefentry"><span class="refentrytitle">atexit</span>(3)</span> function to report memory leaks 742 detected by allocation sampling. See the 743 <a class="link" href="#opt.prof"><quote><code class="mallctl">opt.prof</code></quote></a> option for 744 information on analyzing heap profile output. This option is disabled 745 by default.</p></dd><dt><a name="thread.arena"/><span class="term"> 746 <quote><code class="mallctl">thread.arena</code></quote> 747 (<span class="type">unsigned</span>) 748 <code class="literal">rw</code> 749 </span></dt><dd><p>Get or set the arena associated with the calling 750 thread. If the specified arena was not initialized beforehand (see the 751 <a class="link" href="#arena.i.initialized"><quote><code class="mallctl">arena.i.initialized</code></quote></a> 752 mallctl), it will be automatically initialized as a side effect of 753 calling this interface.</p></dd><dt><a name="thread.allocated"/><span class="term"> 754 <quote><code class="mallctl">thread.allocated</code></quote> 755 (<span class="type">uint64_t</span>) 756 <code class="literal">r-</code> 757 [<code class="option">--enable-stats</code>] 758 </span></dt><dd><p>Get the total number of bytes ever allocated by the 759 calling thread. This counter has the potential to wrap around; it is 760 up to the application to appropriately interpret the counter in such 761 cases.</p></dd><dt><a name="thread.allocatedp"/><span class="term"> 762 <quote><code class="mallctl">thread.allocatedp</code></quote> 763 (<span class="type">uint64_t *</span>) 764 <code class="literal">r-</code> 765 [<code class="option">--enable-stats</code>] 766 </span></dt><dd><p>Get a pointer to the the value that is returned by the 767 <a class="link" href="#thread.allocated"><quote><code class="mallctl">thread.allocated</code></quote></a> 768 mallctl. This is useful for avoiding the overhead of repeated 769 <code class="function">mallctl*()</code> calls.</p></dd><dt><a name="thread.deallocated"/><span class="term"> 770 <quote><code class="mallctl">thread.deallocated</code></quote> 771 (<span class="type">uint64_t</span>) 772 <code class="literal">r-</code> 773 [<code class="option">--enable-stats</code>] 774 </span></dt><dd><p>Get the total number of bytes ever deallocated by the 775 calling thread. This counter has the potential to wrap around; it is 776 up to the application to appropriately interpret the counter in such 777 cases.</p></dd><dt><a name="thread.deallocatedp"/><span class="term"> 778 <quote><code class="mallctl">thread.deallocatedp</code></quote> 779 (<span class="type">uint64_t *</span>) 780 <code class="literal">r-</code> 781 [<code class="option">--enable-stats</code>] 782 </span></dt><dd><p>Get a pointer to the the value that is returned by the 783 <a class="link" href="#thread.deallocated"><quote><code class="mallctl">thread.deallocated</code></quote></a> 784 mallctl. This is useful for avoiding the overhead of repeated 785 <code class="function">mallctl*()</code> calls.</p></dd><dt><a name="thread.tcache.enabled"/><span class="term"> 786 <quote><code class="mallctl">thread.tcache.enabled</code></quote> 787 (<span class="type">bool</span>) 788 <code class="literal">rw</code> 789 </span></dt><dd><p>Enable/disable calling thread's tcache. The tcache is 790 implicitly flushed as a side effect of becoming 791 disabled (see <a class="link" href="#thread.tcache.flush"><quote><code class="mallctl">thread.tcache.flush</code></quote></a>). 792 </p></dd><dt><a name="thread.tcache.flush"/><span class="term"> 793 <quote><code class="mallctl">thread.tcache.flush</code></quote> 794 (<span class="type">void</span>) 795 <code class="literal">--</code> 796 </span></dt><dd><p>Flush calling thread's thread-specific cache (tcache). 797 This interface releases all cached objects and internal data structures 798 associated with the calling thread's tcache. Ordinarily, this interface 799 need not be called, since automatic periodic incremental garbage 800 collection occurs, and the thread cache is automatically discarded when 801 a thread exits. However, garbage collection is triggered by allocation 802 activity, so it is possible for a thread that stops 803 allocating/deallocating to retain its cache indefinitely, in which case 804 the developer may find manual flushing useful.</p></dd><dt><a name="thread.prof.name"/><span class="term"> 805 <quote><code class="mallctl">thread.prof.name</code></quote> 806 (<span class="type">const char *</span>) 807 <code class="literal">r-</code> or 808 <code class="literal">-w</code> 809 [<code class="option">--enable-prof</code>] 810 </span></dt><dd><p>Get/set the descriptive name associated with the calling 811 thread in memory profile dumps. An internal copy of the name string is 812 created, so the input string need not be maintained after this interface 813 completes execution. The output string of this interface should be 814 copied for non-ephemeral uses, because multiple implementation details 815 can cause asynchronous string deallocation. Furthermore, each 816 invocation of this interface can only read or write; simultaneous 817 read/write is not supported due to string lifetime limitations. The 818 name string must be nil-terminated and comprised only of characters in 819 the sets recognized 820 by <span class="citerefentry"><span class="refentrytitle">isgraph</span>(3)</span> and 821 <span class="citerefentry"><span class="refentrytitle">isblank</span>(3)</span>.</p></dd><dt><a name="thread.prof.active"/><span class="term"> 822 <quote><code class="mallctl">thread.prof.active</code></quote> 823 (<span class="type">bool</span>) 824 <code class="literal">rw</code> 825 [<code class="option">--enable-prof</code>] 826 </span></dt><dd><p>Control whether sampling is currently active for the 827 calling thread. This is an activation mechanism in addition to <a class="link" href="#prof.active"><quote><code class="mallctl">prof.active</code></quote></a>; both must 828 be active for the calling thread to sample. This flag is enabled by 829 default.</p></dd><dt><a name="tcache.create"/><span class="term"> 830 <quote><code class="mallctl">tcache.create</code></quote> 831 (<span class="type">unsigned</span>) 832 <code class="literal">r-</code> 833 </span></dt><dd><p>Create an explicit thread-specific cache (tcache) and 834 return an identifier that can be passed to the <a class="link" href="#MALLOCX_TCACHE"><code class="constant">MALLOCX_TCACHE(<em class="parameter"><code>tc</code></em>)</code></a> 835 macro to explicitly use the specified cache rather than the 836 automatically managed one that is used by default. Each explicit cache 837 can be used by only one thread at a time; the application must assure 838 that this constraint holds. 839 </p></dd><dt><a name="tcache.flush"/><span class="term"> 840 <quote><code class="mallctl">tcache.flush</code></quote> 841 (<span class="type">unsigned</span>) 842 <code class="literal">-w</code> 843 </span></dt><dd><p>Flush the specified thread-specific cache (tcache). The 844 same considerations apply to this interface as to <a class="link" href="#thread.tcache.flush"><quote><code class="mallctl">thread.tcache.flush</code></quote></a>, 845 except that the tcache will never be automatically discarded. 846 </p></dd><dt><a name="tcache.destroy"/><span class="term"> 847 <quote><code class="mallctl">tcache.destroy</code></quote> 848 (<span class="type">unsigned</span>) 849 <code class="literal">-w</code> 850 </span></dt><dd><p>Flush the specified thread-specific cache (tcache) and 851 make the identifier available for use during a future tcache creation. 852 </p></dd><dt><a name="arena.i.initialized"/><span class="term"> 853 <quote><code class="mallctl">arena.<i>.initialized</code></quote> 854 (<span class="type">bool</span>) 855 <code class="literal">r-</code> 856 </span></dt><dd><p>Get whether the specified arena's statistics are 857 initialized (i.e. the arena was initialized prior to the current epoch). 858 This interface can also be nominally used to query whether the merged 859 statistics corresponding to <code class="constant">MALLCTL_ARENAS_ALL</code> are 860 initialized (always true).</p></dd><dt><a name="arena.i.decay"/><span class="term"> 861 <quote><code class="mallctl">arena.<i>.decay</code></quote> 862 (<span class="type">void</span>) 863 <code class="literal">--</code> 864 </span></dt><dd><p>Trigger decay-based purging of unused dirty/muzzy pages 865 for arena <i>, or for all arenas if <i> equals 866 <code class="constant">MALLCTL_ARENAS_ALL</code>. The proportion of unused 867 dirty/muzzy pages to be purged depends on the current time; see <a class="link" href="#opt.dirty_decay_ms"><quote><code class="mallctl">opt.dirty_decay_ms</code></quote></a> 868 and <a class="link" href="#opt.muzzy_decay_ms"><quote><code class="mallctl">opt.muzy_decay_ms</code></quote></a> 869 for details.</p></dd><dt><a name="arena.i.purge"/><span class="term"> 870 <quote><code class="mallctl">arena.<i>.purge</code></quote> 871 (<span class="type">void</span>) 872 <code class="literal">--</code> 873 </span></dt><dd><p>Purge all unused dirty pages for arena <i>, or for 874 all arenas if <i> equals <code class="constant">MALLCTL_ARENAS_ALL</code>. 875 </p></dd><dt><a name="arena.i.reset"/><span class="term"> 876 <quote><code class="mallctl">arena.<i>.reset</code></quote> 877 (<span class="type">void</span>) 878 <code class="literal">--</code> 879 </span></dt><dd><p>Discard all of the arena's extant allocations. This 880 interface can only be used with arenas explicitly created via <a class="link" href="#arenas.create"><quote><code class="mallctl">arenas.create</code></quote></a>. None 881 of the arena's discarded/cached allocations may accessed afterward. As 882 part of this requirement, all thread caches which were used to 883 allocate/deallocate in conjunction with the arena must be flushed 884 beforehand.</p></dd><dt><a name="arena.i.destroy"/><span class="term"> 885 <quote><code class="mallctl">arena.<i>.destroy</code></quote> 886 (<span class="type">void</span>) 887 <code class="literal">--</code> 888 </span></dt><dd><p>Destroy the arena. Discard all of the arena's extant 889 allocations using the same mechanism as for <a class="link" href="#arena.i.reset"><quote><code class="mallctl">arena.<i>.reset</code></quote></a> 890 (with all the same constraints and side effects), merge the arena stats 891 into those accessible at arena index 892 <code class="constant">MALLCTL_ARENAS_DESTROYED</code>, and then completely 893 discard all metadata associated with the arena. Future calls to <a class="link" href="#arenas.create"><quote><code class="mallctl">arenas.create</code></quote></a> may 894 recycle the arena index. Destruction will fail if any threads are 895 currently associated with the arena as a result of calls to <a class="link" href="#thread.arena"><quote><code class="mallctl">thread.arena</code></quote></a>.</p></dd><dt><a name="arena.i.dss"/><span class="term"> 896 <quote><code class="mallctl">arena.<i>.dss</code></quote> 897 (<span class="type">const char *</span>) 898 <code class="literal">rw</code> 899 </span></dt><dd><p>Set the precedence of dss allocation as related to mmap 900 allocation for arena <i>, or for all arenas if <i> equals 901 <code class="constant">MALLCTL_ARENAS_ALL</code>. See <a class="link" href="#opt.dss"><quote><code class="mallctl">opt.dss</code></quote></a> for supported 902 settings.</p></dd><dt><a name="arena.i.dirty_decay_ms"/><span class="term"> 903 <quote><code class="mallctl">arena.<i>.dirty_decay_ms</code></quote> 904 (<span class="type">ssize_t</span>) 905 <code class="literal">rw</code> 906 </span></dt><dd><p>Current per-arena approximate time in milliseconds from 907 the creation of a set of unused dirty pages until an equivalent set of 908 unused dirty pages is purged and/or reused. Each time this interface is 909 set, all currently unused dirty pages are considered to have fully 910 decayed, which causes immediate purging of all unused dirty pages unless 911 the decay time is set to -1 (i.e. purging disabled). See <a class="link" href="#opt.dirty_decay_ms"><quote><code class="mallctl">opt.dirty_decay_ms</code></quote></a> 912 for additional information.</p></dd><dt><a name="arena.i.muzzy_decay_ms"/><span class="term"> 913 <quote><code class="mallctl">arena.<i>.muzzy_decay_ms</code></quote> 914 (<span class="type">ssize_t</span>) 915 <code class="literal">rw</code> 916 </span></dt><dd><p>Current per-arena approximate time in milliseconds from 917 the creation of a set of unused muzzy pages until an equivalent set of 918 unused muzzy pages is purged and/or reused. Each time this interface is 919 set, all currently unused muzzy pages are considered to have fully 920 decayed, which causes immediate purging of all unused muzzy pages unless 921 the decay time is set to -1 (i.e. purging disabled). See <a class="link" href="#opt.muzzy_decay_ms"><quote><code class="mallctl">opt.muzzy_decay_ms</code></quote></a> 922 for additional information.</p></dd><dt><a name="arena.i.retain_grow_limit"/><span class="term"> 923 <quote><code class="mallctl">arena.<i>.retain_grow_limit</code></quote> 924 (<span class="type">size_t</span>) 925 <code class="literal">rw</code> 926 </span></dt><dd><p>Maximum size to grow retained region (only relevant when 927 <a class="link" href="#opt.retain"><quote><code class="mallctl">opt.retain</code></quote></a> is 928 enabled). This controls the maximum increment to expand virtual memory, 929 or allocation through <a class="link" href="#arena.i.extent_hooks"><quote><code class="mallctl">arena.<i>extent_hooks</code></quote></a>. 930 In particular, if customized extent hooks reserve physical memory 931 (e.g. 1G huge pages), this is useful to control the allocation hook's 932 input size. The default is no limit.</p></dd><dt><a name="arena.i.extent_hooks"/><span class="term"> 933 <quote><code class="mallctl">arena.<i>.extent_hooks</code></quote> 934 (<span class="type">extent_hooks_t *</span>) 935 <code class="literal">rw</code> 936 </span></dt><dd><p>Get or set the extent management hook functions for 937 arena <i>. The functions must be capable of operating on all 938 extant extents associated with arena <i>, usually by passing 939 unknown extents to the replaced functions. In practice, it is feasible 940 to control allocation for arenas explicitly created via <a class="link" href="#arenas.create"><quote><code class="mallctl">arenas.create</code></quote></a> such 941 that all extents originate from an application-supplied extent allocator 942 (by specifying the custom extent hook functions during arena creation), 943 but the automatically created arenas will have already created extents 944 prior to the application having an opportunity to take over extent 945 allocation.</p><pre class="programlisting"> 946typedef extent_hooks_s extent_hooks_t; 947struct extent_hooks_s { 948 extent_alloc_t *alloc; 949 extent_dalloc_t *dalloc; 950 extent_destroy_t *destroy; 951 extent_commit_t *commit; 952 extent_decommit_t *decommit; 953 extent_purge_t *purge_lazy; 954 extent_purge_t *purge_forced; 955 extent_split_t *split; 956 extent_merge_t *merge; 957};</pre><p>The <span class="type">extent_hooks_t</span> structure comprises function 958 pointers which are described individually below. jemalloc uses these 959 functions to manage extent lifetime, which starts off with allocation of 960 mapped committed memory, in the simplest case followed by deallocation. 961 However, there are performance and platform reasons to retain extents 962 for later reuse. Cleanup attempts cascade from deallocation to decommit 963 to forced purging to lazy purging, which gives the extent management 964 functions opportunities to reject the most permanent cleanup operations 965 in favor of less permanent (and often less costly) operations. All 966 operations except allocation can be universally opted out of by setting 967 the hook pointers to <code class="constant">NULL</code>, or selectively opted out 968 of by returning failure. Note that once the extent hook is set, the 969 structure is accessed directly by the associated arenas, so it must 970 remain valid for the entire lifetime of the arenas.</p><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">typedef void *<b class="fsfunc">(extent_alloc_t)</b>(</code></td><td>extent_hooks_t *<var class="pdparam">extent_hooks</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">new_addr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">alignment</var>, </td></tr><tr><td> </td><td>bool *<var class="pdparam">zero</var>, </td></tr><tr><td> </td><td>bool *<var class="pdparam">commit</var>, </td></tr><tr><td> </td><td>unsigned <var class="pdparam">arena_ind</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div><div class="literallayout"><p/></div><p>An extent allocation function conforms to the 971 <span class="type">extent_alloc_t</span> type and upon success returns a pointer to 972 <em class="parameter"><code>size</code></em> bytes of mapped memory on behalf of arena 973 <em class="parameter"><code>arena_ind</code></em> such that the extent's base address is 974 a multiple of <em class="parameter"><code>alignment</code></em>, as well as setting 975 <em class="parameter"><code>*zero</code></em> to indicate whether the extent is zeroed 976 and <em class="parameter"><code>*commit</code></em> to indicate whether the extent is 977 committed. Upon error the function returns <code class="constant">NULL</code> 978 and leaves <em class="parameter"><code>*zero</code></em> and 979 <em class="parameter"><code>*commit</code></em> unmodified. The 980 <em class="parameter"><code>size</code></em> parameter is always a multiple of the page 981 size. The <em class="parameter"><code>alignment</code></em> parameter is always a power 982 of two at least as large as the page size. Zeroing is mandatory if 983 <em class="parameter"><code>*zero</code></em> is true upon function entry. Committing is 984 mandatory if <em class="parameter"><code>*commit</code></em> is true upon function entry. 985 If <em class="parameter"><code>new_addr</code></em> is not <code class="constant">NULL</code>, the 986 returned pointer must be <em class="parameter"><code>new_addr</code></em> on success or 987 <code class="constant">NULL</code> on error. Committed memory may be committed 988 in absolute terms as on a system that does not overcommit, or in 989 implicit terms as on a system that overcommits and satisfies physical 990 memory needs on demand via soft page faults. Note that replacing the 991 default extent allocation function makes the arena's <a class="link" href="#arena.i.dss"><quote><code class="mallctl">arena.<i>.dss</code></quote></a> 992 setting irrelevant.</p><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">typedef bool <b class="fsfunc">(extent_dalloc_t)</b>(</code></td><td>extent_hooks_t *<var class="pdparam">extent_hooks</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">addr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>bool <var class="pdparam">committed</var>, </td></tr><tr><td> </td><td>unsigned <var class="pdparam">arena_ind</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div><div class="literallayout"><p/></div><p> 993 An extent deallocation function conforms to the 994 <span class="type">extent_dalloc_t</span> type and deallocates an extent at given 995 <em class="parameter"><code>addr</code></em> and <em class="parameter"><code>size</code></em> with 996 <em class="parameter"><code>committed</code></em>/decommited memory as indicated, on 997 behalf of arena <em class="parameter"><code>arena_ind</code></em>, returning false upon 998 success. If the function returns true, this indicates opt-out from 999 deallocation; the virtual memory mapping associated with the extent 1000 remains mapped, in the same commit state, and available for future use, 1001 in which case it will be automatically retained for later reuse.</p><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">typedef void <b class="fsfunc">(extent_destroy_t)</b>(</code></td><td>extent_hooks_t *<var class="pdparam">extent_hooks</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">addr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>bool <var class="pdparam">committed</var>, </td></tr><tr><td> </td><td>unsigned <var class="pdparam">arena_ind</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div><div class="literallayout"><p/></div><p> 1002 An extent destruction function conforms to the 1003 <span class="type">extent_destroy_t</span> type and unconditionally destroys an 1004 extent at given <em class="parameter"><code>addr</code></em> and 1005 <em class="parameter"><code>size</code></em> with 1006 <em class="parameter"><code>committed</code></em>/decommited memory as indicated, on 1007 behalf of arena <em class="parameter"><code>arena_ind</code></em>. This function may be 1008 called to destroy retained extents during arena destruction (see <a class="link" href="#arena.i.destroy"><quote><code class="mallctl">arena.<i>.destroy</code></quote></a>).</p><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">typedef bool <b class="fsfunc">(extent_commit_t)</b>(</code></td><td>extent_hooks_t *<var class="pdparam">extent_hooks</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">addr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">offset</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">length</var>, </td></tr><tr><td> </td><td>unsigned <var class="pdparam">arena_ind</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div><div class="literallayout"><p/></div><p>An extent commit function conforms to the 1009 <span class="type">extent_commit_t</span> type and commits zeroed physical memory to 1010 back pages within an extent at given <em class="parameter"><code>addr</code></em> and 1011 <em class="parameter"><code>size</code></em> at <em class="parameter"><code>offset</code></em> bytes, 1012 extending for <em class="parameter"><code>length</code></em> on behalf of arena 1013 <em class="parameter"><code>arena_ind</code></em>, returning false upon success. 1014 Committed memory may be committed in absolute terms as on a system that 1015 does not overcommit, or in implicit terms as on a system that 1016 overcommits and satisfies physical memory needs on demand via soft page 1017 faults. If the function returns true, this indicates insufficient 1018 physical memory to satisfy the request.</p><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">typedef bool <b class="fsfunc">(extent_decommit_t)</b>(</code></td><td>extent_hooks_t *<var class="pdparam">extent_hooks</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">addr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">offset</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">length</var>, </td></tr><tr><td> </td><td>unsigned <var class="pdparam">arena_ind</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div><div class="literallayout"><p/></div><p>An extent decommit function conforms to the 1019 <span class="type">extent_decommit_t</span> type and decommits any physical memory 1020 that is backing pages within an extent at given 1021 <em class="parameter"><code>addr</code></em> and <em class="parameter"><code>size</code></em> at 1022 <em class="parameter"><code>offset</code></em> bytes, extending for 1023 <em class="parameter"><code>length</code></em> on behalf of arena 1024 <em class="parameter"><code>arena_ind</code></em>, returning false upon success, in which 1025 case the pages will be committed via the extent commit function before 1026 being reused. If the function returns true, this indicates opt-out from 1027 decommit; the memory remains committed and available for future use, in 1028 which case it will be automatically retained for later reuse.</p><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">typedef bool <b class="fsfunc">(extent_purge_t)</b>(</code></td><td>extent_hooks_t *<var class="pdparam">extent_hooks</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">addr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">offset</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">length</var>, </td></tr><tr><td> </td><td>unsigned <var class="pdparam">arena_ind</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div><div class="literallayout"><p/></div><p>An extent purge function conforms to the 1029 <span class="type">extent_purge_t</span> type and discards physical pages 1030 within the virtual memory mapping associated with an extent at given 1031 <em class="parameter"><code>addr</code></em> and <em class="parameter"><code>size</code></em> at 1032 <em class="parameter"><code>offset</code></em> bytes, extending for 1033 <em class="parameter"><code>length</code></em> on behalf of arena 1034 <em class="parameter"><code>arena_ind</code></em>. A lazy extent purge function (e.g. 1035 implemented via 1036 <code class="function">madvise(<em class="parameter"><code>...</code></em><em class="parameter"><code><code class="constant">MADV_FREE</code></code></em>)</code>) 1037 can delay purging indefinitely and leave the pages within the purged 1038 virtual memory range in an indeterminite state, whereas a forced extent 1039 purge function immediately purges, and the pages within the virtual 1040 memory range will be zero-filled the next time they are accessed. If 1041 the function returns true, this indicates failure to purge.</p><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">typedef bool <b class="fsfunc">(extent_split_t)</b>(</code></td><td>extent_hooks_t *<var class="pdparam">extent_hooks</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">addr</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size_a</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size_b</var>, </td></tr><tr><td> </td><td>bool <var class="pdparam">committed</var>, </td></tr><tr><td> </td><td>unsigned <var class="pdparam">arena_ind</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div><div class="literallayout"><p/></div><p>An extent split function conforms to the 1042 <span class="type">extent_split_t</span> type and optionally splits an extent at 1043 given <em class="parameter"><code>addr</code></em> and <em class="parameter"><code>size</code></em> into 1044 two adjacent extents, the first of <em class="parameter"><code>size_a</code></em> bytes, 1045 and the second of <em class="parameter"><code>size_b</code></em> bytes, operating on 1046 <em class="parameter"><code>committed</code></em>/decommitted memory as indicated, on 1047 behalf of arena <em class="parameter"><code>arena_ind</code></em>, returning false upon 1048 success. If the function returns true, this indicates that the extent 1049 remains unsplit and therefore should continue to be operated on as a 1050 whole.</p><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">typedef bool <b class="fsfunc">(extent_merge_t)</b>(</code></td><td>extent_hooks_t *<var class="pdparam">extent_hooks</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">addr_a</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size_a</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">addr_b</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">size_b</var>, </td></tr><tr><td> </td><td>bool <var class="pdparam">committed</var>, </td></tr><tr><td> </td><td>unsigned <var class="pdparam">arena_ind</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div><div class="literallayout"><p/></div><p>An extent merge function conforms to the 1051 <span class="type">extent_merge_t</span> type and optionally merges adjacent extents, 1052 at given <em class="parameter"><code>addr_a</code></em> and <em class="parameter"><code>size_a</code></em> 1053 with given <em class="parameter"><code>addr_b</code></em> and 1054 <em class="parameter"><code>size_b</code></em> into one contiguous extent, operating on 1055 <em class="parameter"><code>committed</code></em>/decommitted memory as indicated, on 1056 behalf of arena <em class="parameter"><code>arena_ind</code></em>, returning false upon 1057 success. If the function returns true, this indicates that the extents 1058 remain distinct mappings and therefore should continue to be operated on 1059 independently.</p></dd><dt><a name="arenas.narenas"/><span class="term"> 1060 <quote><code class="mallctl">arenas.narenas</code></quote> 1061 (<span class="type">unsigned</span>) 1062 <code class="literal">r-</code> 1063 </span></dt><dd><p>Current limit on number of arenas.</p></dd><dt><a name="arenas.dirty_decay_ms"/><span class="term"> 1064 <quote><code class="mallctl">arenas.dirty_decay_ms</code></quote> 1065 (<span class="type">ssize_t</span>) 1066 <code class="literal">rw</code> 1067 </span></dt><dd><p>Current default per-arena approximate time in 1068 milliseconds from the creation of a set of unused dirty pages until an 1069 equivalent set of unused dirty pages is purged and/or reused, used to 1070 initialize <a class="link" href="#arena.i.dirty_decay_ms"><quote><code class="mallctl">arena.<i>.dirty_decay_ms</code></quote></a> 1071 during arena creation. See <a class="link" href="#opt.dirty_decay_ms"><quote><code class="mallctl">opt.dirty_decay_ms</code></quote></a> 1072 for additional information.</p></dd><dt><a name="arenas.muzzy_decay_ms"/><span class="term"> 1073 <quote><code class="mallctl">arenas.muzzy_decay_ms</code></quote> 1074 (<span class="type">ssize_t</span>) 1075 <code class="literal">rw</code> 1076 </span></dt><dd><p>Current default per-arena approximate time in 1077 milliseconds from the creation of a set of unused muzzy pages until an 1078 equivalent set of unused muzzy pages is purged and/or reused, used to 1079 initialize <a class="link" href="#arena.i.muzzy_decay_ms"><quote><code class="mallctl">arena.<i>.muzzy_decay_ms</code></quote></a> 1080 during arena creation. See <a class="link" href="#opt.muzzy_decay_ms"><quote><code class="mallctl">opt.muzzy_decay_ms</code></quote></a> 1081 for additional information.</p></dd><dt><a name="arenas.quantum"/><span class="term"> 1082 <quote><code class="mallctl">arenas.quantum</code></quote> 1083 (<span class="type">size_t</span>) 1084 <code class="literal">r-</code> 1085 </span></dt><dd><p>Quantum size.</p></dd><dt><a name="arenas.page"/><span class="term"> 1086 <quote><code class="mallctl">arenas.page</code></quote> 1087 (<span class="type">size_t</span>) 1088 <code class="literal">r-</code> 1089 </span></dt><dd><p>Page size.</p></dd><dt><a name="arenas.tcache_max"/><span class="term"> 1090 <quote><code class="mallctl">arenas.tcache_max</code></quote> 1091 (<span class="type">size_t</span>) 1092 <code class="literal">r-</code> 1093 </span></dt><dd><p>Maximum thread-cached size class.</p></dd><dt><a name="arenas.nbins"/><span class="term"> 1094 <quote><code class="mallctl">arenas.nbins</code></quote> 1095 (<span class="type">unsigned</span>) 1096 <code class="literal">r-</code> 1097 </span></dt><dd><p>Number of bin size classes.</p></dd><dt><a name="arenas.nhbins"/><span class="term"> 1098 <quote><code class="mallctl">arenas.nhbins</code></quote> 1099 (<span class="type">unsigned</span>) 1100 <code class="literal">r-</code> 1101 </span></dt><dd><p>Total number of thread cache bin size 1102 classes.</p></dd><dt><a name="arenas.bin.i.size"/><span class="term"> 1103 <quote><code class="mallctl">arenas.bin.<i>.size</code></quote> 1104 (<span class="type">size_t</span>) 1105 <code class="literal">r-</code> 1106 </span></dt><dd><p>Maximum size supported by size class.</p></dd><dt><a name="arenas.bin.i.nregs"/><span class="term"> 1107 <quote><code class="mallctl">arenas.bin.<i>.nregs</code></quote> 1108 (<span class="type">uint32_t</span>) 1109 <code class="literal">r-</code> 1110 </span></dt><dd><p>Number of regions per slab.</p></dd><dt><a name="arenas.bin.i.slab_size"/><span class="term"> 1111 <quote><code class="mallctl">arenas.bin.<i>.slab_size</code></quote> 1112 (<span class="type">size_t</span>) 1113 <code class="literal">r-</code> 1114 </span></dt><dd><p>Number of bytes per slab.</p></dd><dt><a name="arenas.nlextents"/><span class="term"> 1115 <quote><code class="mallctl">arenas.nlextents</code></quote> 1116 (<span class="type">unsigned</span>) 1117 <code class="literal">r-</code> 1118 </span></dt><dd><p>Total number of large size classes.</p></dd><dt><a name="arenas.lextent.i.size"/><span class="term"> 1119 <quote><code class="mallctl">arenas.lextent.<i>.size</code></quote> 1120 (<span class="type">size_t</span>) 1121 <code class="literal">r-</code> 1122 </span></dt><dd><p>Maximum size supported by this large size 1123 class.</p></dd><dt><a name="arenas.create"/><span class="term"> 1124 <quote><code class="mallctl">arenas.create</code></quote> 1125 (<span class="type">unsigned</span>, <span class="type">extent_hooks_t *</span>) 1126 <code class="literal">rw</code> 1127 </span></dt><dd><p>Explicitly create a new arena outside the range of 1128 automatically managed arenas, with optionally specified extent hooks, 1129 and return the new arena index.</p></dd><dt><a name="arenas.lookup"/><span class="term"> 1130 <quote><code class="mallctl">arenas.lookup</code></quote> 1131 (<span class="type">unsigned</span>, <span class="type">void*</span>) 1132 <code class="literal">rw</code> 1133 </span></dt><dd><p>Index of the arena to which an allocation belongs to.</p></dd><dt><a name="prof.thread_active_init"/><span class="term"> 1134 <quote><code class="mallctl">prof.thread_active_init</code></quote> 1135 (<span class="type">bool</span>) 1136 <code class="literal">rw</code> 1137 [<code class="option">--enable-prof</code>] 1138 </span></dt><dd><p>Control the initial setting for <a class="link" href="#thread.prof.active"><quote><code class="mallctl">thread.prof.active</code></quote></a> 1139 in newly created threads. See the <a class="link" href="#opt.prof_thread_active_init"><quote><code class="mallctl">opt.prof_thread_active_init</code></quote></a> 1140 option for additional information.</p></dd><dt><a name="prof.active"/><span class="term"> 1141 <quote><code class="mallctl">prof.active</code></quote> 1142 (<span class="type">bool</span>) 1143 <code class="literal">rw</code> 1144 [<code class="option">--enable-prof</code>] 1145 </span></dt><dd><p>Control whether sampling is currently active. See the 1146 <a class="link" href="#opt.prof_active"><quote><code class="mallctl">opt.prof_active</code></quote></a> 1147 option for additional information, as well as the interrelated <a class="link" href="#thread.prof.active"><quote><code class="mallctl">thread.prof.active</code></quote></a> 1148 mallctl.</p></dd><dt><a name="prof.dump"/><span class="term"> 1149 <quote><code class="mallctl">prof.dump</code></quote> 1150 (<span class="type">const char *</span>) 1151 <code class="literal">-w</code> 1152 [<code class="option">--enable-prof</code>] 1153 </span></dt><dd><p>Dump a memory profile to the specified file, or if NULL 1154 is specified, to a file according to the pattern 1155 <code class="filename"><prefix>.<pid>.<seq>.m<mseq>.heap</code>, 1156 where <code class="literal"><prefix></code> is controlled by the 1157 <a class="link" href="#opt.prof_prefix"><quote><code class="mallctl">opt.prof_prefix</code></quote></a> 1158 option.</p></dd><dt><a name="prof.gdump"/><span class="term"> 1159 <quote><code class="mallctl">prof.gdump</code></quote> 1160 (<span class="type">bool</span>) 1161 <code class="literal">rw</code> 1162 [<code class="option">--enable-prof</code>] 1163 </span></dt><dd><p>When enabled, trigger a memory profile dump every time 1164 the total virtual memory exceeds the previous maximum. Profiles are 1165 dumped to files named according to the pattern 1166 <code class="filename"><prefix>.<pid>.<seq>.u<useq>.heap</code>, 1167 where <code class="literal"><prefix></code> is controlled by the <a class="link" href="#opt.prof_prefix"><quote><code class="mallctl">opt.prof_prefix</code></quote></a> 1168 option.</p></dd><dt><a name="prof.reset"/><span class="term"> 1169 <quote><code class="mallctl">prof.reset</code></quote> 1170 (<span class="type">size_t</span>) 1171 <code class="literal">-w</code> 1172 [<code class="option">--enable-prof</code>] 1173 </span></dt><dd><p>Reset all memory profile statistics, and optionally 1174 update the sample rate (see <a class="link" href="#opt.lg_prof_sample"><quote><code class="mallctl">opt.lg_prof_sample</code></quote></a> 1175 and <a class="link" href="#prof.lg_sample"><quote><code class="mallctl">prof.lg_sample</code></quote></a>). 1176 </p></dd><dt><a name="prof.lg_sample"/><span class="term"> 1177 <quote><code class="mallctl">prof.lg_sample</code></quote> 1178 (<span class="type">size_t</span>) 1179 <code class="literal">r-</code> 1180 [<code class="option">--enable-prof</code>] 1181 </span></dt><dd><p>Get the current sample rate (see <a class="link" href="#opt.lg_prof_sample"><quote><code class="mallctl">opt.lg_prof_sample</code></quote></a>). 1182 </p></dd><dt><a name="prof.interval"/><span class="term"> 1183 <quote><code class="mallctl">prof.interval</code></quote> 1184 (<span class="type">uint64_t</span>) 1185 <code class="literal">r-</code> 1186 [<code class="option">--enable-prof</code>] 1187 </span></dt><dd><p>Average number of bytes allocated between 1188 interval-based profile dumps. See the 1189 <a class="link" href="#opt.lg_prof_interval"><quote><code class="mallctl">opt.lg_prof_interval</code></quote></a> 1190 option for additional information.</p></dd><dt><a name="stats.allocated"/><span class="term"> 1191 <quote><code class="mallctl">stats.allocated</code></quote> 1192 (<span class="type">size_t</span>) 1193 <code class="literal">r-</code> 1194 [<code class="option">--enable-stats</code>] 1195 </span></dt><dd><p>Total number of bytes allocated by the 1196 application.</p></dd><dt><a name="stats.active"/><span class="term"> 1197 <quote><code class="mallctl">stats.active</code></quote> 1198 (<span class="type">size_t</span>) 1199 <code class="literal">r-</code> 1200 [<code class="option">--enable-stats</code>] 1201 </span></dt><dd><p>Total number of bytes in active pages allocated by the 1202 application. This is a multiple of the page size, and greater than or 1203 equal to <a class="link" href="#stats.allocated"><quote><code class="mallctl">stats.allocated</code></quote></a>. 1204 This does not include <a class="link" href="#stats.arenas.i.pdirty"> 1205 <quote><code class="mallctl">stats.arenas.<i>.pdirty</code></quote></a>, 1206 <a class="link" href="#stats.arenas.i.pmuzzy"> 1207 <quote><code class="mallctl">stats.arenas.<i>.pmuzzy</code></quote></a>, nor pages 1208 entirely devoted to allocator metadata.</p></dd><dt><a name="stats.metadata"/><span class="term"> 1209 <quote><code class="mallctl">stats.metadata</code></quote> 1210 (<span class="type">size_t</span>) 1211 <code class="literal">r-</code> 1212 [<code class="option">--enable-stats</code>] 1213 </span></dt><dd><p>Total number of bytes dedicated to metadata, which 1214 comprise base allocations used for bootstrap-sensitive allocator 1215 metadata structures (see <a class="link" href="#stats.arenas.i.base"><quote><code class="mallctl">stats.arenas.<i>.base</code></quote></a>) 1216 and internal allocations (see <a class="link" href="#stats.arenas.i.internal"><quote><code class="mallctl">stats.arenas.<i>.internal</code></quote></a>). 1217 Transparent huge page (enabled with <a class="link" href="#opt.metadata_thp">opt.metadata_thp</a>) usage is not 1218 considered.</p></dd><dt><a name="stats.metadata_thp"/><span class="term"> 1219 <quote><code class="mallctl">stats.metadata_thp</code></quote> 1220 (<span class="type">size_t</span>) 1221 <code class="literal">r-</code> 1222 [<code class="option">--enable-stats</code>] 1223 </span></dt><dd><p>Number of transparent huge pages (THP) used for 1224 metadata. See <a class="link" href="#stats.metadata"><quote><code class="mallctl">stats.metadata</code></quote></a> and 1225 <a class="link" href="#opt.metadata_thp">opt.metadata_thp</a>) for 1226 details.</p></dd><dt><a name="stats.resident"/><span class="term"> 1227 <quote><code class="mallctl">stats.resident</code></quote> 1228 (<span class="type">size_t</span>) 1229 <code class="literal">r-</code> 1230 [<code class="option">--enable-stats</code>] 1231 </span></dt><dd><p>Maximum number of bytes in physically resident data 1232 pages mapped by the allocator, comprising all pages dedicated to 1233 allocator metadata, pages backing active allocations, and unused dirty 1234 pages. This is a maximum rather than precise because pages may not 1235 actually be physically resident if they correspond to demand-zeroed 1236 virtual memory that has not yet been touched. This is a multiple of the 1237 page size, and is larger than <a class="link" href="#stats.active"><quote><code class="mallctl">stats.active</code></quote></a>.</p></dd><dt><a name="stats.mapped"/><span class="term"> 1238 <quote><code class="mallctl">stats.mapped</code></quote> 1239 (<span class="type">size_t</span>) 1240 <code class="literal">r-</code> 1241 [<code class="option">--enable-stats</code>] 1242 </span></dt><dd><p>Total number of bytes in active extents mapped by the 1243 allocator. This is larger than <a class="link" href="#stats.active"><quote><code class="mallctl">stats.active</code></quote></a>. This 1244 does not include inactive extents, even those that contain unused dirty 1245 pages, which means that there is no strict ordering between this and 1246 <a class="link" href="#stats.resident"><quote><code class="mallctl">stats.resident</code></quote></a>.</p></dd><dt><a name="stats.retained"/><span class="term"> 1247 <quote><code class="mallctl">stats.retained</code></quote> 1248 (<span class="type">size_t</span>) 1249 <code class="literal">r-</code> 1250 [<code class="option">--enable-stats</code>] 1251 </span></dt><dd><p>Total number of bytes in virtual memory mappings that 1252 were retained rather than being returned to the operating system via 1253 e.g. <span class="citerefentry"><span class="refentrytitle">munmap</span>(2)</span> or similar. Retained virtual 1254 memory is typically untouched, decommitted, or purged, so it has no 1255 strongly associated physical memory (see <a class="link" href="#arena.i.extent_hooks">extent hooks</a> for details). 1256 Retained memory is excluded from mapped memory statistics, e.g. <a class="link" href="#stats.mapped"><quote><code class="mallctl">stats.mapped</code></quote></a>. 1257 </p></dd><dt><a name="stats.background_thread.num_threads"/><span class="term"> 1258 <quote><code class="mallctl">stats.background_thread.num_threads</code></quote> 1259 (<span class="type">size_t</span>) 1260 <code class="literal">r-</code> 1261 [<code class="option">--enable-stats</code>] 1262 </span></dt><dd><p> Number of <a class="link" href="#background_thread">background 1263 threads</a> running currently.</p></dd><dt><a name="stats.background_thread.num_runs"/><span class="term"> 1264 <quote><code class="mallctl">stats.background_thread.num_runs</code></quote> 1265 (<span class="type">uint64_t</span>) 1266 <code class="literal">r-</code> 1267 [<code class="option">--enable-stats</code>] 1268 </span></dt><dd><p> Total number of runs from all <a class="link" href="#background_thread">background threads</a>.</p></dd><dt><a name="stats.background_thread.run_interval"/><span class="term"> 1269 <quote><code class="mallctl">stats.background_thread.run_interval</code></quote> 1270 (<span class="type">uint64_t</span>) 1271 <code class="literal">r-</code> 1272 [<code class="option">--enable-stats</code>] 1273 </span></dt><dd><p> Average run interval in nanoseconds of <a class="link" href="#background_thread">background threads</a>.</p></dd><dt><a name="stats.mutexes.ctl"/><span class="term"> 1274 <quote><code class="mallctl">stats.mutexes.ctl.{counter};</code></quote> 1275 (<span class="type">counter specific type</span>) 1276 <code class="literal">r-</code> 1277 [<code class="option">--enable-stats</code>] 1278 </span></dt><dd><p>Statistics on <code class="varname">ctl</code> mutex (global 1279 scope; mallctl related). <quote><code class="mallctl">{counter}</code></quote> is one of the 1280 counters below:</p><dt><a name="mutex_counters"/></dt><dd><p><code class="varname">num_ops</code> (<span class="type">uint64_t</span>): 1281 Total number of lock acquisition operations on this mutex.</p><p><code class="varname">num_spin_acq</code> (<span class="type">uint64_t</span>): Number 1282 of times the mutex was spin-acquired. When the mutex is currently 1283 locked and cannot be acquired immediately, a short period of 1284 spin-retry within jemalloc will be performed. Acquired through spin 1285 generally means the contention was lightweight and not causing context 1286 switches.</p><p><code class="varname">num_wait</code> (<span class="type">uint64_t</span>): Number of 1287 times the mutex was wait-acquired, which means the mutex contention 1288 was not solved by spin-retry, and blocking operation was likely 1289 involved in order to acquire the mutex. This event generally implies 1290 higher cost / longer delay, and should be investigated if it happens 1291 often.</p><p><code class="varname">max_wait_time</code> (<span class="type">uint64_t</span>): 1292 Maximum length of time in nanoseconds spent on a single wait-acquired 1293 lock operation. Note that to avoid profiling overhead on the common 1294 path, this does not consider spin-acquired cases.</p><p><code class="varname">total_wait_time</code> (<span class="type">uint64_t</span>): 1295 Cumulative time in nanoseconds spent on wait-acquired lock operations. 1296 Similarly, spin-acquired cases are not considered.</p><p><code class="varname">max_num_thds</code> (<span class="type">uint32_t</span>): Maximum 1297 number of threads waiting on this mutex simultaneously. Similarly, 1298 spin-acquired cases are not considered.</p><p><code class="varname">num_owner_switch</code> (<span class="type">uint64_t</span>): 1299 Number of times the current mutex owner is different from the previous 1300 one. This event does not generally imply an issue; rather it is an 1301 indicator of how often the protected data are accessed by different 1302 threads. 1303 </p></dd></dd><dt><a name="stats.mutexes.background_thread"/><span class="term"> 1304 <quote><code class="mallctl">stats.mutexes.background_thread.{counter}</code></quote> 1305 (<span class="type">counter specific type</span>) <code class="literal">r-</code> 1306 [<code class="option">--enable-stats</code>] 1307 </span></dt><dd><p>Statistics on <code class="varname">background_thread</code> mutex 1308 (global scope; <a class="link" href="#background_thread"><quote><code class="mallctl">background_thread</code></quote></a> 1309 related). <quote><code class="mallctl">{counter}</code></quote> is one of the counters in <a class="link" href="#mutex_counters">mutex profiling 1310 counters</a>.</p></dd><dt><a name="stats.mutexes.prof"/><span class="term"> 1311 <quote><code class="mallctl">stats.mutexes.prof.{counter}</code></quote> 1312 (<span class="type">counter specific type</span>) <code class="literal">r-</code> 1313 [<code class="option">--enable-stats</code>] 1314 </span></dt><dd><p>Statistics on <code class="varname">prof</code> mutex (global 1315 scope; profiling related). <quote><code class="mallctl">{counter}</code></quote> is one of the 1316 counters in <a class="link" href="#mutex_counters">mutex profiling 1317 counters</a>.</p></dd><dt><a name="stats.mutexes.reset"/><span class="term"> 1318 <quote><code class="mallctl">stats.mutexes.reset</code></quote> 1319 (<span class="type">void</span>) <code class="literal">--</code> 1320 [<code class="option">--enable-stats</code>] 1321 </span></dt><dd><p>Reset all mutex profile statistics, including global 1322 mutexes, arena mutexes and bin mutexes.</p></dd><dt><a name="stats.arenas.i.dss"/><span class="term"> 1323 <quote><code class="mallctl">stats.arenas.<i>.dss</code></quote> 1324 (<span class="type">const char *</span>) 1325 <code class="literal">r-</code> 1326 </span></dt><dd><p>dss (<span class="citerefentry"><span class="refentrytitle">sbrk</span>(2)</span>) allocation precedence as 1327 related to <span class="citerefentry"><span class="refentrytitle">mmap</span>(2)</span> allocation. See <a class="link" href="#opt.dss"><quote><code class="mallctl">opt.dss</code></quote></a> for details. 1328 </p></dd><dt><a name="stats.arenas.i.dirty_decay_ms"/><span class="term"> 1329 <quote><code class="mallctl">stats.arenas.<i>.dirty_decay_ms</code></quote> 1330 (<span class="type">ssize_t</span>) 1331 <code class="literal">r-</code> 1332 </span></dt><dd><p>Approximate time in milliseconds from the creation of a 1333 set of unused dirty pages until an equivalent set of unused dirty pages 1334 is purged and/or reused. See <a class="link" href="#opt.dirty_decay_ms"><quote><code class="mallctl">opt.dirty_decay_ms</code></quote></a> 1335 for details.</p></dd><dt><a name="stats.arenas.i.muzzy_decay_ms"/><span class="term"> 1336 <quote><code class="mallctl">stats.arenas.<i>.muzzy_decay_ms</code></quote> 1337 (<span class="type">ssize_t</span>) 1338 <code class="literal">r-</code> 1339 </span></dt><dd><p>Approximate time in milliseconds from the creation of a 1340 set of unused muzzy pages until an equivalent set of unused muzzy pages 1341 is purged and/or reused. See <a class="link" href="#opt.muzzy_decay_ms"><quote><code class="mallctl">opt.muzzy_decay_ms</code></quote></a> 1342 for details.</p></dd><dt><a name="stats.arenas.i.nthreads"/><span class="term"> 1343 <quote><code class="mallctl">stats.arenas.<i>.nthreads</code></quote> 1344 (<span class="type">unsigned</span>) 1345 <code class="literal">r-</code> 1346 </span></dt><dd><p>Number of threads currently assigned to 1347 arena.</p></dd><dt><a name="stats.arenas.i.uptime"/><span class="term"> 1348 <quote><code class="mallctl">stats.arenas.<i>.uptime</code></quote> 1349 (<span class="type">uint64_t</span>) 1350 <code class="literal">r-</code> 1351 </span></dt><dd><p>Time elapsed (in nanoseconds) since the arena was 1352 created. If <i> equals <code class="constant">0</code> or 1353 <code class="constant">MALLCTL_ARENAS_ALL</code>, this is the uptime since malloc 1354 initialization.</p></dd><dt><a name="stats.arenas.i.pactive"/><span class="term"> 1355 <quote><code class="mallctl">stats.arenas.<i>.pactive</code></quote> 1356 (<span class="type">size_t</span>) 1357 <code class="literal">r-</code> 1358 </span></dt><dd><p>Number of pages in active extents.</p></dd><dt><a name="stats.arenas.i.pdirty"/><span class="term"> 1359 <quote><code class="mallctl">stats.arenas.<i>.pdirty</code></quote> 1360 (<span class="type">size_t</span>) 1361 <code class="literal">r-</code> 1362 </span></dt><dd><p>Number of pages within unused extents that are 1363 potentially dirty, and for which <code class="function">madvise()</code> or 1364 similar has not been called. See <a class="link" href="#opt.dirty_decay_ms"><quote><code class="mallctl">opt.dirty_decay_ms</code></quote></a> 1365 for a description of dirty pages.</p></dd><dt><a name="stats.arenas.i.pmuzzy"/><span class="term"> 1366 <quote><code class="mallctl">stats.arenas.<i>.pmuzzy</code></quote> 1367 (<span class="type">size_t</span>) 1368 <code class="literal">r-</code> 1369 </span></dt><dd><p>Number of pages within unused extents that are muzzy. 1370 See <a class="link" href="#opt.muzzy_decay_ms"><quote><code class="mallctl">opt.muzzy_decay_ms</code></quote></a> 1371 for a description of muzzy pages.</p></dd><dt><a name="stats.arenas.i.mapped"/><span class="term"> 1372 <quote><code class="mallctl">stats.arenas.<i>.mapped</code></quote> 1373 (<span class="type">size_t</span>) 1374 <code class="literal">r-</code> 1375 [<code class="option">--enable-stats</code>] 1376 </span></dt><dd><p>Number of mapped bytes.</p></dd><dt><a name="stats.arenas.i.retained"/><span class="term"> 1377 <quote><code class="mallctl">stats.arenas.<i>.retained</code></quote> 1378 (<span class="type">size_t</span>) 1379 <code class="literal">r-</code> 1380 [<code class="option">--enable-stats</code>] 1381 </span></dt><dd><p>Number of retained bytes. See <a class="link" href="#stats.retained"><quote><code class="mallctl">stats.retained</code></quote></a> for 1382 details.</p></dd><dt><a name="stats.arenas.i.base"/><span class="term"> 1383 <quote><code class="mallctl">stats.arenas.<i>.base</code></quote> 1384 (<span class="type">size_t</span>) 1385 <code class="literal">r-</code> 1386 [<code class="option">--enable-stats</code>] 1387 </span></dt><dd><p> 1388 Number of bytes dedicated to bootstrap-sensitive allocator metadata 1389 structures.</p></dd><dt><a name="stats.arenas.i.internal"/><span class="term"> 1390 <quote><code class="mallctl">stats.arenas.<i>.internal</code></quote> 1391 (<span class="type">size_t</span>) 1392 <code class="literal">r-</code> 1393 [<code class="option">--enable-stats</code>] 1394 </span></dt><dd><p>Number of bytes dedicated to internal allocations. 1395 Internal allocations differ from application-originated allocations in 1396 that they are for internal use, and that they are omitted from heap 1397 profiles.</p></dd><dt><a name="stats.arenas.i.metadata_thp"/><span class="term"> 1398 <quote><code class="mallctl">stats.arenas.<i>.metadata_thp</code></quote> 1399 (<span class="type">size_t</span>) 1400 <code class="literal">r-</code> 1401 [<code class="option">--enable-stats</code>] 1402 </span></dt><dd><p>Number of transparent huge pages (THP) used for 1403 metadata. See <a class="link" href="#opt.metadata_thp">opt.metadata_thp</a> 1404 for details.</p></dd><dt><a name="stats.arenas.i.resident"/><span class="term"> 1405 <quote><code class="mallctl">stats.arenas.<i>.resident</code></quote> 1406 (<span class="type">size_t</span>) 1407 <code class="literal">r-</code> 1408 [<code class="option">--enable-stats</code>] 1409 </span></dt><dd><p>Maximum number of bytes in physically resident data 1410 pages mapped by the arena, comprising all pages dedicated to allocator 1411 metadata, pages backing active allocations, and unused dirty pages. 1412 This is a maximum rather than precise because pages may not actually be 1413 physically resident if they correspond to demand-zeroed virtual memory 1414 that has not yet been touched. This is a multiple of the page 1415 size.</p></dd><dt><a name="stats.arenas.i.dirty_npurge"/><span class="term"> 1416 <quote><code class="mallctl">stats.arenas.<i>.dirty_npurge</code></quote> 1417 (<span class="type">uint64_t</span>) 1418 <code class="literal">r-</code> 1419 [<code class="option">--enable-stats</code>] 1420 </span></dt><dd><p>Number of dirty page purge sweeps performed. 1421 </p></dd><dt><a name="stats.arenas.i.dirty_nmadvise"/><span class="term"> 1422 <quote><code class="mallctl">stats.arenas.<i>.dirty_nmadvise</code></quote> 1423 (<span class="type">uint64_t</span>) 1424 <code class="literal">r-</code> 1425 [<code class="option">--enable-stats</code>] 1426 </span></dt><dd><p>Number of <code class="function">madvise()</code> or similar 1427 calls made to purge dirty pages.</p></dd><dt><a name="stats.arenas.i.dirty_purged"/><span class="term"> 1428 <quote><code class="mallctl">stats.arenas.<i>.dirty_purged</code></quote> 1429 (<span class="type">uint64_t</span>) 1430 <code class="literal">r-</code> 1431 [<code class="option">--enable-stats</code>] 1432 </span></dt><dd><p>Number of dirty pages purged.</p></dd><dt><a name="stats.arenas.i.muzzy_npurge"/><span class="term"> 1433 <quote><code class="mallctl">stats.arenas.<i>.muzzy_npurge</code></quote> 1434 (<span class="type">uint64_t</span>) 1435 <code class="literal">r-</code> 1436 [<code class="option">--enable-stats</code>] 1437 </span></dt><dd><p>Number of muzzy page purge sweeps performed. 1438 </p></dd><dt><a name="stats.arenas.i.muzzy_nmadvise"/><span class="term"> 1439 <quote><code class="mallctl">stats.arenas.<i>.muzzy_nmadvise</code></quote> 1440 (<span class="type">uint64_t</span>) 1441 <code class="literal">r-</code> 1442 [<code class="option">--enable-stats</code>] 1443 </span></dt><dd><p>Number of <code class="function">madvise()</code> or similar 1444 calls made to purge muzzy pages.</p></dd><dt><a name="stats.arenas.i.muzzy_purged"/><span class="term"> 1445 <quote><code class="mallctl">stats.arenas.<i>.muzzy_purged</code></quote> 1446 (<span class="type">uint64_t</span>) 1447 <code class="literal">r-</code> 1448 [<code class="option">--enable-stats</code>] 1449 </span></dt><dd><p>Number of muzzy pages purged.</p></dd><dt><a name="stats.arenas.i.small.allocated"/><span class="term"> 1450 <quote><code class="mallctl">stats.arenas.<i>.small.allocated</code></quote> 1451 (<span class="type">size_t</span>) 1452 <code class="literal">r-</code> 1453 [<code class="option">--enable-stats</code>] 1454 </span></dt><dd><p>Number of bytes currently allocated by small objects. 1455 </p></dd><dt><a name="stats.arenas.i.small.nmalloc"/><span class="term"> 1456 <quote><code class="mallctl">stats.arenas.<i>.small.nmalloc</code></quote> 1457 (<span class="type">uint64_t</span>) 1458 <code class="literal">r-</code> 1459 [<code class="option">--enable-stats</code>] 1460 </span></dt><dd><p>Cumulative number of times a small allocation was 1461 requested from the arena's bins, whether to fill the relevant tcache if 1462 <a class="link" href="#opt.tcache"><quote><code class="mallctl">opt.tcache</code></quote></a> is 1463 enabled, or to directly satisfy an allocation request 1464 otherwise.</p></dd><dt><a name="stats.arenas.i.small.ndalloc"/><span class="term"> 1465 <quote><code class="mallctl">stats.arenas.<i>.small.ndalloc</code></quote> 1466 (<span class="type">uint64_t</span>) 1467 <code class="literal">r-</code> 1468 [<code class="option">--enable-stats</code>] 1469 </span></dt><dd><p>Cumulative number of times a small allocation was 1470 returned to the arena's bins, whether to flush the relevant tcache if 1471 <a class="link" href="#opt.tcache"><quote><code class="mallctl">opt.tcache</code></quote></a> is 1472 enabled, or to directly deallocate an allocation 1473 otherwise.</p></dd><dt><a name="stats.arenas.i.small.nrequests"/><span class="term"> 1474 <quote><code class="mallctl">stats.arenas.<i>.small.nrequests</code></quote> 1475 (<span class="type">uint64_t</span>) 1476 <code class="literal">r-</code> 1477 [<code class="option">--enable-stats</code>] 1478 </span></dt><dd><p>Cumulative number of allocation requests satisfied by 1479 all bin size classes.</p></dd><dt><a name="stats.arenas.i.large.allocated"/><span class="term"> 1480 <quote><code class="mallctl">stats.arenas.<i>.large.allocated</code></quote> 1481 (<span class="type">size_t</span>) 1482 <code class="literal">r-</code> 1483 [<code class="option">--enable-stats</code>] 1484 </span></dt><dd><p>Number of bytes currently allocated by large objects. 1485 </p></dd><dt><a name="stats.arenas.i.large.nmalloc"/><span class="term"> 1486 <quote><code class="mallctl">stats.arenas.<i>.large.nmalloc</code></quote> 1487 (<span class="type">uint64_t</span>) 1488 <code class="literal">r-</code> 1489 [<code class="option">--enable-stats</code>] 1490 </span></dt><dd><p>Cumulative number of times a large extent was allocated 1491 from the arena, whether to fill the relevant tcache if <a class="link" href="#opt.tcache"><quote><code class="mallctl">opt.tcache</code></quote></a> is enabled and 1492 the size class is within the range being cached, or to directly satisfy 1493 an allocation request otherwise.</p></dd><dt><a name="stats.arenas.i.large.ndalloc"/><span class="term"> 1494 <quote><code class="mallctl">stats.arenas.<i>.large.ndalloc</code></quote> 1495 (<span class="type">uint64_t</span>) 1496 <code class="literal">r-</code> 1497 [<code class="option">--enable-stats</code>] 1498 </span></dt><dd><p>Cumulative number of times a large extent was returned 1499 to the arena, whether to flush the relevant tcache if <a class="link" href="#opt.tcache"><quote><code class="mallctl">opt.tcache</code></quote></a> is enabled and 1500 the size class is within the range being cached, or to directly 1501 deallocate an allocation otherwise.</p></dd><dt><a name="stats.arenas.i.large.nrequests"/><span class="term"> 1502 <quote><code class="mallctl">stats.arenas.<i>.large.nrequests</code></quote> 1503 (<span class="type">uint64_t</span>) 1504 <code class="literal">r-</code> 1505 [<code class="option">--enable-stats</code>] 1506 </span></dt><dd><p>Cumulative number of allocation requests satisfied by 1507 all large size classes.</p></dd><dt><a name="stats.arenas.i.bins.j.nmalloc"/><span class="term"> 1508 <quote><code class="mallctl">stats.arenas.<i>.bins.<j>.nmalloc</code></quote> 1509 (<span class="type">uint64_t</span>) 1510 <code class="literal">r-</code> 1511 [<code class="option">--enable-stats</code>] 1512 </span></dt><dd><p>Cumulative number of times a bin region of the 1513 corresponding size class was allocated from the arena, whether to fill 1514 the relevant tcache if <a class="link" href="#opt.tcache"><quote><code class="mallctl">opt.tcache</code></quote></a> is enabled, or 1515 to directly satisfy an allocation request otherwise.</p></dd><dt><a name="stats.arenas.i.bins.j.ndalloc"/><span class="term"> 1516 <quote><code class="mallctl">stats.arenas.<i>.bins.<j>.ndalloc</code></quote> 1517 (<span class="type">uint64_t</span>) 1518 <code class="literal">r-</code> 1519 [<code class="option">--enable-stats</code>] 1520 </span></dt><dd><p>Cumulative number of times a bin region of the 1521 corresponding size class was returned to the arena, whether to flush the 1522 relevant tcache if <a class="link" href="#opt.tcache"><quote><code class="mallctl">opt.tcache</code></quote></a> is enabled, or 1523 to directly deallocate an allocation otherwise.</p></dd><dt><a name="stats.arenas.i.bins.j.nrequests"/><span class="term"> 1524 <quote><code class="mallctl">stats.arenas.<i>.bins.<j>.nrequests</code></quote> 1525 (<span class="type">uint64_t</span>) 1526 <code class="literal">r-</code> 1527 [<code class="option">--enable-stats</code>] 1528 </span></dt><dd><p>Cumulative number of allocation requests satisfied by 1529 bin regions of the corresponding size class.</p></dd><dt><a name="stats.arenas.i.bins.j.curregs"/><span class="term"> 1530 <quote><code class="mallctl">stats.arenas.<i>.bins.<j>.curregs</code></quote> 1531 (<span class="type">size_t</span>) 1532 <code class="literal">r-</code> 1533 [<code class="option">--enable-stats</code>] 1534 </span></dt><dd><p>Current number of regions for this size 1535 class.</p></dd><dt><a name="stats.arenas.i.bins.j.nfills"/><span class="term"> 1536 <quote><code class="mallctl">stats.arenas.<i>.bins.<j>.nfills</code></quote> 1537 (<span class="type">uint64_t</span>) 1538 <code class="literal">r-</code> 1539 </span></dt><dd><p>Cumulative number of tcache fills.</p></dd><dt><a name="stats.arenas.i.bins.j.nflushes"/><span class="term"> 1540 <quote><code class="mallctl">stats.arenas.<i>.bins.<j>.nflushes</code></quote> 1541 (<span class="type">uint64_t</span>) 1542 <code class="literal">r-</code> 1543 </span></dt><dd><p>Cumulative number of tcache flushes.</p></dd><dt><a name="stats.arenas.i.bins.j.nslabs"/><span class="term"> 1544 <quote><code class="mallctl">stats.arenas.<i>.bins.<j>.nslabs</code></quote> 1545 (<span class="type">uint64_t</span>) 1546 <code class="literal">r-</code> 1547 [<code class="option">--enable-stats</code>] 1548 </span></dt><dd><p>Cumulative number of slabs created.</p></dd><dt><a name="stats.arenas.i.bins.j.nreslabs"/><span class="term"> 1549 <quote><code class="mallctl">stats.arenas.<i>.bins.<j>.nreslabs</code></quote> 1550 (<span class="type">uint64_t</span>) 1551 <code class="literal">r-</code> 1552 [<code class="option">--enable-stats</code>] 1553 </span></dt><dd><p>Cumulative number of times the current slab from which 1554 to allocate changed.</p></dd><dt><a name="stats.arenas.i.bins.j.curslabs"/><span class="term"> 1555 <quote><code class="mallctl">stats.arenas.<i>.bins.<j>.curslabs</code></quote> 1556 (<span class="type">size_t</span>) 1557 <code class="literal">r-</code> 1558 [<code class="option">--enable-stats</code>] 1559 </span></dt><dd><p>Current number of slabs.</p></dd><dt><a name="stats.arenas.i.bins.mutex"/><span class="term"> 1560 <quote><code class="mallctl">stats.arenas.<i>.bins.<j>.mutex.{counter}</code></quote> 1561 (<span class="type">counter specific type</span>) <code class="literal">r-</code> 1562 [<code class="option">--enable-stats</code>] 1563 </span></dt><dd><p>Statistics on 1564 <code class="varname">arena.<i>.bins.<j></code> mutex (arena bin 1565 scope; bin operation related). <quote><code class="mallctl">{counter}</code></quote> is one of 1566 the counters in <a class="link" href="#mutex_counters">mutex profiling 1567 counters</a>.</p></dd><dt><a name="stats.arenas.i.lextents.j.nmalloc"/><span class="term"> 1568 <quote><code class="mallctl">stats.arenas.<i>.lextents.<j>.nmalloc</code></quote> 1569 (<span class="type">uint64_t</span>) 1570 <code class="literal">r-</code> 1571 [<code class="option">--enable-stats</code>] 1572 </span></dt><dd><p>Cumulative number of times a large extent of the 1573 corresponding size class was allocated from the arena, whether to fill 1574 the relevant tcache if <a class="link" href="#opt.tcache"><quote><code class="mallctl">opt.tcache</code></quote></a> is enabled and 1575 the size class is within the range being cached, or to directly satisfy 1576 an allocation request otherwise.</p></dd><dt><a name="stats.arenas.i.lextents.j.ndalloc"/><span class="term"> 1577 <quote><code class="mallctl">stats.arenas.<i>.lextents.<j>.ndalloc</code></quote> 1578 (<span class="type">uint64_t</span>) 1579 <code class="literal">r-</code> 1580 [<code class="option">--enable-stats</code>] 1581 </span></dt><dd><p>Cumulative number of times a large extent of the 1582 corresponding size class was returned to the arena, whether to flush the 1583 relevant tcache if <a class="link" href="#opt.tcache"><quote><code class="mallctl">opt.tcache</code></quote></a> is enabled and 1584 the size class is within the range being cached, or to directly 1585 deallocate an allocation otherwise.</p></dd><dt><a name="stats.arenas.i.lextents.j.nrequests"/><span class="term"> 1586 <quote><code class="mallctl">stats.arenas.<i>.lextents.<j>.nrequests</code></quote> 1587 (<span class="type">uint64_t</span>) 1588 <code class="literal">r-</code> 1589 [<code class="option">--enable-stats</code>] 1590 </span></dt><dd><p>Cumulative number of allocation requests satisfied by 1591 large extents of the corresponding size class.</p></dd><dt><a name="stats.arenas.i.lextents.j.curlextents"/><span class="term"> 1592 <quote><code class="mallctl">stats.arenas.<i>.lextents.<j>.curlextents</code></quote> 1593 (<span class="type">size_t</span>) 1594 <code class="literal">r-</code> 1595 [<code class="option">--enable-stats</code>] 1596 </span></dt><dd><p>Current number of large allocations for this size class. 1597 </p></dd><dt><a name="stats.arenas.i.mutexes.large"/><span class="term"> 1598 <quote><code class="mallctl">stats.arenas.<i>.mutexes.large.{counter}</code></quote> 1599 (<span class="type">counter specific type</span>) <code class="literal">r-</code> 1600 [<code class="option">--enable-stats</code>] 1601 </span></dt><dd><p>Statistics on <code class="varname">arena.<i>.large</code> 1602 mutex (arena scope; large allocation related). 1603 <quote><code class="mallctl">{counter}</code></quote> is one of the counters in <a class="link" href="#mutex_counters">mutex profiling 1604 counters</a>.</p></dd><dt><a name="stats.arenas.i.mutexes.extent_avail"/><span class="term"> 1605 <quote><code class="mallctl">stats.arenas.<i>.mutexes.extent_avail.{counter}</code></quote> 1606 (<span class="type">counter specific type</span>) <code class="literal">r-</code> 1607 [<code class="option">--enable-stats</code>] 1608 </span></dt><dd><p>Statistics on <code class="varname">arena.<i>.extent_avail 1609 </code> mutex (arena scope; extent avail related). 1610 <quote><code class="mallctl">{counter}</code></quote> is one of the counters in <a class="link" href="#mutex_counters">mutex profiling 1611 counters</a>.</p></dd><dt><a name="stats.arenas.i.mutexes.extents_dirty"/><span class="term"> 1612 <quote><code class="mallctl">stats.arenas.<i>.mutexes.extents_dirty.{counter}</code></quote> 1613 (<span class="type">counter specific type</span>) <code class="literal">r-</code> 1614 [<code class="option">--enable-stats</code>] 1615 </span></dt><dd><p>Statistics on <code class="varname">arena.<i>.extents_dirty 1616 </code> mutex (arena scope; dirty extents related). 1617 <quote><code class="mallctl">{counter}</code></quote> is one of the counters in <a class="link" href="#mutex_counters">mutex profiling 1618 counters</a>.</p></dd><dt><a name="stats.arenas.i.mutexes.extents_muzzy"/><span class="term"> 1619 <quote><code class="mallctl">stats.arenas.<i>.mutexes.extents_muzzy.{counter}</code></quote> 1620 (<span class="type">counter specific type</span>) <code class="literal">r-</code> 1621 [<code class="option">--enable-stats</code>] 1622 </span></dt><dd><p>Statistics on <code class="varname">arena.<i>.extents_muzzy 1623 </code> mutex (arena scope; muzzy extents related). 1624 <quote><code class="mallctl">{counter}</code></quote> is one of the counters in <a class="link" href="#mutex_counters">mutex profiling 1625 counters</a>.</p></dd><dt><a name="stats.arenas.i.mutexes.extents_retained"/><span class="term"> 1626 <quote><code class="mallctl">stats.arenas.<i>.mutexes.extents_retained.{counter}</code></quote> 1627 (<span class="type">counter specific type</span>) <code class="literal">r-</code> 1628 [<code class="option">--enable-stats</code>] 1629 </span></dt><dd><p>Statistics on <code class="varname">arena.<i>.extents_retained 1630 </code> mutex (arena scope; retained extents related). 1631 <quote><code class="mallctl">{counter}</code></quote> is one of the counters in <a class="link" href="#mutex_counters">mutex profiling 1632 counters</a>.</p></dd><dt><a name="stats.arenas.i.mutexes.decay_dirty"/><span class="term"> 1633 <quote><code class="mallctl">stats.arenas.<i>.mutexes.decay_dirty.{counter}</code></quote> 1634 (<span class="type">counter specific type</span>) <code class="literal">r-</code> 1635 [<code class="option">--enable-stats</code>] 1636 </span></dt><dd><p>Statistics on <code class="varname">arena.<i>.decay_dirty 1637 </code> mutex (arena scope; decay for dirty pages related). 1638 <quote><code class="mallctl">{counter}</code></quote> is one of the counters in <a class="link" href="#mutex_counters">mutex profiling 1639 counters</a>.</p></dd><dt><a name="stats.arenas.i.mutexes.decay_muzzy"/><span class="term"> 1640 <quote><code class="mallctl">stats.arenas.<i>.mutexes.decay_muzzy.{counter}</code></quote> 1641 (<span class="type">counter specific type</span>) <code class="literal">r-</code> 1642 [<code class="option">--enable-stats</code>] 1643 </span></dt><dd><p>Statistics on <code class="varname">arena.<i>.decay_muzzy 1644 </code> mutex (arena scope; decay for muzzy pages related). 1645 <quote><code class="mallctl">{counter}</code></quote> is one of the counters in <a class="link" href="#mutex_counters">mutex profiling 1646 counters</a>.</p></dd><dt><a name="stats.arenas.i.mutexes.base"/><span class="term"> 1647 <quote><code class="mallctl">stats.arenas.<i>.mutexes.base.{counter}</code></quote> 1648 (<span class="type">counter specific type</span>) <code class="literal">r-</code> 1649 [<code class="option">--enable-stats</code>] 1650 </span></dt><dd><p>Statistics on <code class="varname">arena.<i>.base</code> 1651 mutex (arena scope; base allocator related). 1652 <quote><code class="mallctl">{counter}</code></quote> is one of the counters in <a class="link" href="#mutex_counters">mutex profiling 1653 counters</a>.</p></dd><dt><a name="stats.arenas.i.mutexes.tcache_list"/><span class="term"> 1654 <quote><code class="mallctl">stats.arenas.<i>.mutexes.tcache_list.{counter}</code></quote> 1655 (<span class="type">counter specific type</span>) <code class="literal">r-</code> 1656 [<code class="option">--enable-stats</code>] 1657 </span></dt><dd><p>Statistics on 1658 <code class="varname">arena.<i>.tcache_list</code> mutex (arena scope; 1659 tcache to arena association related). This mutex is expected to be 1660 accessed less often. <quote><code class="mallctl">{counter}</code></quote> is one of the 1661 counters in <a class="link" href="#mutex_counters">mutex profiling 1662 counters</a>.</p></dd></dl></div></div><div class="refsect1"><a name="heap_profile_format"/><h2>HEAP PROFILE FORMAT</h2><p>Although the heap profiling functionality was originally designed to 1663 be compatible with the 1664 <span class="command"><strong>pprof</strong></span> command that is developed as part of the <a class="ulink" href="http://code.google.com/p/gperftools/" target="_top">gperftools 1665 package</a>, the addition of per thread heap profiling functionality 1666 required a different heap profile format. The <span class="command"><strong>jeprof</strong></span> 1667 command is derived from <span class="command"><strong>pprof</strong></span>, with enhancements to 1668 support the heap profile format described here.</p><p>In the following hypothetical heap profile, <code class="constant">[...]</code> 1669 indicates elision for the sake of compactness. </p><pre class="programlisting"> 1670heap_v2/524288 1671 t*: 28106: 56637512 [0: 0] 1672 [...] 1673 t3: 352: 16777344 [0: 0] 1674 [...] 1675 t99: 17754: 29341640 [0: 0] 1676 [...] 1677@ 0x5f86da8 0x5f5a1dc [...] 0x29e4d4e 0xa200316 0xabb2988 [...] 1678 t*: 13: 6688 [0: 0] 1679 t3: 12: 6496 [0: ] 1680 t99: 1: 192 [0: 0] 1681[...] 1682 1683MAPPED_LIBRARIES: 1684[...]</pre><p> The following matches the above heap profile, but most 1685tokens are replaced with <code class="constant"><description></code> to indicate 1686descriptions of the corresponding fields. </p><pre class="programlisting"> 1687<heap_profile_format_version>/<mean_sample_interval> 1688 <aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>] 1689 [...] 1690 <thread_3_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>] 1691 [...] 1692 <thread_99_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>] 1693 [...] 1694@ <top_frame> <frame> [...] <frame> <frame> <frame> [...] 1695 <backtrace_aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>] 1696 <backtrace_thread_3>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>] 1697 <backtrace_thread_99>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>] 1698[...] 1699 1700MAPPED_LIBRARIES: 1701</proc/<pid>/maps></pre></div><div class="refsect1"><a name="debugging_malloc_problems"/><h2>DEBUGGING MALLOC PROBLEMS</h2><p>When debugging, it is a good idea to configure/build jemalloc with 1702 the <code class="option">--enable-debug</code> and <code class="option">--enable-fill</code> 1703 options, and recompile the program with suitable options and symbols for 1704 debugger support. When so configured, jemalloc incorporates a wide variety 1705 of run-time assertions that catch application errors such as double-free, 1706 write-after-free, etc.</p><p>Programs often accidentally depend on <span class="quote">“<span class="quote">uninitialized</span>”</span> 1707 memory actually being filled with zero bytes. Junk filling 1708 (see the <a class="link" href="#opt.junk"><quote><code class="mallctl">opt.junk</code></quote></a> 1709 option) tends to expose such bugs in the form of obviously incorrect 1710 results and/or coredumps. Conversely, zero 1711 filling (see the <a class="link" href="#opt.zero"><quote><code class="mallctl">opt.zero</code></quote></a> option) eliminates 1712 the symptoms of such bugs. Between these two options, it is usually 1713 possible to quickly detect, diagnose, and eliminate such bugs.</p><p>This implementation does not provide much detail about the problems 1714 it detects, because the performance impact for storing such information 1715 would be prohibitive.</p></div><div class="refsect1"><a name="diagnostic_messages"/><h2>DIAGNOSTIC MESSAGES</h2><p>If any of the memory allocation/deallocation functions detect an 1716 error or warning condition, a message will be printed to file descriptor 1717 <code class="constant">STDERR_FILENO</code>. Errors will result in the process 1718 dumping core. If the <a class="link" href="#opt.abort"><quote><code class="mallctl">opt.abort</code></quote></a> option is set, most 1719 warnings are treated as errors.</p><p>The <code class="varname">malloc_message</code> variable allows the programmer 1720 to override the function which emits the text strings forming the errors 1721 and warnings if for some reason the <code class="constant">STDERR_FILENO</code> file 1722 descriptor is not suitable for this. 1723 <code class="function">malloc_message()</code> takes the 1724 <em class="parameter"><code>cbopaque</code></em> pointer argument that is 1725 <code class="constant">NULL</code> unless overridden by the arguments in a call to 1726 <code class="function">malloc_stats_print()</code>, followed by a string 1727 pointer. Please note that doing anything which tries to allocate memory in 1728 this function is likely to result in a crash or deadlock.</p><p>All messages are prefixed by 1729 <span class="quote">“<span class="quote"><code class="computeroutput"><jemalloc>: </code></span>”</span>.</p></div><div class="refsect1"><a name="return_values"/><h2>RETURN VALUES</h2><div class="refsect2"><a name="idm140689764475728"/><h3>Standard API</h3><p>The <code class="function">malloc()</code> and 1730 <code class="function">calloc()</code> functions return a pointer to the 1731 allocated memory if successful; otherwise a <code class="constant">NULL</code> 1732 pointer is returned and <code class="varname">errno</code> is set to 1733 <span class="errorname">ENOMEM</span>.</p><p>The <code class="function">posix_memalign()</code> function 1734 returns the value 0 if successful; otherwise it returns an error value. 1735 The <code class="function">posix_memalign()</code> function will fail 1736 if: 1737 </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorname">EINVAL</span></span></dt><dd><p>The <em class="parameter"><code>alignment</code></em> parameter is 1738 not a power of 2 at least as large as 1739 <code class="code">sizeof(<span class="type">void *</span>)</code>. 1740 </p></dd><dt><span class="term"><span class="errorname">ENOMEM</span></span></dt><dd><p>Memory allocation error.</p></dd></dl></div><p> 1741 </p><p>The <code class="function">aligned_alloc()</code> function returns 1742 a pointer to the allocated memory if successful; otherwise a 1743 <code class="constant">NULL</code> pointer is returned and 1744 <code class="varname">errno</code> is set. The 1745 <code class="function">aligned_alloc()</code> function will fail if: 1746 </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorname">EINVAL</span></span></dt><dd><p>The <em class="parameter"><code>alignment</code></em> parameter is 1747 not a power of 2. 1748 </p></dd><dt><span class="term"><span class="errorname">ENOMEM</span></span></dt><dd><p>Memory allocation error.</p></dd></dl></div><p> 1749 </p><p>The <code class="function">realloc()</code> function returns a 1750 pointer, possibly identical to <em class="parameter"><code>ptr</code></em>, to the 1751 allocated memory if successful; otherwise a <code class="constant">NULL</code> 1752 pointer is returned, and <code class="varname">errno</code> is set to 1753 <span class="errorname">ENOMEM</span> if the error was the result of an 1754 allocation failure. The <code class="function">realloc()</code> 1755 function always leaves the original buffer intact when an error occurs. 1756 </p><p>The <code class="function">free()</code> function returns no 1757 value.</p></div><div class="refsect2"><a name="idm140689764454240"/><h3>Non-standard API</h3><p>The <code class="function">mallocx()</code> and 1758 <code class="function">rallocx()</code> functions return a pointer to 1759 the allocated memory if successful; otherwise a <code class="constant">NULL</code> 1760 pointer is returned to indicate insufficient contiguous memory was 1761 available to service the allocation request. </p><p>The <code class="function">xallocx()</code> function returns the 1762 real size of the resulting resized allocation pointed to by 1763 <em class="parameter"><code>ptr</code></em>, which is a value less than 1764 <em class="parameter"><code>size</code></em> if the allocation could not be adequately 1765 grown in place. </p><p>The <code class="function">sallocx()</code> function returns the 1766 real size of the allocation pointed to by <em class="parameter"><code>ptr</code></em>. 1767 </p><p>The <code class="function">nallocx()</code> returns the real size 1768 that would result from a successful equivalent 1769 <code class="function">mallocx()</code> function call, or zero if 1770 insufficient memory is available to perform the size computation. </p><p>The <code class="function">mallctl()</code>, 1771 <code class="function">mallctlnametomib()</code>, and 1772 <code class="function">mallctlbymib()</code> functions return 0 on 1773 success; otherwise they return an error value. The functions will fail 1774 if: 1775 </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorname">EINVAL</span></span></dt><dd><p><em class="parameter"><code>newp</code></em> is not 1776 <code class="constant">NULL</code>, and <em class="parameter"><code>newlen</code></em> is too 1777 large or too small. Alternatively, <em class="parameter"><code>*oldlenp</code></em> 1778 is too large or too small; in this case as much data as possible 1779 are read despite the error.</p></dd><dt><span class="term"><span class="errorname">ENOENT</span></span></dt><dd><p><em class="parameter"><code>name</code></em> or 1780 <em class="parameter"><code>mib</code></em> specifies an unknown/invalid 1781 value.</p></dd><dt><span class="term"><span class="errorname">EPERM</span></span></dt><dd><p>Attempt to read or write void value, or attempt to 1782 write read-only value.</p></dd><dt><span class="term"><span class="errorname">EAGAIN</span></span></dt><dd><p>A memory allocation failure 1783 occurred.</p></dd><dt><span class="term"><span class="errorname">EFAULT</span></span></dt><dd><p>An interface with side effects failed in some way 1784 not directly related to <code class="function">mallctl*()</code> 1785 read/write processing.</p></dd></dl></div><p> 1786 </p><p>The <code class="function">malloc_usable_size()</code> function 1787 returns the usable size of the allocation pointed to by 1788 <em class="parameter"><code>ptr</code></em>. </p></div></div><div class="refsect1"><a name="environment"/><h2>ENVIRONMENT</h2><p>The following environment variable affects the execution of the 1789 allocation functions: 1790 </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">MALLOC_CONF</code></span></dt><dd><p>If the environment variable 1791 <code class="envar">MALLOC_CONF</code> is set, the characters it contains 1792 will be interpreted as options.</p></dd></dl></div><p> 1793 </p></div><div class="refsect1"><a name="examples"/><h2>EXAMPLES</h2><p>To dump core whenever a problem occurs: 1794 </p><pre class="screen">ln -s 'abort:true' /etc/malloc.conf</pre><p> 1795 </p><p>To specify in the source that only one arena should be automatically 1796 created: 1797 </p><pre class="programlisting"> 1798malloc_conf = "narenas:1";</pre></div><div class="refsect1"><a name="see_also"/><h2>SEE ALSO</h2><p><span class="citerefentry"><span class="refentrytitle">madvise</span>(2)</span>, 1799 <span class="citerefentry"><span class="refentrytitle">mmap</span>(2)</span>, 1800 <span class="citerefentry"><span class="refentrytitle">sbrk</span>(2)</span>, 1801 <span class="citerefentry"><span class="refentrytitle">utrace</span>(2)</span>, 1802 <span class="citerefentry"><span class="refentrytitle">alloca</span>(3)</span>, 1803 <span class="citerefentry"><span class="refentrytitle">atexit</span>(3)</span>, 1804 <span class="citerefentry"><span class="refentrytitle">getpagesize</span>(3)</span></p></div><div class="refsect1"><a name="standards"/><h2>STANDARDS</h2><p>The <code class="function">malloc()</code>, 1805 <code class="function">calloc()</code>, 1806 <code class="function">realloc()</code>, and 1807 <code class="function">free()</code> functions conform to ISO/IEC 1808 9899:1990 (<span class="quote">“<span class="quote">ISO C90</span>”</span>).</p><p>The <code class="function">posix_memalign()</code> function conforms 1809 to IEEE Std 1003.1-2001 (<span class="quote">“<span class="quote">POSIX.1</span>”</span>).</p></div></div></body></html>