1*8e33eff8Schristos<?xml version='1.0' encoding='UTF-8'?> 2*8e33eff8Schristos<?xml-stylesheet type="text/xsl" 3*8e33eff8Schristos href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?> 4*8e33eff8Schristos<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" 5*8e33eff8Schristos "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ 6*8e33eff8Schristos]> 7*8e33eff8Schristos 8*8e33eff8Schristos<refentry> 9*8e33eff8Schristos <refentryinfo> 10*8e33eff8Schristos <title>User Manual</title> 11*8e33eff8Schristos <productname>jemalloc</productname> 12*8e33eff8Schristos <releaseinfo role="version">@jemalloc_version@</releaseinfo> 13*8e33eff8Schristos <authorgroup> 14*8e33eff8Schristos <author> 15*8e33eff8Schristos <firstname>Jason</firstname> 16*8e33eff8Schristos <surname>Evans</surname> 17*8e33eff8Schristos <personblurb>Author</personblurb> 18*8e33eff8Schristos </author> 19*8e33eff8Schristos </authorgroup> 20*8e33eff8Schristos </refentryinfo> 21*8e33eff8Schristos <refmeta> 22*8e33eff8Schristos <refentrytitle>JEMALLOC</refentrytitle> 23*8e33eff8Schristos <manvolnum>3</manvolnum> 24*8e33eff8Schristos </refmeta> 25*8e33eff8Schristos <refnamediv> 26*8e33eff8Schristos <refdescriptor>jemalloc</refdescriptor> 27*8e33eff8Schristos <refname>jemalloc</refname> 28*8e33eff8Schristos <!-- Each refname causes a man page file to be created. Only if this were 29*8e33eff8Schristos the system malloc(3) implementation would these files be appropriate. 30*8e33eff8Schristos <refname>malloc</refname> 31*8e33eff8Schristos <refname>calloc</refname> 32*8e33eff8Schristos <refname>posix_memalign</refname> 33*8e33eff8Schristos <refname>aligned_alloc</refname> 34*8e33eff8Schristos <refname>realloc</refname> 35*8e33eff8Schristos <refname>free</refname> 36*8e33eff8Schristos <refname>mallocx</refname> 37*8e33eff8Schristos <refname>rallocx</refname> 38*8e33eff8Schristos <refname>xallocx</refname> 39*8e33eff8Schristos <refname>sallocx</refname> 40*8e33eff8Schristos <refname>dallocx</refname> 41*8e33eff8Schristos <refname>sdallocx</refname> 42*8e33eff8Schristos <refname>nallocx</refname> 43*8e33eff8Schristos <refname>mallctl</refname> 44*8e33eff8Schristos <refname>mallctlnametomib</refname> 45*8e33eff8Schristos <refname>mallctlbymib</refname> 46*8e33eff8Schristos <refname>malloc_stats_print</refname> 47*8e33eff8Schristos <refname>malloc_usable_size</refname> 48*8e33eff8Schristos --> 49*8e33eff8Schristos <refpurpose>general purpose memory allocation functions</refpurpose> 50*8e33eff8Schristos </refnamediv> 51*8e33eff8Schristos <refsect1 id="library"> 52*8e33eff8Schristos <title>LIBRARY</title> 53*8e33eff8Schristos <para>This manual describes jemalloc @jemalloc_version@. More information 54*8e33eff8Schristos can be found at the <ulink 55*8e33eff8Schristos url="http://jemalloc.net/">jemalloc website</ulink>.</para> 56*8e33eff8Schristos </refsect1> 57*8e33eff8Schristos <refsynopsisdiv> 58*8e33eff8Schristos <title>SYNOPSIS</title> 59*8e33eff8Schristos <funcsynopsis> 60*8e33eff8Schristos <funcsynopsisinfo>#include <<filename class="headerfile">jemalloc/jemalloc.h</filename>></funcsynopsisinfo> 61*8e33eff8Schristos <refsect2> 62*8e33eff8Schristos <title>Standard API</title> 63*8e33eff8Schristos <funcprototype> 64*8e33eff8Schristos <funcdef>void *<function>malloc</function></funcdef> 65*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 66*8e33eff8Schristos </funcprototype> 67*8e33eff8Schristos <funcprototype> 68*8e33eff8Schristos <funcdef>void *<function>calloc</function></funcdef> 69*8e33eff8Schristos <paramdef>size_t <parameter>number</parameter></paramdef> 70*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 71*8e33eff8Schristos </funcprototype> 72*8e33eff8Schristos <funcprototype> 73*8e33eff8Schristos <funcdef>int <function>posix_memalign</function></funcdef> 74*8e33eff8Schristos <paramdef>void **<parameter>ptr</parameter></paramdef> 75*8e33eff8Schristos <paramdef>size_t <parameter>alignment</parameter></paramdef> 76*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 77*8e33eff8Schristos </funcprototype> 78*8e33eff8Schristos <funcprototype> 79*8e33eff8Schristos <funcdef>void *<function>aligned_alloc</function></funcdef> 80*8e33eff8Schristos <paramdef>size_t <parameter>alignment</parameter></paramdef> 81*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 82*8e33eff8Schristos </funcprototype> 83*8e33eff8Schristos <funcprototype> 84*8e33eff8Schristos <funcdef>void *<function>realloc</function></funcdef> 85*8e33eff8Schristos <paramdef>void *<parameter>ptr</parameter></paramdef> 86*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 87*8e33eff8Schristos </funcprototype> 88*8e33eff8Schristos <funcprototype> 89*8e33eff8Schristos <funcdef>void <function>free</function></funcdef> 90*8e33eff8Schristos <paramdef>void *<parameter>ptr</parameter></paramdef> 91*8e33eff8Schristos </funcprototype> 92*8e33eff8Schristos </refsect2> 93*8e33eff8Schristos <refsect2> 94*8e33eff8Schristos <title>Non-standard API</title> 95*8e33eff8Schristos <funcprototype> 96*8e33eff8Schristos <funcdef>void *<function>mallocx</function></funcdef> 97*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 98*8e33eff8Schristos <paramdef>int <parameter>flags</parameter></paramdef> 99*8e33eff8Schristos </funcprototype> 100*8e33eff8Schristos <funcprototype> 101*8e33eff8Schristos <funcdef>void *<function>rallocx</function></funcdef> 102*8e33eff8Schristos <paramdef>void *<parameter>ptr</parameter></paramdef> 103*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 104*8e33eff8Schristos <paramdef>int <parameter>flags</parameter></paramdef> 105*8e33eff8Schristos </funcprototype> 106*8e33eff8Schristos <funcprototype> 107*8e33eff8Schristos <funcdef>size_t <function>xallocx</function></funcdef> 108*8e33eff8Schristos <paramdef>void *<parameter>ptr</parameter></paramdef> 109*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 110*8e33eff8Schristos <paramdef>size_t <parameter>extra</parameter></paramdef> 111*8e33eff8Schristos <paramdef>int <parameter>flags</parameter></paramdef> 112*8e33eff8Schristos </funcprototype> 113*8e33eff8Schristos <funcprototype> 114*8e33eff8Schristos <funcdef>size_t <function>sallocx</function></funcdef> 115*8e33eff8Schristos <paramdef>void *<parameter>ptr</parameter></paramdef> 116*8e33eff8Schristos <paramdef>int <parameter>flags</parameter></paramdef> 117*8e33eff8Schristos </funcprototype> 118*8e33eff8Schristos <funcprototype> 119*8e33eff8Schristos <funcdef>void <function>dallocx</function></funcdef> 120*8e33eff8Schristos <paramdef>void *<parameter>ptr</parameter></paramdef> 121*8e33eff8Schristos <paramdef>int <parameter>flags</parameter></paramdef> 122*8e33eff8Schristos </funcprototype> 123*8e33eff8Schristos <funcprototype> 124*8e33eff8Schristos <funcdef>void <function>sdallocx</function></funcdef> 125*8e33eff8Schristos <paramdef>void *<parameter>ptr</parameter></paramdef> 126*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 127*8e33eff8Schristos <paramdef>int <parameter>flags</parameter></paramdef> 128*8e33eff8Schristos </funcprototype> 129*8e33eff8Schristos <funcprototype> 130*8e33eff8Schristos <funcdef>size_t <function>nallocx</function></funcdef> 131*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 132*8e33eff8Schristos <paramdef>int <parameter>flags</parameter></paramdef> 133*8e33eff8Schristos </funcprototype> 134*8e33eff8Schristos <funcprototype> 135*8e33eff8Schristos <funcdef>int <function>mallctl</function></funcdef> 136*8e33eff8Schristos <paramdef>const char *<parameter>name</parameter></paramdef> 137*8e33eff8Schristos <paramdef>void *<parameter>oldp</parameter></paramdef> 138*8e33eff8Schristos <paramdef>size_t *<parameter>oldlenp</parameter></paramdef> 139*8e33eff8Schristos <paramdef>void *<parameter>newp</parameter></paramdef> 140*8e33eff8Schristos <paramdef>size_t <parameter>newlen</parameter></paramdef> 141*8e33eff8Schristos </funcprototype> 142*8e33eff8Schristos <funcprototype> 143*8e33eff8Schristos <funcdef>int <function>mallctlnametomib</function></funcdef> 144*8e33eff8Schristos <paramdef>const char *<parameter>name</parameter></paramdef> 145*8e33eff8Schristos <paramdef>size_t *<parameter>mibp</parameter></paramdef> 146*8e33eff8Schristos <paramdef>size_t *<parameter>miblenp</parameter></paramdef> 147*8e33eff8Schristos </funcprototype> 148*8e33eff8Schristos <funcprototype> 149*8e33eff8Schristos <funcdef>int <function>mallctlbymib</function></funcdef> 150*8e33eff8Schristos <paramdef>const size_t *<parameter>mib</parameter></paramdef> 151*8e33eff8Schristos <paramdef>size_t <parameter>miblen</parameter></paramdef> 152*8e33eff8Schristos <paramdef>void *<parameter>oldp</parameter></paramdef> 153*8e33eff8Schristos <paramdef>size_t *<parameter>oldlenp</parameter></paramdef> 154*8e33eff8Schristos <paramdef>void *<parameter>newp</parameter></paramdef> 155*8e33eff8Schristos <paramdef>size_t <parameter>newlen</parameter></paramdef> 156*8e33eff8Schristos </funcprototype> 157*8e33eff8Schristos <funcprototype> 158*8e33eff8Schristos <funcdef>void <function>malloc_stats_print</function></funcdef> 159*8e33eff8Schristos <paramdef>void <parameter>(*write_cb)</parameter> 160*8e33eff8Schristos <funcparams>void *, const char *</funcparams> 161*8e33eff8Schristos </paramdef> 162*8e33eff8Schristos <paramdef>void *<parameter>cbopaque</parameter></paramdef> 163*8e33eff8Schristos <paramdef>const char *<parameter>opts</parameter></paramdef> 164*8e33eff8Schristos </funcprototype> 165*8e33eff8Schristos <funcprototype> 166*8e33eff8Schristos <funcdef>size_t <function>malloc_usable_size</function></funcdef> 167*8e33eff8Schristos <paramdef>const void *<parameter>ptr</parameter></paramdef> 168*8e33eff8Schristos </funcprototype> 169*8e33eff8Schristos <funcprototype> 170*8e33eff8Schristos <funcdef>void <function>(*malloc_message)</function></funcdef> 171*8e33eff8Schristos <paramdef>void *<parameter>cbopaque</parameter></paramdef> 172*8e33eff8Schristos <paramdef>const char *<parameter>s</parameter></paramdef> 173*8e33eff8Schristos </funcprototype> 174*8e33eff8Schristos <para><type>const char *</type><varname>malloc_conf</varname>;</para> 175*8e33eff8Schristos </refsect2> 176*8e33eff8Schristos </funcsynopsis> 177*8e33eff8Schristos </refsynopsisdiv> 178*8e33eff8Schristos <refsect1 id="description"> 179*8e33eff8Schristos <title>DESCRIPTION</title> 180*8e33eff8Schristos <refsect2> 181*8e33eff8Schristos <title>Standard API</title> 182*8e33eff8Schristos 183*8e33eff8Schristos <para>The <function>malloc()</function> function allocates 184*8e33eff8Schristos <parameter>size</parameter> bytes of uninitialized memory. The allocated 185*8e33eff8Schristos space is suitably aligned (after possible pointer coercion) for storage 186*8e33eff8Schristos of any type of object.</para> 187*8e33eff8Schristos 188*8e33eff8Schristos <para>The <function>calloc()</function> function allocates 189*8e33eff8Schristos space for <parameter>number</parameter> objects, each 190*8e33eff8Schristos <parameter>size</parameter> bytes in length. The result is identical to 191*8e33eff8Schristos calling <function>malloc()</function> with an argument of 192*8e33eff8Schristos <parameter>number</parameter> * <parameter>size</parameter>, with the 193*8e33eff8Schristos exception that the allocated memory is explicitly initialized to zero 194*8e33eff8Schristos bytes.</para> 195*8e33eff8Schristos 196*8e33eff8Schristos <para>The <function>posix_memalign()</function> function 197*8e33eff8Schristos allocates <parameter>size</parameter> bytes of memory such that the 198*8e33eff8Schristos allocation's base address is a multiple of 199*8e33eff8Schristos <parameter>alignment</parameter>, and returns the allocation in the value 200*8e33eff8Schristos pointed to by <parameter>ptr</parameter>. The requested 201*8e33eff8Schristos <parameter>alignment</parameter> must be a power of 2 at least as large as 202*8e33eff8Schristos <code language="C">sizeof(<type>void *</type>)</code>.</para> 203*8e33eff8Schristos 204*8e33eff8Schristos <para>The <function>aligned_alloc()</function> function 205*8e33eff8Schristos allocates <parameter>size</parameter> bytes of memory such that the 206*8e33eff8Schristos allocation's base address is a multiple of 207*8e33eff8Schristos <parameter>alignment</parameter>. The requested 208*8e33eff8Schristos <parameter>alignment</parameter> must be a power of 2. Behavior is 209*8e33eff8Schristos undefined if <parameter>size</parameter> is not an integral multiple of 210*8e33eff8Schristos <parameter>alignment</parameter>.</para> 211*8e33eff8Schristos 212*8e33eff8Schristos <para>The <function>realloc()</function> function changes the 213*8e33eff8Schristos size of the previously allocated memory referenced by 214*8e33eff8Schristos <parameter>ptr</parameter> to <parameter>size</parameter> bytes. The 215*8e33eff8Schristos contents of the memory are unchanged up to the lesser of the new and old 216*8e33eff8Schristos sizes. If the new size is larger, the contents of the newly allocated 217*8e33eff8Schristos portion of the memory are undefined. Upon success, the memory referenced 218*8e33eff8Schristos by <parameter>ptr</parameter> is freed and a pointer to the newly 219*8e33eff8Schristos allocated memory is returned. Note that 220*8e33eff8Schristos <function>realloc()</function> may move the memory allocation, 221*8e33eff8Schristos resulting in a different return value than <parameter>ptr</parameter>. 222*8e33eff8Schristos If <parameter>ptr</parameter> is <constant>NULL</constant>, the 223*8e33eff8Schristos <function>realloc()</function> function behaves identically to 224*8e33eff8Schristos <function>malloc()</function> for the specified size.</para> 225*8e33eff8Schristos 226*8e33eff8Schristos <para>The <function>free()</function> function causes the 227*8e33eff8Schristos allocated memory referenced by <parameter>ptr</parameter> to be made 228*8e33eff8Schristos available for future allocations. If <parameter>ptr</parameter> is 229*8e33eff8Schristos <constant>NULL</constant>, no action occurs.</para> 230*8e33eff8Schristos </refsect2> 231*8e33eff8Schristos <refsect2> 232*8e33eff8Schristos <title>Non-standard API</title> 233*8e33eff8Schristos <para>The <function>mallocx()</function>, 234*8e33eff8Schristos <function>rallocx()</function>, 235*8e33eff8Schristos <function>xallocx()</function>, 236*8e33eff8Schristos <function>sallocx()</function>, 237*8e33eff8Schristos <function>dallocx()</function>, 238*8e33eff8Schristos <function>sdallocx()</function>, and 239*8e33eff8Schristos <function>nallocx()</function> functions all have a 240*8e33eff8Schristos <parameter>flags</parameter> argument that can be used to specify 241*8e33eff8Schristos options. The functions only check the options that are contextually 242*8e33eff8Schristos relevant. Use bitwise or (<code language="C">|</code>) operations to 243*8e33eff8Schristos specify one or more of the following: 244*8e33eff8Schristos <variablelist> 245*8e33eff8Schristos <varlistentry id="MALLOCX_LG_ALIGN"> 246*8e33eff8Schristos <term><constant>MALLOCX_LG_ALIGN(<parameter>la</parameter>) 247*8e33eff8Schristos </constant></term> 248*8e33eff8Schristos 249*8e33eff8Schristos <listitem><para>Align the memory allocation to start at an address 250*8e33eff8Schristos that is a multiple of <code language="C">(1 << 251*8e33eff8Schristos <parameter>la</parameter>)</code>. This macro does not validate 252*8e33eff8Schristos that <parameter>la</parameter> is within the valid 253*8e33eff8Schristos range.</para></listitem> 254*8e33eff8Schristos </varlistentry> 255*8e33eff8Schristos <varlistentry id="MALLOCX_ALIGN"> 256*8e33eff8Schristos <term><constant>MALLOCX_ALIGN(<parameter>a</parameter>) 257*8e33eff8Schristos </constant></term> 258*8e33eff8Schristos 259*8e33eff8Schristos <listitem><para>Align the memory allocation to start at an address 260*8e33eff8Schristos that is a multiple of <parameter>a</parameter>, where 261*8e33eff8Schristos <parameter>a</parameter> is a power of two. This macro does not 262*8e33eff8Schristos validate that <parameter>a</parameter> is a power of 2. 263*8e33eff8Schristos </para></listitem> 264*8e33eff8Schristos </varlistentry> 265*8e33eff8Schristos <varlistentry id="MALLOCX_ZERO"> 266*8e33eff8Schristos <term><constant>MALLOCX_ZERO</constant></term> 267*8e33eff8Schristos 268*8e33eff8Schristos <listitem><para>Initialize newly allocated memory to contain zero 269*8e33eff8Schristos bytes. In the growing reallocation case, the real size prior to 270*8e33eff8Schristos reallocation defines the boundary between untouched bytes and those 271*8e33eff8Schristos that are initialized to contain zero bytes. If this macro is 272*8e33eff8Schristos absent, newly allocated memory is uninitialized.</para></listitem> 273*8e33eff8Schristos </varlistentry> 274*8e33eff8Schristos <varlistentry id="MALLOCX_TCACHE"> 275*8e33eff8Schristos <term><constant>MALLOCX_TCACHE(<parameter>tc</parameter>) 276*8e33eff8Schristos </constant></term> 277*8e33eff8Schristos 278*8e33eff8Schristos <listitem><para>Use the thread-specific cache (tcache) specified by 279*8e33eff8Schristos the identifier <parameter>tc</parameter>, which must have been 280*8e33eff8Schristos acquired via the <link 281*8e33eff8Schristos linkend="tcache.create"><mallctl>tcache.create</mallctl></link> 282*8e33eff8Schristos mallctl. This macro does not validate that 283*8e33eff8Schristos <parameter>tc</parameter> specifies a valid 284*8e33eff8Schristos identifier.</para></listitem> 285*8e33eff8Schristos </varlistentry> 286*8e33eff8Schristos <varlistentry id="MALLOC_TCACHE_NONE"> 287*8e33eff8Schristos <term><constant>MALLOCX_TCACHE_NONE</constant></term> 288*8e33eff8Schristos 289*8e33eff8Schristos <listitem><para>Do not use a thread-specific cache (tcache). Unless 290*8e33eff8Schristos <constant>MALLOCX_TCACHE(<parameter>tc</parameter>)</constant> or 291*8e33eff8Schristos <constant>MALLOCX_TCACHE_NONE</constant> is specified, an 292*8e33eff8Schristos automatically managed tcache will be used under many circumstances. 293*8e33eff8Schristos This macro cannot be used in the same <parameter>flags</parameter> 294*8e33eff8Schristos argument as 295*8e33eff8Schristos <constant>MALLOCX_TCACHE(<parameter>tc</parameter>)</constant>.</para></listitem> 296*8e33eff8Schristos </varlistentry> 297*8e33eff8Schristos <varlistentry id="MALLOCX_ARENA"> 298*8e33eff8Schristos <term><constant>MALLOCX_ARENA(<parameter>a</parameter>) 299*8e33eff8Schristos </constant></term> 300*8e33eff8Schristos 301*8e33eff8Schristos <listitem><para>Use the arena specified by the index 302*8e33eff8Schristos <parameter>a</parameter>. This macro has no effect for regions that 303*8e33eff8Schristos were allocated via an arena other than the one specified. This 304*8e33eff8Schristos macro does not validate that <parameter>a</parameter> specifies an 305*8e33eff8Schristos arena index in the valid range.</para></listitem> 306*8e33eff8Schristos </varlistentry> 307*8e33eff8Schristos </variablelist> 308*8e33eff8Schristos </para> 309*8e33eff8Schristos 310*8e33eff8Schristos <para>The <function>mallocx()</function> function allocates at 311*8e33eff8Schristos least <parameter>size</parameter> bytes of memory, and returns a pointer 312*8e33eff8Schristos to the base address of the allocation. Behavior is undefined if 313*8e33eff8Schristos <parameter>size</parameter> is <constant>0</constant>.</para> 314*8e33eff8Schristos 315*8e33eff8Schristos <para>The <function>rallocx()</function> function resizes the 316*8e33eff8Schristos allocation at <parameter>ptr</parameter> to be at least 317*8e33eff8Schristos <parameter>size</parameter> bytes, and returns a pointer to the base 318*8e33eff8Schristos address of the resulting allocation, which may or may not have moved from 319*8e33eff8Schristos its original location. Behavior is undefined if 320*8e33eff8Schristos <parameter>size</parameter> is <constant>0</constant>.</para> 321*8e33eff8Schristos 322*8e33eff8Schristos <para>The <function>xallocx()</function> function resizes the 323*8e33eff8Schristos allocation at <parameter>ptr</parameter> in place to be at least 324*8e33eff8Schristos <parameter>size</parameter> bytes, and returns the real size of the 325*8e33eff8Schristos allocation. If <parameter>extra</parameter> is non-zero, an attempt is 326*8e33eff8Schristos made to resize the allocation to be at least <code 327*8e33eff8Schristos language="C">(<parameter>size</parameter> + 328*8e33eff8Schristos <parameter>extra</parameter>)</code> bytes, though inability to allocate 329*8e33eff8Schristos the extra byte(s) will not by itself result in failure to resize. 330*8e33eff8Schristos Behavior is undefined if <parameter>size</parameter> is 331*8e33eff8Schristos <constant>0</constant>, or if <code 332*8e33eff8Schristos language="C">(<parameter>size</parameter> + <parameter>extra</parameter> 333*8e33eff8Schristos > <constant>SIZE_T_MAX</constant>)</code>.</para> 334*8e33eff8Schristos 335*8e33eff8Schristos <para>The <function>sallocx()</function> function returns the 336*8e33eff8Schristos real size of the allocation at <parameter>ptr</parameter>.</para> 337*8e33eff8Schristos 338*8e33eff8Schristos <para>The <function>dallocx()</function> function causes the 339*8e33eff8Schristos memory referenced by <parameter>ptr</parameter> to be made available for 340*8e33eff8Schristos future allocations.</para> 341*8e33eff8Schristos 342*8e33eff8Schristos <para>The <function>sdallocx()</function> function is an 343*8e33eff8Schristos extension of <function>dallocx()</function> with a 344*8e33eff8Schristos <parameter>size</parameter> parameter to allow the caller to pass in the 345*8e33eff8Schristos allocation size as an optimization. The minimum valid input size is the 346*8e33eff8Schristos original requested size of the allocation, and the maximum valid input 347*8e33eff8Schristos size is the corresponding value returned by 348*8e33eff8Schristos <function>nallocx()</function> or 349*8e33eff8Schristos <function>sallocx()</function>.</para> 350*8e33eff8Schristos 351*8e33eff8Schristos <para>The <function>nallocx()</function> function allocates no 352*8e33eff8Schristos memory, but it performs the same size computation as the 353*8e33eff8Schristos <function>mallocx()</function> function, and returns the real 354*8e33eff8Schristos size of the allocation that would result from the equivalent 355*8e33eff8Schristos <function>mallocx()</function> function call, or 356*8e33eff8Schristos <constant>0</constant> if the inputs exceed the maximum supported size 357*8e33eff8Schristos class and/or alignment. Behavior is undefined if 358*8e33eff8Schristos <parameter>size</parameter> is <constant>0</constant>.</para> 359*8e33eff8Schristos 360*8e33eff8Schristos <para>The <function>mallctl()</function> function provides a 361*8e33eff8Schristos general interface for introspecting the memory allocator, as well as 362*8e33eff8Schristos setting modifiable parameters and triggering actions. The 363*8e33eff8Schristos period-separated <parameter>name</parameter> argument specifies a 364*8e33eff8Schristos location in a tree-structured namespace; see the <xref 365*8e33eff8Schristos linkend="mallctl_namespace" xrefstyle="template:%t"/> section for 366*8e33eff8Schristos documentation on the tree contents. To read a value, pass a pointer via 367*8e33eff8Schristos <parameter>oldp</parameter> to adequate space to contain the value, and a 368*8e33eff8Schristos pointer to its length via <parameter>oldlenp</parameter>; otherwise pass 369*8e33eff8Schristos <constant>NULL</constant> and <constant>NULL</constant>. Similarly, to 370*8e33eff8Schristos write a value, pass a pointer to the value via 371*8e33eff8Schristos <parameter>newp</parameter>, and its length via 372*8e33eff8Schristos <parameter>newlen</parameter>; otherwise pass <constant>NULL</constant> 373*8e33eff8Schristos and <constant>0</constant>.</para> 374*8e33eff8Schristos 375*8e33eff8Schristos <para>The <function>mallctlnametomib()</function> function 376*8e33eff8Schristos provides a way to avoid repeated name lookups for applications that 377*8e33eff8Schristos repeatedly query the same portion of the namespace, by translating a name 378*8e33eff8Schristos to a <quote>Management Information Base</quote> (MIB) that can be passed 379*8e33eff8Schristos repeatedly to <function>mallctlbymib()</function>. Upon 380*8e33eff8Schristos successful return from <function>mallctlnametomib()</function>, 381*8e33eff8Schristos <parameter>mibp</parameter> contains an array of 382*8e33eff8Schristos <parameter>*miblenp</parameter> integers, where 383*8e33eff8Schristos <parameter>*miblenp</parameter> is the lesser of the number of components 384*8e33eff8Schristos in <parameter>name</parameter> and the input value of 385*8e33eff8Schristos <parameter>*miblenp</parameter>. Thus it is possible to pass a 386*8e33eff8Schristos <parameter>*miblenp</parameter> that is smaller than the number of 387*8e33eff8Schristos period-separated name components, which results in a partial MIB that can 388*8e33eff8Schristos be used as the basis for constructing a complete MIB. For name 389*8e33eff8Schristos components that are integers (e.g. the 2 in 390*8e33eff8Schristos <link 391*8e33eff8Schristos linkend="arenas.bin.i.size"><mallctl>arenas.bin.2.size</mallctl></link>), 392*8e33eff8Schristos the corresponding MIB component will always be that integer. Therefore, 393*8e33eff8Schristos it is legitimate to construct code like the following: <programlisting 394*8e33eff8Schristos language="C"><![CDATA[ 395*8e33eff8Schristosunsigned nbins, i; 396*8e33eff8Schristossize_t mib[4]; 397*8e33eff8Schristossize_t len, miblen; 398*8e33eff8Schristos 399*8e33eff8Schristoslen = sizeof(nbins); 400*8e33eff8Schristosmallctl("arenas.nbins", &nbins, &len, NULL, 0); 401*8e33eff8Schristos 402*8e33eff8Schristosmiblen = 4; 403*8e33eff8Schristosmallctlnametomib("arenas.bin.0.size", mib, &miblen); 404*8e33eff8Schristosfor (i = 0; i < nbins; i++) { 405*8e33eff8Schristos size_t bin_size; 406*8e33eff8Schristos 407*8e33eff8Schristos mib[2] = i; 408*8e33eff8Schristos len = sizeof(bin_size); 409*8e33eff8Schristos mallctlbymib(mib, miblen, (void *)&bin_size, &len, NULL, 0); 410*8e33eff8Schristos /* Do something with bin_size... */ 411*8e33eff8Schristos}]]></programlisting></para> 412*8e33eff8Schristos 413*8e33eff8Schristos <varlistentry id="malloc_stats_print_opts"> 414*8e33eff8Schristos </varlistentry> 415*8e33eff8Schristos <para>The <function>malloc_stats_print()</function> function writes 416*8e33eff8Schristos summary statistics via the <parameter>write_cb</parameter> callback 417*8e33eff8Schristos function pointer and <parameter>cbopaque</parameter> data passed to 418*8e33eff8Schristos <parameter>write_cb</parameter>, or <function>malloc_message()</function> 419*8e33eff8Schristos if <parameter>write_cb</parameter> is <constant>NULL</constant>. The 420*8e33eff8Schristos statistics are presented in human-readable form unless <quote>J</quote> is 421*8e33eff8Schristos specified as a character within the <parameter>opts</parameter> string, in 422*8e33eff8Schristos which case the statistics are presented in <ulink 423*8e33eff8Schristos url="http://www.json.org/">JSON format</ulink>. This function can be 424*8e33eff8Schristos called repeatedly. General information that never changes during 425*8e33eff8Schristos execution can be omitted by specifying <quote>g</quote> as a character 426*8e33eff8Schristos within the <parameter>opts</parameter> string. Note that 427*8e33eff8Schristos <function>malloc_message()</function> uses the 428*8e33eff8Schristos <function>mallctl*()</function> functions internally, so inconsistent 429*8e33eff8Schristos statistics can be reported if multiple threads use these functions 430*8e33eff8Schristos simultaneously. If <option>--enable-stats</option> is specified during 431*8e33eff8Schristos configuration, <quote>m</quote>, <quote>d</quote>, and <quote>a</quote> 432*8e33eff8Schristos can be specified to omit merged arena, destroyed merged arena, and per 433*8e33eff8Schristos arena statistics, respectively; <quote>b</quote> and <quote>l</quote> can 434*8e33eff8Schristos be specified to omit per size class statistics for bins and large objects, 435*8e33eff8Schristos respectively; <quote>x</quote> can be specified to omit all mutex 436*8e33eff8Schristos statistics. Unrecognized characters are silently ignored. Note that 437*8e33eff8Schristos thread caching may prevent some statistics from being completely up to 438*8e33eff8Schristos date, since extra locking would be required to merge counters that track 439*8e33eff8Schristos thread cache operations.</para> 440*8e33eff8Schristos 441*8e33eff8Schristos <para>The <function>malloc_usable_size()</function> function 442*8e33eff8Schristos returns the usable size of the allocation pointed to by 443*8e33eff8Schristos <parameter>ptr</parameter>. The return value may be larger than the size 444*8e33eff8Schristos that was requested during allocation. The 445*8e33eff8Schristos <function>malloc_usable_size()</function> function is not a 446*8e33eff8Schristos mechanism for in-place <function>realloc()</function>; rather 447*8e33eff8Schristos it is provided solely as a tool for introspection purposes. Any 448*8e33eff8Schristos discrepancy between the requested allocation size and the size reported 449*8e33eff8Schristos by <function>malloc_usable_size()</function> should not be 450*8e33eff8Schristos depended on, since such behavior is entirely implementation-dependent. 451*8e33eff8Schristos </para> 452*8e33eff8Schristos </refsect2> 453*8e33eff8Schristos </refsect1> 454*8e33eff8Schristos <refsect1 id="tuning"> 455*8e33eff8Schristos <title>TUNING</title> 456*8e33eff8Schristos <para>Once, when the first call is made to one of the memory allocation 457*8e33eff8Schristos routines, the allocator initializes its internals based in part on various 458*8e33eff8Schristos options that can be specified at compile- or run-time.</para> 459*8e33eff8Schristos 460*8e33eff8Schristos <para>The string specified via <option>--with-malloc-conf</option>, the 461*8e33eff8Schristos string pointed to by the global variable <varname>malloc_conf</varname>, the 462*8e33eff8Schristos <quote>name</quote> of the file referenced by the symbolic link named 463*8e33eff8Schristos <filename class="symlink">/etc/malloc.conf</filename>, and the value of the 464*8e33eff8Schristos environment variable <envar>MALLOC_CONF</envar>, will be interpreted, in 465*8e33eff8Schristos that order, from left to right as options. Note that 466*8e33eff8Schristos <varname>malloc_conf</varname> may be read before 467*8e33eff8Schristos <function>main()</function> is entered, so the declaration of 468*8e33eff8Schristos <varname>malloc_conf</varname> should specify an initializer that contains 469*8e33eff8Schristos the final value to be read by jemalloc. <option>--with-malloc-conf</option> 470*8e33eff8Schristos and <varname>malloc_conf</varname> are compile-time mechanisms, whereas 471*8e33eff8Schristos <filename class="symlink">/etc/malloc.conf</filename> and 472*8e33eff8Schristos <envar>MALLOC_CONF</envar> can be safely set any time prior to program 473*8e33eff8Schristos invocation.</para> 474*8e33eff8Schristos 475*8e33eff8Schristos <para>An options string is a comma-separated list of option:value pairs. 476*8e33eff8Schristos There is one key corresponding to each <link 477*8e33eff8Schristos linkend="opt.abort"><mallctl>opt.*</mallctl></link> mallctl (see the <xref 478*8e33eff8Schristos linkend="mallctl_namespace" xrefstyle="template:%t"/> section for options 479*8e33eff8Schristos documentation). For example, <literal>abort:true,narenas:1</literal> sets 480*8e33eff8Schristos the <link linkend="opt.abort"><mallctl>opt.abort</mallctl></link> and <link 481*8e33eff8Schristos linkend="opt.narenas"><mallctl>opt.narenas</mallctl></link> options. Some 482*8e33eff8Schristos options have boolean values (true/false), others have integer values (base 483*8e33eff8Schristos 8, 10, or 16, depending on prefix), and yet others have raw string 484*8e33eff8Schristos values.</para> 485*8e33eff8Schristos </refsect1> 486*8e33eff8Schristos <refsect1 id="implementation_notes"> 487*8e33eff8Schristos <title>IMPLEMENTATION NOTES</title> 488*8e33eff8Schristos <para>Traditionally, allocators have used 489*8e33eff8Schristos <citerefentry><refentrytitle>sbrk</refentrytitle> 490*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry> to obtain memory, which is 491*8e33eff8Schristos suboptimal for several reasons, including race conditions, increased 492*8e33eff8Schristos fragmentation, and artificial limitations on maximum usable memory. If 493*8e33eff8Schristos <citerefentry><refentrytitle>sbrk</refentrytitle> 494*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry> is supported by the operating 495*8e33eff8Schristos system, this allocator uses both 496*8e33eff8Schristos <citerefentry><refentrytitle>mmap</refentrytitle> 497*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry> and 498*8e33eff8Schristos <citerefentry><refentrytitle>sbrk</refentrytitle> 499*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry>, in that order of preference; 500*8e33eff8Schristos otherwise only <citerefentry><refentrytitle>mmap</refentrytitle> 501*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry> is used.</para> 502*8e33eff8Schristos 503*8e33eff8Schristos <para>This allocator uses multiple arenas in order to reduce lock 504*8e33eff8Schristos contention for threaded programs on multi-processor systems. This works 505*8e33eff8Schristos well with regard to threading scalability, but incurs some costs. There is 506*8e33eff8Schristos a small fixed per-arena overhead, and additionally, arenas manage memory 507*8e33eff8Schristos completely independently of each other, which means a small fixed increase 508*8e33eff8Schristos in overall memory fragmentation. These overheads are not generally an 509*8e33eff8Schristos issue, given the number of arenas normally used. Note that using 510*8e33eff8Schristos substantially more arenas than the default is not likely to improve 511*8e33eff8Schristos performance, mainly due to reduced cache performance. However, it may make 512*8e33eff8Schristos sense to reduce the number of arenas if an application does not make much 513*8e33eff8Schristos use of the allocation functions.</para> 514*8e33eff8Schristos 515*8e33eff8Schristos <para>In addition to multiple arenas, this allocator supports 516*8e33eff8Schristos thread-specific caching, in order to make it possible to completely avoid 517*8e33eff8Schristos synchronization for most allocation requests. Such caching allows very fast 518*8e33eff8Schristos allocation in the common case, but it increases memory usage and 519*8e33eff8Schristos fragmentation, since a bounded number of objects can remain allocated in 520*8e33eff8Schristos each thread cache.</para> 521*8e33eff8Schristos 522*8e33eff8Schristos <para>Memory is conceptually broken into extents. Extents are always 523*8e33eff8Schristos aligned to multiples of the page size. This alignment makes it possible to 524*8e33eff8Schristos find metadata for user objects quickly. User objects are broken into two 525*8e33eff8Schristos categories according to size: small and large. Contiguous small objects 526*8e33eff8Schristos comprise a slab, which resides within a single extent, whereas large objects 527*8e33eff8Schristos each have their own extents backing them.</para> 528*8e33eff8Schristos 529*8e33eff8Schristos <para>Small objects are managed in groups by slabs. Each slab maintains 530*8e33eff8Schristos a bitmap to track which regions are in use. Allocation requests that are no 531*8e33eff8Schristos more than half the quantum (8 or 16, depending on architecture) are rounded 532*8e33eff8Schristos up to the nearest power of two that is at least <code 533*8e33eff8Schristos language="C">sizeof(<type>double</type>)</code>. All other object size 534*8e33eff8Schristos classes are multiples of the quantum, spaced such that there are four size 535*8e33eff8Schristos classes for each doubling in size, which limits internal fragmentation to 536*8e33eff8Schristos approximately 20% for all but the smallest size classes. Small size classes 537*8e33eff8Schristos are smaller than four times the page size, and large size classes extend 538*8e33eff8Schristos from four times the page size up to the largest size class that does not 539*8e33eff8Schristos exceed <constant>PTRDIFF_MAX</constant>.</para> 540*8e33eff8Schristos 541*8e33eff8Schristos <para>Allocations are packed tightly together, which can be an issue for 542*8e33eff8Schristos multi-threaded applications. If you need to assure that allocations do not 543*8e33eff8Schristos suffer from cacheline sharing, round your allocation requests up to the 544*8e33eff8Schristos nearest multiple of the cacheline size, or specify cacheline alignment when 545*8e33eff8Schristos allocating.</para> 546*8e33eff8Schristos 547*8e33eff8Schristos <para>The <function>realloc()</function>, 548*8e33eff8Schristos <function>rallocx()</function>, and 549*8e33eff8Schristos <function>xallocx()</function> functions may resize allocations 550*8e33eff8Schristos without moving them under limited circumstances. Unlike the 551*8e33eff8Schristos <function>*allocx()</function> API, the standard API does not 552*8e33eff8Schristos officially round up the usable size of an allocation to the nearest size 553*8e33eff8Schristos class, so technically it is necessary to call 554*8e33eff8Schristos <function>realloc()</function> to grow e.g. a 9-byte allocation to 555*8e33eff8Schristos 16 bytes, or shrink a 16-byte allocation to 9 bytes. Growth and shrinkage 556*8e33eff8Schristos trivially succeeds in place as long as the pre-size and post-size both round 557*8e33eff8Schristos up to the same size class. No other API guarantees are made regarding 558*8e33eff8Schristos in-place resizing, but the current implementation also tries to resize large 559*8e33eff8Schristos allocations in place, as long as the pre-size and post-size are both large. 560*8e33eff8Schristos For shrinkage to succeed, the extent allocator must support splitting (see 561*8e33eff8Schristos <link 562*8e33eff8Schristos linkend="arena.i.extent_hooks"><mallctl>arena.<i>.extent_hooks</mallctl></link>). 563*8e33eff8Schristos Growth only succeeds if the trailing memory is currently available, and the 564*8e33eff8Schristos extent allocator supports merging.</para> 565*8e33eff8Schristos 566*8e33eff8Schristos <para>Assuming 4 KiB pages and a 16-byte quantum on a 64-bit system, the 567*8e33eff8Schristos size classes in each category are as shown in <xref linkend="size_classes" 568*8e33eff8Schristos xrefstyle="template:Table %n"/>.</para> 569*8e33eff8Schristos 570*8e33eff8Schristos <table xml:id="size_classes" frame="all"> 571*8e33eff8Schristos <title>Size classes</title> 572*8e33eff8Schristos <tgroup cols="3" colsep="1" rowsep="1"> 573*8e33eff8Schristos <colspec colname="c1" align="left"/> 574*8e33eff8Schristos <colspec colname="c2" align="right"/> 575*8e33eff8Schristos <colspec colname="c3" align="left"/> 576*8e33eff8Schristos <thead> 577*8e33eff8Schristos <row> 578*8e33eff8Schristos <entry>Category</entry> 579*8e33eff8Schristos <entry>Spacing</entry> 580*8e33eff8Schristos <entry>Size</entry> 581*8e33eff8Schristos </row> 582*8e33eff8Schristos </thead> 583*8e33eff8Schristos <tbody> 584*8e33eff8Schristos <row> 585*8e33eff8Schristos <entry morerows="8">Small</entry> 586*8e33eff8Schristos <entry>lg</entry> 587*8e33eff8Schristos <entry>[8]</entry> 588*8e33eff8Schristos </row> 589*8e33eff8Schristos <row> 590*8e33eff8Schristos <entry>16</entry> 591*8e33eff8Schristos <entry>[16, 32, 48, 64, 80, 96, 112, 128]</entry> 592*8e33eff8Schristos </row> 593*8e33eff8Schristos <row> 594*8e33eff8Schristos <entry>32</entry> 595*8e33eff8Schristos <entry>[160, 192, 224, 256]</entry> 596*8e33eff8Schristos </row> 597*8e33eff8Schristos <row> 598*8e33eff8Schristos <entry>64</entry> 599*8e33eff8Schristos <entry>[320, 384, 448, 512]</entry> 600*8e33eff8Schristos </row> 601*8e33eff8Schristos <row> 602*8e33eff8Schristos <entry>128</entry> 603*8e33eff8Schristos <entry>[640, 768, 896, 1024]</entry> 604*8e33eff8Schristos </row> 605*8e33eff8Schristos <row> 606*8e33eff8Schristos <entry>256</entry> 607*8e33eff8Schristos <entry>[1280, 1536, 1792, 2048]</entry> 608*8e33eff8Schristos </row> 609*8e33eff8Schristos <row> 610*8e33eff8Schristos <entry>512</entry> 611*8e33eff8Schristos <entry>[2560, 3072, 3584, 4096]</entry> 612*8e33eff8Schristos </row> 613*8e33eff8Schristos <row> 614*8e33eff8Schristos <entry>1 KiB</entry> 615*8e33eff8Schristos <entry>[5 KiB, 6 KiB, 7 KiB, 8 KiB]</entry> 616*8e33eff8Schristos </row> 617*8e33eff8Schristos <row> 618*8e33eff8Schristos <entry>2 KiB</entry> 619*8e33eff8Schristos <entry>[10 KiB, 12 KiB, 14 KiB]</entry> 620*8e33eff8Schristos </row> 621*8e33eff8Schristos <row> 622*8e33eff8Schristos <entry morerows="15">Large</entry> 623*8e33eff8Schristos <entry>2 KiB</entry> 624*8e33eff8Schristos <entry>[16 KiB]</entry> 625*8e33eff8Schristos </row> 626*8e33eff8Schristos <row> 627*8e33eff8Schristos <entry>4 KiB</entry> 628*8e33eff8Schristos <entry>[20 KiB, 24 KiB, 28 KiB, 32 KiB]</entry> 629*8e33eff8Schristos </row> 630*8e33eff8Schristos <row> 631*8e33eff8Schristos <entry>8 KiB</entry> 632*8e33eff8Schristos <entry>[40 KiB, 48 KiB, 54 KiB, 64 KiB]</entry> 633*8e33eff8Schristos </row> 634*8e33eff8Schristos <row> 635*8e33eff8Schristos <entry>16 KiB</entry> 636*8e33eff8Schristos <entry>[80 KiB, 96 KiB, 112 KiB, 128 KiB]</entry> 637*8e33eff8Schristos </row> 638*8e33eff8Schristos <row> 639*8e33eff8Schristos <entry>32 KiB</entry> 640*8e33eff8Schristos <entry>[160 KiB, 192 KiB, 224 KiB, 256 KiB]</entry> 641*8e33eff8Schristos </row> 642*8e33eff8Schristos <row> 643*8e33eff8Schristos <entry>64 KiB</entry> 644*8e33eff8Schristos <entry>[320 KiB, 384 KiB, 448 KiB, 512 KiB]</entry> 645*8e33eff8Schristos </row> 646*8e33eff8Schristos <row> 647*8e33eff8Schristos <entry>128 KiB</entry> 648*8e33eff8Schristos <entry>[640 KiB, 768 KiB, 896 KiB, 1 MiB]</entry> 649*8e33eff8Schristos </row> 650*8e33eff8Schristos <row> 651*8e33eff8Schristos <entry>256 KiB</entry> 652*8e33eff8Schristos <entry>[1280 KiB, 1536 KiB, 1792 KiB, 2 MiB]</entry> 653*8e33eff8Schristos </row> 654*8e33eff8Schristos <row> 655*8e33eff8Schristos <entry>512 KiB</entry> 656*8e33eff8Schristos <entry>[2560 KiB, 3 MiB, 3584 KiB, 4 MiB]</entry> 657*8e33eff8Schristos </row> 658*8e33eff8Schristos <row> 659*8e33eff8Schristos <entry>1 MiB</entry> 660*8e33eff8Schristos <entry>[5 MiB, 6 MiB, 7 MiB, 8 MiB]</entry> 661*8e33eff8Schristos </row> 662*8e33eff8Schristos <row> 663*8e33eff8Schristos <entry>2 MiB</entry> 664*8e33eff8Schristos <entry>[10 MiB, 12 MiB, 14 MiB, 16 MiB]</entry> 665*8e33eff8Schristos </row> 666*8e33eff8Schristos <row> 667*8e33eff8Schristos <entry>4 MiB</entry> 668*8e33eff8Schristos <entry>[20 MiB, 24 MiB, 28 MiB, 32 MiB]</entry> 669*8e33eff8Schristos </row> 670*8e33eff8Schristos <row> 671*8e33eff8Schristos <entry>8 MiB</entry> 672*8e33eff8Schristos <entry>[40 MiB, 48 MiB, 56 MiB, 64 MiB]</entry> 673*8e33eff8Schristos </row> 674*8e33eff8Schristos <row> 675*8e33eff8Schristos <entry>...</entry> 676*8e33eff8Schristos <entry>...</entry> 677*8e33eff8Schristos </row> 678*8e33eff8Schristos <row> 679*8e33eff8Schristos <entry>512 PiB</entry> 680*8e33eff8Schristos <entry>[2560 PiB, 3 EiB, 3584 PiB, 4 EiB]</entry> 681*8e33eff8Schristos </row> 682*8e33eff8Schristos <row> 683*8e33eff8Schristos <entry>1 EiB</entry> 684*8e33eff8Schristos <entry>[5 EiB, 6 EiB, 7 EiB]</entry> 685*8e33eff8Schristos </row> 686*8e33eff8Schristos </tbody> 687*8e33eff8Schristos </tgroup> 688*8e33eff8Schristos </table> 689*8e33eff8Schristos </refsect1> 690*8e33eff8Schristos <refsect1 id="mallctl_namespace"> 691*8e33eff8Schristos <title>MALLCTL NAMESPACE</title> 692*8e33eff8Schristos <para>The following names are defined in the namespace accessible via the 693*8e33eff8Schristos <function>mallctl*()</function> functions. Value types are specified in 694*8e33eff8Schristos parentheses, their readable/writable statuses are encoded as 695*8e33eff8Schristos <literal>rw</literal>, <literal>r-</literal>, <literal>-w</literal>, or 696*8e33eff8Schristos <literal>--</literal>, and required build configuration flags follow, if 697*8e33eff8Schristos any. A name element encoded as <literal><i></literal> or 698*8e33eff8Schristos <literal><j></literal> indicates an integer component, where the 699*8e33eff8Schristos integer varies from 0 to some upper value that must be determined via 700*8e33eff8Schristos introspection. In the case of <mallctl>stats.arenas.<i>.*</mallctl> 701*8e33eff8Schristos and <mallctl>arena.<i>.{initialized,purge,decay,dss}</mallctl>, 702*8e33eff8Schristos <literal><i></literal> equal to 703*8e33eff8Schristos <constant>MALLCTL_ARENAS_ALL</constant> can be used to operate on all arenas 704*8e33eff8Schristos or access the summation of statistics from all arenas; similarly 705*8e33eff8Schristos <literal><i></literal> equal to 706*8e33eff8Schristos <constant>MALLCTL_ARENAS_DESTROYED</constant> can be used to access the 707*8e33eff8Schristos summation of statistics from all destroyed arenas. These constants can be 708*8e33eff8Schristos utilized either via <function>mallctlnametomib()</function> followed by 709*8e33eff8Schristos <function>mallctlbymib()</function>, or via code such as the following: 710*8e33eff8Schristos <programlisting language="C"><![CDATA[ 711*8e33eff8Schristos#define STRINGIFY_HELPER(x) #x 712*8e33eff8Schristos#define STRINGIFY(x) STRINGIFY_HELPER(x) 713*8e33eff8Schristos 714*8e33eff8Schristosmallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".decay", 715*8e33eff8Schristos NULL, NULL, NULL, 0);]]></programlisting> 716*8e33eff8Schristos Take special note of the <link 717*8e33eff8Schristos linkend="epoch"><mallctl>epoch</mallctl></link> mallctl, which controls 718*8e33eff8Schristos refreshing of cached dynamic statistics.</para> 719*8e33eff8Schristos 720*8e33eff8Schristos <variablelist> 721*8e33eff8Schristos <varlistentry id="version"> 722*8e33eff8Schristos <term> 723*8e33eff8Schristos <mallctl>version</mallctl> 724*8e33eff8Schristos (<type>const char *</type>) 725*8e33eff8Schristos <literal>r-</literal> 726*8e33eff8Schristos </term> 727*8e33eff8Schristos <listitem><para>Return the jemalloc version string.</para></listitem> 728*8e33eff8Schristos </varlistentry> 729*8e33eff8Schristos 730*8e33eff8Schristos <varlistentry id="epoch"> 731*8e33eff8Schristos <term> 732*8e33eff8Schristos <mallctl>epoch</mallctl> 733*8e33eff8Schristos (<type>uint64_t</type>) 734*8e33eff8Schristos <literal>rw</literal> 735*8e33eff8Schristos </term> 736*8e33eff8Schristos <listitem><para>If a value is passed in, refresh the data from which 737*8e33eff8Schristos the <function>mallctl*()</function> functions report values, 738*8e33eff8Schristos and increment the epoch. Return the current epoch. This is useful for 739*8e33eff8Schristos detecting whether another thread caused a refresh.</para></listitem> 740*8e33eff8Schristos </varlistentry> 741*8e33eff8Schristos 742*8e33eff8Schristos <varlistentry id="background_thread"> 743*8e33eff8Schristos <term> 744*8e33eff8Schristos <mallctl>background_thread</mallctl> 745*8e33eff8Schristos (<type>bool</type>) 746*8e33eff8Schristos <literal>rw</literal> 747*8e33eff8Schristos </term> 748*8e33eff8Schristos <listitem><para>Enable/disable internal background worker threads. When 749*8e33eff8Schristos set to true, background threads are created on demand (the number of 750*8e33eff8Schristos background threads will be no more than the number of CPUs or active 751*8e33eff8Schristos arenas). Threads run periodically, and handle <link 752*8e33eff8Schristos linkend="arena.i.decay">purging</link> asynchronously. When switching 753*8e33eff8Schristos off, background threads are terminated synchronously. Note that after 754*8e33eff8Schristos <citerefentry><refentrytitle>fork</refentrytitle><manvolnum>2</manvolnum></citerefentry> 755*8e33eff8Schristos function, the state in the child process will be disabled regardless 756*8e33eff8Schristos the state in parent process. See <link 757*8e33eff8Schristos linkend="stats.background_thread.num_threads"><mallctl>stats.background_thread</mallctl></link> 758*8e33eff8Schristos for related stats. <link 759*8e33eff8Schristos linkend="opt.background_thread"><mallctl>opt.background_thread</mallctl></link> 760*8e33eff8Schristos can be used to set the default option. This option is only available on 761*8e33eff8Schristos selected pthread-based platforms.</para></listitem> 762*8e33eff8Schristos </varlistentry> 763*8e33eff8Schristos 764*8e33eff8Schristos <varlistentry id="max_background_threads"> 765*8e33eff8Schristos <term> 766*8e33eff8Schristos <mallctl>max_background_threads</mallctl> 767*8e33eff8Schristos (<type>size_t</type>) 768*8e33eff8Schristos <literal>rw</literal> 769*8e33eff8Schristos </term> 770*8e33eff8Schristos <listitem><para>Maximum number of background worker threads that will 771*8e33eff8Schristos be created. This value is capped at <link 772*8e33eff8Schristos linkend="opt.max_background_threads"><mallctl>opt.max_background_threads</mallctl></link> at 773*8e33eff8Schristos startup.</para></listitem> 774*8e33eff8Schristos </varlistentry> 775*8e33eff8Schristos 776*8e33eff8Schristos <varlistentry id="config.cache_oblivious"> 777*8e33eff8Schristos <term> 778*8e33eff8Schristos <mallctl>config.cache_oblivious</mallctl> 779*8e33eff8Schristos (<type>bool</type>) 780*8e33eff8Schristos <literal>r-</literal> 781*8e33eff8Schristos </term> 782*8e33eff8Schristos <listitem><para><option>--enable-cache-oblivious</option> was specified 783*8e33eff8Schristos during build configuration.</para></listitem> 784*8e33eff8Schristos </varlistentry> 785*8e33eff8Schristos 786*8e33eff8Schristos <varlistentry id="config.debug"> 787*8e33eff8Schristos <term> 788*8e33eff8Schristos <mallctl>config.debug</mallctl> 789*8e33eff8Schristos (<type>bool</type>) 790*8e33eff8Schristos <literal>r-</literal> 791*8e33eff8Schristos </term> 792*8e33eff8Schristos <listitem><para><option>--enable-debug</option> was specified during 793*8e33eff8Schristos build configuration.</para></listitem> 794*8e33eff8Schristos </varlistentry> 795*8e33eff8Schristos 796*8e33eff8Schristos <varlistentry id="config.fill"> 797*8e33eff8Schristos <term> 798*8e33eff8Schristos <mallctl>config.fill</mallctl> 799*8e33eff8Schristos (<type>bool</type>) 800*8e33eff8Schristos <literal>r-</literal> 801*8e33eff8Schristos </term> 802*8e33eff8Schristos <listitem><para><option>--enable-fill</option> was specified during 803*8e33eff8Schristos build configuration.</para></listitem> 804*8e33eff8Schristos </varlistentry> 805*8e33eff8Schristos 806*8e33eff8Schristos <varlistentry id="config.lazy_lock"> 807*8e33eff8Schristos <term> 808*8e33eff8Schristos <mallctl>config.lazy_lock</mallctl> 809*8e33eff8Schristos (<type>bool</type>) 810*8e33eff8Schristos <literal>r-</literal> 811*8e33eff8Schristos </term> 812*8e33eff8Schristos <listitem><para><option>--enable-lazy-lock</option> was specified 813*8e33eff8Schristos during build configuration.</para></listitem> 814*8e33eff8Schristos </varlistentry> 815*8e33eff8Schristos 816*8e33eff8Schristos <varlistentry id="config.malloc_conf"> 817*8e33eff8Schristos <term> 818*8e33eff8Schristos <mallctl>config.malloc_conf</mallctl> 819*8e33eff8Schristos (<type>const char *</type>) 820*8e33eff8Schristos <literal>r-</literal> 821*8e33eff8Schristos </term> 822*8e33eff8Schristos <listitem><para>Embedded configure-time-specified run-time options 823*8e33eff8Schristos string, empty unless <option>--with-malloc-conf</option> was specified 824*8e33eff8Schristos during build configuration.</para></listitem> 825*8e33eff8Schristos </varlistentry> 826*8e33eff8Schristos 827*8e33eff8Schristos <varlistentry id="config.prof"> 828*8e33eff8Schristos <term> 829*8e33eff8Schristos <mallctl>config.prof</mallctl> 830*8e33eff8Schristos (<type>bool</type>) 831*8e33eff8Schristos <literal>r-</literal> 832*8e33eff8Schristos </term> 833*8e33eff8Schristos <listitem><para><option>--enable-prof</option> was specified during 834*8e33eff8Schristos build configuration.</para></listitem> 835*8e33eff8Schristos </varlistentry> 836*8e33eff8Schristos 837*8e33eff8Schristos <varlistentry id="config.prof_libgcc"> 838*8e33eff8Schristos <term> 839*8e33eff8Schristos <mallctl>config.prof_libgcc</mallctl> 840*8e33eff8Schristos (<type>bool</type>) 841*8e33eff8Schristos <literal>r-</literal> 842*8e33eff8Schristos </term> 843*8e33eff8Schristos <listitem><para><option>--disable-prof-libgcc</option> was not 844*8e33eff8Schristos specified during build configuration.</para></listitem> 845*8e33eff8Schristos </varlistentry> 846*8e33eff8Schristos 847*8e33eff8Schristos <varlistentry id="config.prof_libunwind"> 848*8e33eff8Schristos <term> 849*8e33eff8Schristos <mallctl>config.prof_libunwind</mallctl> 850*8e33eff8Schristos (<type>bool</type>) 851*8e33eff8Schristos <literal>r-</literal> 852*8e33eff8Schristos </term> 853*8e33eff8Schristos <listitem><para><option>--enable-prof-libunwind</option> was specified 854*8e33eff8Schristos during build configuration.</para></listitem> 855*8e33eff8Schristos </varlistentry> 856*8e33eff8Schristos 857*8e33eff8Schristos <varlistentry id="config.stats"> 858*8e33eff8Schristos <term> 859*8e33eff8Schristos <mallctl>config.stats</mallctl> 860*8e33eff8Schristos (<type>bool</type>) 861*8e33eff8Schristos <literal>r-</literal> 862*8e33eff8Schristos </term> 863*8e33eff8Schristos <listitem><para><option>--enable-stats</option> was specified during 864*8e33eff8Schristos build configuration.</para></listitem> 865*8e33eff8Schristos </varlistentry> 866*8e33eff8Schristos 867*8e33eff8Schristos 868*8e33eff8Schristos <varlistentry id="config.utrace"> 869*8e33eff8Schristos <term> 870*8e33eff8Schristos <mallctl>config.utrace</mallctl> 871*8e33eff8Schristos (<type>bool</type>) 872*8e33eff8Schristos <literal>r-</literal> 873*8e33eff8Schristos </term> 874*8e33eff8Schristos <listitem><para><option>--enable-utrace</option> was specified during 875*8e33eff8Schristos build configuration.</para></listitem> 876*8e33eff8Schristos </varlistentry> 877*8e33eff8Schristos 878*8e33eff8Schristos <varlistentry id="config.xmalloc"> 879*8e33eff8Schristos <term> 880*8e33eff8Schristos <mallctl>config.xmalloc</mallctl> 881*8e33eff8Schristos (<type>bool</type>) 882*8e33eff8Schristos <literal>r-</literal> 883*8e33eff8Schristos </term> 884*8e33eff8Schristos <listitem><para><option>--enable-xmalloc</option> was specified during 885*8e33eff8Schristos build configuration.</para></listitem> 886*8e33eff8Schristos </varlistentry> 887*8e33eff8Schristos 888*8e33eff8Schristos <varlistentry id="opt.abort"> 889*8e33eff8Schristos <term> 890*8e33eff8Schristos <mallctl>opt.abort</mallctl> 891*8e33eff8Schristos (<type>bool</type>) 892*8e33eff8Schristos <literal>r-</literal> 893*8e33eff8Schristos </term> 894*8e33eff8Schristos <listitem><para>Abort-on-warning enabled/disabled. If true, most 895*8e33eff8Schristos warnings are fatal. Note that runtime option warnings are not included 896*8e33eff8Schristos (see <link 897*8e33eff8Schristos linkend="opt.abort_conf"><mallctl>opt.abort_conf</mallctl></link> for 898*8e33eff8Schristos that). The process will call 899*8e33eff8Schristos <citerefentry><refentrytitle>abort</refentrytitle> 900*8e33eff8Schristos <manvolnum>3</manvolnum></citerefentry> in these cases. This option is 901*8e33eff8Schristos disabled by default unless <option>--enable-debug</option> is 902*8e33eff8Schristos specified during configuration, in which case it is enabled by default. 903*8e33eff8Schristos </para></listitem> 904*8e33eff8Schristos </varlistentry> 905*8e33eff8Schristos 906*8e33eff8Schristos <varlistentry id="opt.abort_conf"> 907*8e33eff8Schristos <term> 908*8e33eff8Schristos <mallctl>opt.abort_conf</mallctl> 909*8e33eff8Schristos (<type>bool</type>) 910*8e33eff8Schristos <literal>r-</literal> 911*8e33eff8Schristos </term> 912*8e33eff8Schristos <listitem><para>Abort-on-invalid-configuration enabled/disabled. If 913*8e33eff8Schristos true, invalid runtime options are fatal. The process will call 914*8e33eff8Schristos <citerefentry><refentrytitle>abort</refentrytitle> 915*8e33eff8Schristos <manvolnum>3</manvolnum></citerefentry> in these cases. This option is 916*8e33eff8Schristos disabled by default unless <option>--enable-debug</option> is 917*8e33eff8Schristos specified during configuration, in which case it is enabled by default. 918*8e33eff8Schristos </para></listitem> 919*8e33eff8Schristos </varlistentry> 920*8e33eff8Schristos 921*8e33eff8Schristos <varlistentry id="opt.metadata_thp"> 922*8e33eff8Schristos <term> 923*8e33eff8Schristos <mallctl>opt.metadata_thp</mallctl> 924*8e33eff8Schristos (<type>const char *</type>) 925*8e33eff8Schristos <literal>r-</literal> 926*8e33eff8Schristos </term> 927*8e33eff8Schristos <listitem><para>Controls whether to allow jemalloc to use transparent 928*8e33eff8Schristos huge page (THP) for internal metadata (see <link 929*8e33eff8Schristos linkend="stats.metadata">stats.metadata</link>). <quote>always</quote> 930*8e33eff8Schristos allows such usage. <quote>auto</quote> uses no THP initially, but may 931*8e33eff8Schristos begin to do so when metadata usage reaches certain level. The default 932*8e33eff8Schristos is <quote>disabled</quote>.</para></listitem> 933*8e33eff8Schristos </varlistentry> 934*8e33eff8Schristos 935*8e33eff8Schristos <varlistentry id="opt.retain"> 936*8e33eff8Schristos <term> 937*8e33eff8Schristos <mallctl>opt.retain</mallctl> 938*8e33eff8Schristos (<type>bool</type>) 939*8e33eff8Schristos <literal>r-</literal> 940*8e33eff8Schristos </term> 941*8e33eff8Schristos <listitem><para>If true, retain unused virtual memory for later reuse 942*8e33eff8Schristos rather than discarding it by calling 943*8e33eff8Schristos <citerefentry><refentrytitle>munmap</refentrytitle> 944*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry> or equivalent (see <link 945*8e33eff8Schristos linkend="stats.retained">stats.retained</link> for related details). 946*8e33eff8Schristos This option is disabled by default unless discarding virtual memory is 947*8e33eff8Schristos known to trigger 948*8e33eff8Schristos platform-specific performance problems, e.g. for [64-bit] Linux, which 949*8e33eff8Schristos has a quirk in its virtual memory allocation algorithm that causes 950*8e33eff8Schristos semi-permanent VM map holes under normal jemalloc operation. Although 951*8e33eff8Schristos <citerefentry><refentrytitle>munmap</refentrytitle> 952*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry> causes issues on 32-bit Linux as 953*8e33eff8Schristos well, retaining virtual memory for 32-bit Linux is disabled by default 954*8e33eff8Schristos due to the practical possibility of address space exhaustion. 955*8e33eff8Schristos </para></listitem> 956*8e33eff8Schristos </varlistentry> 957*8e33eff8Schristos 958*8e33eff8Schristos <varlistentry id="opt.dss"> 959*8e33eff8Schristos <term> 960*8e33eff8Schristos <mallctl>opt.dss</mallctl> 961*8e33eff8Schristos (<type>const char *</type>) 962*8e33eff8Schristos <literal>r-</literal> 963*8e33eff8Schristos </term> 964*8e33eff8Schristos <listitem><para>dss (<citerefentry><refentrytitle>sbrk</refentrytitle> 965*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry>) allocation precedence as 966*8e33eff8Schristos related to <citerefentry><refentrytitle>mmap</refentrytitle> 967*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry> allocation. The following 968*8e33eff8Schristos settings are supported if 969*8e33eff8Schristos <citerefentry><refentrytitle>sbrk</refentrytitle> 970*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry> is supported by the operating 971*8e33eff8Schristos system: <quote>disabled</quote>, <quote>primary</quote>, and 972*8e33eff8Schristos <quote>secondary</quote>; otherwise only <quote>disabled</quote> is 973*8e33eff8Schristos supported. The default is <quote>secondary</quote> if 974*8e33eff8Schristos <citerefentry><refentrytitle>sbrk</refentrytitle> 975*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry> is supported by the operating 976*8e33eff8Schristos system; <quote>disabled</quote> otherwise. 977*8e33eff8Schristos </para></listitem> 978*8e33eff8Schristos </varlistentry> 979*8e33eff8Schristos 980*8e33eff8Schristos <varlistentry id="opt.narenas"> 981*8e33eff8Schristos <term> 982*8e33eff8Schristos <mallctl>opt.narenas</mallctl> 983*8e33eff8Schristos (<type>unsigned</type>) 984*8e33eff8Schristos <literal>r-</literal> 985*8e33eff8Schristos </term> 986*8e33eff8Schristos <listitem><para>Maximum number of arenas to use for automatic 987*8e33eff8Schristos multiplexing of threads and arenas. The default is four times the 988*8e33eff8Schristos number of CPUs, or one if there is a single CPU.</para></listitem> 989*8e33eff8Schristos </varlistentry> 990*8e33eff8Schristos 991*8e33eff8Schristos <varlistentry id="opt.percpu_arena"> 992*8e33eff8Schristos <term> 993*8e33eff8Schristos <mallctl>opt.percpu_arena</mallctl> 994*8e33eff8Schristos (<type>const char *</type>) 995*8e33eff8Schristos <literal>r-</literal> 996*8e33eff8Schristos </term> 997*8e33eff8Schristos <listitem><para>Per CPU arena mode. Use the <quote>percpu</quote> 998*8e33eff8Schristos setting to enable this feature, which uses number of CPUs to determine 999*8e33eff8Schristos number of arenas, and bind threads to arenas dynamically based on the 1000*8e33eff8Schristos CPU the thread runs on currently. <quote>phycpu</quote> setting uses 1001*8e33eff8Schristos one arena per physical CPU, which means the two hyper threads on the 1002*8e33eff8Schristos same CPU share one arena. Note that no runtime checking regarding the 1003*8e33eff8Schristos availability of hyper threading is done at the moment. When set to 1004*8e33eff8Schristos <quote>disabled</quote>, narenas and thread to arena association will 1005*8e33eff8Schristos not be impacted by this option. The default is <quote>disabled</quote>. 1006*8e33eff8Schristos </para></listitem> 1007*8e33eff8Schristos </varlistentry> 1008*8e33eff8Schristos 1009*8e33eff8Schristos <varlistentry id="opt.background_thread"> 1010*8e33eff8Schristos <term> 1011*8e33eff8Schristos <mallctl>opt.background_thread</mallctl> 1012*8e33eff8Schristos (<type>const bool</type>) 1013*8e33eff8Schristos <literal>r-</literal> 1014*8e33eff8Schristos </term> 1015*8e33eff8Schristos <listitem><para>Internal background worker threads enabled/disabled. 1016*8e33eff8Schristos Because of potential circular dependencies, enabling background thread 1017*8e33eff8Schristos using this option may cause crash or deadlock during initialization. For 1018*8e33eff8Schristos a reliable way to use this feature, see <link 1019*8e33eff8Schristos linkend="background_thread">background_thread</link> for dynamic control 1020*8e33eff8Schristos options and details. This option is disabled by 1021*8e33eff8Schristos default.</para></listitem> 1022*8e33eff8Schristos </varlistentry> 1023*8e33eff8Schristos 1024*8e33eff8Schristos <varlistentry id="opt.max_background_threads"> 1025*8e33eff8Schristos <term> 1026*8e33eff8Schristos <mallctl>opt.max_background_threads</mallctl> 1027*8e33eff8Schristos (<type>const size_t</type>) 1028*8e33eff8Schristos <literal>r-</literal> 1029*8e33eff8Schristos </term> 1030*8e33eff8Schristos <listitem><para>Maximum number of background threads that will be created 1031*8e33eff8Schristos if <link linkend="background_thread">background_thread</link> is set. 1032*8e33eff8Schristos Defaults to number of cpus.</para></listitem> 1033*8e33eff8Schristos </varlistentry> 1034*8e33eff8Schristos 1035*8e33eff8Schristos <varlistentry id="opt.dirty_decay_ms"> 1036*8e33eff8Schristos <term> 1037*8e33eff8Schristos <mallctl>opt.dirty_decay_ms</mallctl> 1038*8e33eff8Schristos (<type>ssize_t</type>) 1039*8e33eff8Schristos <literal>r-</literal> 1040*8e33eff8Schristos </term> 1041*8e33eff8Schristos <listitem><para>Approximate time in milliseconds from the creation of a 1042*8e33eff8Schristos set of unused dirty pages until an equivalent set of unused dirty pages 1043*8e33eff8Schristos is purged (i.e. converted to muzzy via e.g. 1044*8e33eff8Schristos <function>madvise(<parameter>...</parameter><parameter><constant>MADV_FREE</constant></parameter>)</function> 1045*8e33eff8Schristos if supported by the operating system, or converted to clean otherwise) 1046*8e33eff8Schristos and/or reused. Dirty pages are defined as previously having been 1047*8e33eff8Schristos potentially written to by the application, and therefore consuming 1048*8e33eff8Schristos physical memory, yet having no current use. The pages are incrementally 1049*8e33eff8Schristos purged according to a sigmoidal decay curve that starts and ends with 1050*8e33eff8Schristos zero purge rate. A decay time of 0 causes all unused dirty pages to be 1051*8e33eff8Schristos purged immediately upon creation. A decay time of -1 disables purging. 1052*8e33eff8Schristos The default decay time is 10 seconds. See <link 1053*8e33eff8Schristos linkend="arenas.dirty_decay_ms"><mallctl>arenas.dirty_decay_ms</mallctl></link> 1054*8e33eff8Schristos and <link 1055*8e33eff8Schristos linkend="arena.i.dirty_decay_ms"><mallctl>arena.<i>.dirty_decay_ms</mallctl></link> 1056*8e33eff8Schristos for related dynamic control options. See <link 1057*8e33eff8Schristos linkend="opt.muzzy_decay_ms"><mallctl>opt.muzzy_decay_ms</mallctl></link> 1058*8e33eff8Schristos for a description of muzzy pages.</para></listitem> 1059*8e33eff8Schristos </varlistentry> 1060*8e33eff8Schristos 1061*8e33eff8Schristos <varlistentry id="opt.muzzy_decay_ms"> 1062*8e33eff8Schristos <term> 1063*8e33eff8Schristos <mallctl>opt.muzzy_decay_ms</mallctl> 1064*8e33eff8Schristos (<type>ssize_t</type>) 1065*8e33eff8Schristos <literal>r-</literal> 1066*8e33eff8Schristos </term> 1067*8e33eff8Schristos <listitem><para>Approximate time in milliseconds from the creation of a 1068*8e33eff8Schristos set of unused muzzy pages until an equivalent set of unused muzzy pages 1069*8e33eff8Schristos is purged (i.e. converted to clean) and/or reused. Muzzy pages are 1070*8e33eff8Schristos defined as previously having been unused dirty pages that were 1071*8e33eff8Schristos subsequently purged in a manner that left them subject to the 1072*8e33eff8Schristos reclamation whims of the operating system (e.g. 1073*8e33eff8Schristos <function>madvise(<parameter>...</parameter><parameter><constant>MADV_FREE</constant></parameter>)</function>), 1074*8e33eff8Schristos and therefore in an indeterminate state. The pages are incrementally 1075*8e33eff8Schristos purged according to a sigmoidal decay curve that starts and ends with 1076*8e33eff8Schristos zero purge rate. A decay time of 0 causes all unused muzzy pages to be 1077*8e33eff8Schristos purged immediately upon creation. A decay time of -1 disables purging. 1078*8e33eff8Schristos The default decay time is 10 seconds. See <link 1079*8e33eff8Schristos linkend="arenas.muzzy_decay_ms"><mallctl>arenas.muzzy_decay_ms</mallctl></link> 1080*8e33eff8Schristos and <link 1081*8e33eff8Schristos linkend="arena.i.muzzy_decay_ms"><mallctl>arena.<i>.muzzy_decay_ms</mallctl></link> 1082*8e33eff8Schristos for related dynamic control options.</para></listitem> 1083*8e33eff8Schristos </varlistentry> 1084*8e33eff8Schristos 1085*8e33eff8Schristos <varlistentry id="opt.lg_extent_max_active_fit"> 1086*8e33eff8Schristos <term> 1087*8e33eff8Schristos <mallctl>opt.lg_extent_max_active_fit</mallctl> 1088*8e33eff8Schristos (<type>size_t</type>) 1089*8e33eff8Schristos <literal>r-</literal> 1090*8e33eff8Schristos </term> 1091*8e33eff8Schristos <listitem><para>When reusing dirty extents, this determines the (log 1092*8e33eff8Schristos base 2 of the) maximum ratio between the size of the active extent 1093*8e33eff8Schristos selected (to split off from) and the size of the requested allocation. 1094*8e33eff8Schristos This prevents the splitting of large active extents for smaller 1095*8e33eff8Schristos allocations, which can reduce fragmentation over the long run 1096*8e33eff8Schristos (especially for non-active extents). Lower value may reduce 1097*8e33eff8Schristos fragmentation, at the cost of extra active extents. The default value 1098*8e33eff8Schristos is 6, which gives a maximum ratio of 64 (2^6).</para></listitem> 1099*8e33eff8Schristos </varlistentry> 1100*8e33eff8Schristos 1101*8e33eff8Schristos <varlistentry id="opt.stats_print"> 1102*8e33eff8Schristos <term> 1103*8e33eff8Schristos <mallctl>opt.stats_print</mallctl> 1104*8e33eff8Schristos (<type>bool</type>) 1105*8e33eff8Schristos <literal>r-</literal> 1106*8e33eff8Schristos </term> 1107*8e33eff8Schristos <listitem><para>Enable/disable statistics printing at exit. If 1108*8e33eff8Schristos enabled, the <function>malloc_stats_print()</function> 1109*8e33eff8Schristos function is called at program exit via an 1110*8e33eff8Schristos <citerefentry><refentrytitle>atexit</refentrytitle> 1111*8e33eff8Schristos <manvolnum>3</manvolnum></citerefentry> function. <link 1112*8e33eff8Schristos linkend="opt.stats_print_opts"><mallctl>opt.stats_print_opts</mallctl></link> 1113*8e33eff8Schristos can be combined to specify output options. If 1114*8e33eff8Schristos <option>--enable-stats</option> is specified during configuration, this 1115*8e33eff8Schristos has the potential to cause deadlock for a multi-threaded process that 1116*8e33eff8Schristos exits while one or more threads are executing in the memory allocation 1117*8e33eff8Schristos functions. Furthermore, <function>atexit()</function> may 1118*8e33eff8Schristos allocate memory during application initialization and then deadlock 1119*8e33eff8Schristos internally when jemalloc in turn calls 1120*8e33eff8Schristos <function>atexit()</function>, so this option is not 1121*8e33eff8Schristos universally usable (though the application can register its own 1122*8e33eff8Schristos <function>atexit()</function> function with equivalent 1123*8e33eff8Schristos functionality). Therefore, this option should only be used with care; 1124*8e33eff8Schristos it is primarily intended as a performance tuning aid during application 1125*8e33eff8Schristos development. This option is disabled by default.</para></listitem> 1126*8e33eff8Schristos </varlistentry> 1127*8e33eff8Schristos 1128*8e33eff8Schristos <varlistentry id="opt.stats_print_opts"> 1129*8e33eff8Schristos <term> 1130*8e33eff8Schristos <mallctl>opt.stats_print_opts</mallctl> 1131*8e33eff8Schristos (<type>const char *</type>) 1132*8e33eff8Schristos <literal>r-</literal> 1133*8e33eff8Schristos </term> 1134*8e33eff8Schristos <listitem><para>Options (the <parameter>opts</parameter> string) to pass 1135*8e33eff8Schristos to the <function>malloc_stats_print()</function> at exit (enabled 1136*8e33eff8Schristos through <link 1137*8e33eff8Schristos linkend="opt.stats_print"><mallctl>opt.stats_print</mallctl></link>). See 1138*8e33eff8Schristos available options in <link 1139*8e33eff8Schristos linkend="malloc_stats_print_opts"><function>malloc_stats_print()</function></link>. 1140*8e33eff8Schristos Has no effect unless <link 1141*8e33eff8Schristos linkend="opt.stats_print"><mallctl>opt.stats_print</mallctl></link> is 1142*8e33eff8Schristos enabled. The default is <quote></quote>.</para></listitem> 1143*8e33eff8Schristos </varlistentry> 1144*8e33eff8Schristos 1145*8e33eff8Schristos <varlistentry id="opt.junk"> 1146*8e33eff8Schristos <term> 1147*8e33eff8Schristos <mallctl>opt.junk</mallctl> 1148*8e33eff8Schristos (<type>const char *</type>) 1149*8e33eff8Schristos <literal>r-</literal> 1150*8e33eff8Schristos [<option>--enable-fill</option>] 1151*8e33eff8Schristos </term> 1152*8e33eff8Schristos <listitem><para>Junk filling. If set to <quote>alloc</quote>, each byte 1153*8e33eff8Schristos of uninitialized allocated memory will be initialized to 1154*8e33eff8Schristos <literal>0xa5</literal>. If set to <quote>free</quote>, all deallocated 1155*8e33eff8Schristos memory will be initialized to <literal>0x5a</literal>. If set to 1156*8e33eff8Schristos <quote>true</quote>, both allocated and deallocated memory will be 1157*8e33eff8Schristos initialized, and if set to <quote>false</quote>, junk filling be 1158*8e33eff8Schristos disabled entirely. This is intended for debugging and will impact 1159*8e33eff8Schristos performance negatively. This option is <quote>false</quote> by default 1160*8e33eff8Schristos unless <option>--enable-debug</option> is specified during 1161*8e33eff8Schristos configuration, in which case it is <quote>true</quote> by 1162*8e33eff8Schristos default.</para></listitem> 1163*8e33eff8Schristos </varlistentry> 1164*8e33eff8Schristos 1165*8e33eff8Schristos <varlistentry id="opt.zero"> 1166*8e33eff8Schristos <term> 1167*8e33eff8Schristos <mallctl>opt.zero</mallctl> 1168*8e33eff8Schristos (<type>bool</type>) 1169*8e33eff8Schristos <literal>r-</literal> 1170*8e33eff8Schristos [<option>--enable-fill</option>] 1171*8e33eff8Schristos </term> 1172*8e33eff8Schristos <listitem><para>Zero filling enabled/disabled. If enabled, each byte 1173*8e33eff8Schristos of uninitialized allocated memory will be initialized to 0. Note that 1174*8e33eff8Schristos this initialization only happens once for each byte, so 1175*8e33eff8Schristos <function>realloc()</function> and 1176*8e33eff8Schristos <function>rallocx()</function> calls do not zero memory that 1177*8e33eff8Schristos was previously allocated. This is intended for debugging and will 1178*8e33eff8Schristos impact performance negatively. This option is disabled by default. 1179*8e33eff8Schristos </para></listitem> 1180*8e33eff8Schristos </varlistentry> 1181*8e33eff8Schristos 1182*8e33eff8Schristos <varlistentry id="opt.utrace"> 1183*8e33eff8Schristos <term> 1184*8e33eff8Schristos <mallctl>opt.utrace</mallctl> 1185*8e33eff8Schristos (<type>bool</type>) 1186*8e33eff8Schristos <literal>r-</literal> 1187*8e33eff8Schristos [<option>--enable-utrace</option>] 1188*8e33eff8Schristos </term> 1189*8e33eff8Schristos <listitem><para>Allocation tracing based on 1190*8e33eff8Schristos <citerefentry><refentrytitle>utrace</refentrytitle> 1191*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry> enabled/disabled. This option 1192*8e33eff8Schristos is disabled by default.</para></listitem> 1193*8e33eff8Schristos </varlistentry> 1194*8e33eff8Schristos 1195*8e33eff8Schristos <varlistentry id="opt.xmalloc"> 1196*8e33eff8Schristos <term> 1197*8e33eff8Schristos <mallctl>opt.xmalloc</mallctl> 1198*8e33eff8Schristos (<type>bool</type>) 1199*8e33eff8Schristos <literal>r-</literal> 1200*8e33eff8Schristos [<option>--enable-xmalloc</option>] 1201*8e33eff8Schristos </term> 1202*8e33eff8Schristos <listitem><para>Abort-on-out-of-memory enabled/disabled. If enabled, 1203*8e33eff8Schristos rather than returning failure for any allocation function, display a 1204*8e33eff8Schristos diagnostic message on <constant>STDERR_FILENO</constant> and cause the 1205*8e33eff8Schristos program to drop core (using 1206*8e33eff8Schristos <citerefentry><refentrytitle>abort</refentrytitle> 1207*8e33eff8Schristos <manvolnum>3</manvolnum></citerefentry>). If an application is 1208*8e33eff8Schristos designed to depend on this behavior, set the option at compile time by 1209*8e33eff8Schristos including the following in the source code: 1210*8e33eff8Schristos <programlisting language="C"><![CDATA[ 1211*8e33eff8Schristosmalloc_conf = "xmalloc:true";]]></programlisting> 1212*8e33eff8Schristos This option is disabled by default.</para></listitem> 1213*8e33eff8Schristos </varlistentry> 1214*8e33eff8Schristos 1215*8e33eff8Schristos <varlistentry id="opt.tcache"> 1216*8e33eff8Schristos <term> 1217*8e33eff8Schristos <mallctl>opt.tcache</mallctl> 1218*8e33eff8Schristos (<type>bool</type>) 1219*8e33eff8Schristos <literal>r-</literal> 1220*8e33eff8Schristos </term> 1221*8e33eff8Schristos <listitem><para>Thread-specific caching (tcache) enabled/disabled. When 1222*8e33eff8Schristos there are multiple threads, each thread uses a tcache for objects up to 1223*8e33eff8Schristos a certain size. Thread-specific caching allows many allocations to be 1224*8e33eff8Schristos satisfied without performing any thread synchronization, at the cost of 1225*8e33eff8Schristos increased memory use. See the <link 1226*8e33eff8Schristos linkend="opt.lg_tcache_max"><mallctl>opt.lg_tcache_max</mallctl></link> 1227*8e33eff8Schristos option for related tuning information. This option is enabled by 1228*8e33eff8Schristos default.</para></listitem> 1229*8e33eff8Schristos </varlistentry> 1230*8e33eff8Schristos 1231*8e33eff8Schristos <varlistentry id="opt.lg_tcache_max"> 1232*8e33eff8Schristos <term> 1233*8e33eff8Schristos <mallctl>opt.lg_tcache_max</mallctl> 1234*8e33eff8Schristos (<type>size_t</type>) 1235*8e33eff8Schristos <literal>r-</literal> 1236*8e33eff8Schristos </term> 1237*8e33eff8Schristos <listitem><para>Maximum size class (log base 2) to cache in the 1238*8e33eff8Schristos thread-specific cache (tcache). At a minimum, all small size classes 1239*8e33eff8Schristos are cached, and at a maximum all large size classes are cached. The 1240*8e33eff8Schristos default maximum is 32 KiB (2^15).</para></listitem> 1241*8e33eff8Schristos </varlistentry> 1242*8e33eff8Schristos 1243*8e33eff8Schristos <varlistentry id="opt.thp"> 1244*8e33eff8Schristos <term> 1245*8e33eff8Schristos <mallctl>opt.thp</mallctl> 1246*8e33eff8Schristos (<type>const char *</type>) 1247*8e33eff8Schristos <literal>r-</literal> 1248*8e33eff8Schristos </term> 1249*8e33eff8Schristos <listitem><para>Transparent hugepage (THP) mode. Settings "always", 1250*8e33eff8Schristos "never" and "default" are available if THP is supported by the operating 1251*8e33eff8Schristos system. The "always" setting enables transparent hugepage for all user 1252*8e33eff8Schristos memory mappings with 1253*8e33eff8Schristos <parameter><constant>MADV_HUGEPAGE</constant></parameter>; "never" 1254*8e33eff8Schristos ensures no transparent hugepage with 1255*8e33eff8Schristos <parameter><constant>MADV_NOHUGEPAGE</constant></parameter>; the default 1256*8e33eff8Schristos setting "default" makes no changes. Note that: this option does not 1257*8e33eff8Schristos affect THP for jemalloc internal metadata (see <link 1258*8e33eff8Schristos linkend="opt.metadata_thp"><mallctl>opt.metadata_thp</mallctl></link>); 1259*8e33eff8Schristos in addition, for arenas with customized <link 1260*8e33eff8Schristos linkend="arena.i.extent_hooks"><mallctl>extent_hooks</mallctl></link>, 1261*8e33eff8Schristos this option is bypassed as it is implemented as part of the default 1262*8e33eff8Schristos extent hooks.</para></listitem> 1263*8e33eff8Schristos </varlistentry> 1264*8e33eff8Schristos 1265*8e33eff8Schristos <varlistentry id="opt.prof"> 1266*8e33eff8Schristos <term> 1267*8e33eff8Schristos <mallctl>opt.prof</mallctl> 1268*8e33eff8Schristos (<type>bool</type>) 1269*8e33eff8Schristos <literal>r-</literal> 1270*8e33eff8Schristos [<option>--enable-prof</option>] 1271*8e33eff8Schristos </term> 1272*8e33eff8Schristos <listitem><para>Memory profiling enabled/disabled. If enabled, profile 1273*8e33eff8Schristos memory allocation activity. See the <link 1274*8e33eff8Schristos linkend="opt.prof_active"><mallctl>opt.prof_active</mallctl></link> 1275*8e33eff8Schristos option for on-the-fly activation/deactivation. See the <link 1276*8e33eff8Schristos linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link> 1277*8e33eff8Schristos option for probabilistic sampling control. See the <link 1278*8e33eff8Schristos linkend="opt.prof_accum"><mallctl>opt.prof_accum</mallctl></link> 1279*8e33eff8Schristos option for control of cumulative sample reporting. See the <link 1280*8e33eff8Schristos linkend="opt.lg_prof_interval"><mallctl>opt.lg_prof_interval</mallctl></link> 1281*8e33eff8Schristos option for information on interval-triggered profile dumping, the <link 1282*8e33eff8Schristos linkend="opt.prof_gdump"><mallctl>opt.prof_gdump</mallctl></link> 1283*8e33eff8Schristos option for information on high-water-triggered profile dumping, and the 1284*8e33eff8Schristos <link linkend="opt.prof_final"><mallctl>opt.prof_final</mallctl></link> 1285*8e33eff8Schristos option for final profile dumping. Profile output is compatible with 1286*8e33eff8Schristos the <command>jeprof</command> command, which is based on the 1287*8e33eff8Schristos <command>pprof</command> that is developed as part of the <ulink 1288*8e33eff8Schristos url="http://code.google.com/p/gperftools/">gperftools 1289*8e33eff8Schristos package</ulink>. See <link linkend="heap_profile_format">HEAP PROFILE 1290*8e33eff8Schristos FORMAT</link> for heap profile format documentation.</para></listitem> 1291*8e33eff8Schristos </varlistentry> 1292*8e33eff8Schristos 1293*8e33eff8Schristos <varlistentry id="opt.prof_prefix"> 1294*8e33eff8Schristos <term> 1295*8e33eff8Schristos <mallctl>opt.prof_prefix</mallctl> 1296*8e33eff8Schristos (<type>const char *</type>) 1297*8e33eff8Schristos <literal>r-</literal> 1298*8e33eff8Schristos [<option>--enable-prof</option>] 1299*8e33eff8Schristos </term> 1300*8e33eff8Schristos <listitem><para>Filename prefix for profile dumps. If the prefix is 1301*8e33eff8Schristos set to the empty string, no automatic dumps will occur; this is 1302*8e33eff8Schristos primarily useful for disabling the automatic final heap dump (which 1303*8e33eff8Schristos also disables leak reporting, if enabled). The default prefix is 1304*8e33eff8Schristos <filename>jeprof</filename>.</para></listitem> 1305*8e33eff8Schristos </varlistentry> 1306*8e33eff8Schristos 1307*8e33eff8Schristos <varlistentry id="opt.prof_active"> 1308*8e33eff8Schristos <term> 1309*8e33eff8Schristos <mallctl>opt.prof_active</mallctl> 1310*8e33eff8Schristos (<type>bool</type>) 1311*8e33eff8Schristos <literal>r-</literal> 1312*8e33eff8Schristos [<option>--enable-prof</option>] 1313*8e33eff8Schristos </term> 1314*8e33eff8Schristos <listitem><para>Profiling activated/deactivated. This is a secondary 1315*8e33eff8Schristos control mechanism that makes it possible to start the application with 1316*8e33eff8Schristos profiling enabled (see the <link 1317*8e33eff8Schristos linkend="opt.prof"><mallctl>opt.prof</mallctl></link> option) but 1318*8e33eff8Schristos inactive, then toggle profiling at any time during program execution 1319*8e33eff8Schristos with the <link 1320*8e33eff8Schristos linkend="prof.active"><mallctl>prof.active</mallctl></link> mallctl. 1321*8e33eff8Schristos This option is enabled by default.</para></listitem> 1322*8e33eff8Schristos </varlistentry> 1323*8e33eff8Schristos 1324*8e33eff8Schristos <varlistentry id="opt.prof_thread_active_init"> 1325*8e33eff8Schristos <term> 1326*8e33eff8Schristos <mallctl>opt.prof_thread_active_init</mallctl> 1327*8e33eff8Schristos (<type>bool</type>) 1328*8e33eff8Schristos <literal>r-</literal> 1329*8e33eff8Schristos [<option>--enable-prof</option>] 1330*8e33eff8Schristos </term> 1331*8e33eff8Schristos <listitem><para>Initial setting for <link 1332*8e33eff8Schristos linkend="thread.prof.active"><mallctl>thread.prof.active</mallctl></link> 1333*8e33eff8Schristos in newly created threads. The initial setting for newly created threads 1334*8e33eff8Schristos can also be changed during execution via the <link 1335*8e33eff8Schristos linkend="prof.thread_active_init"><mallctl>prof.thread_active_init</mallctl></link> 1336*8e33eff8Schristos mallctl. This option is enabled by default.</para></listitem> 1337*8e33eff8Schristos </varlistentry> 1338*8e33eff8Schristos 1339*8e33eff8Schristos <varlistentry id="opt.lg_prof_sample"> 1340*8e33eff8Schristos <term> 1341*8e33eff8Schristos <mallctl>opt.lg_prof_sample</mallctl> 1342*8e33eff8Schristos (<type>size_t</type>) 1343*8e33eff8Schristos <literal>r-</literal> 1344*8e33eff8Schristos [<option>--enable-prof</option>] 1345*8e33eff8Schristos </term> 1346*8e33eff8Schristos <listitem><para>Average interval (log base 2) between allocation 1347*8e33eff8Schristos samples, as measured in bytes of allocation activity. Increasing the 1348*8e33eff8Schristos sampling interval decreases profile fidelity, but also decreases the 1349*8e33eff8Schristos computational overhead. The default sample interval is 512 KiB (2^19 1350*8e33eff8Schristos B).</para></listitem> 1351*8e33eff8Schristos </varlistentry> 1352*8e33eff8Schristos 1353*8e33eff8Schristos <varlistentry id="opt.prof_accum"> 1354*8e33eff8Schristos <term> 1355*8e33eff8Schristos <mallctl>opt.prof_accum</mallctl> 1356*8e33eff8Schristos (<type>bool</type>) 1357*8e33eff8Schristos <literal>r-</literal> 1358*8e33eff8Schristos [<option>--enable-prof</option>] 1359*8e33eff8Schristos </term> 1360*8e33eff8Schristos <listitem><para>Reporting of cumulative object/byte counts in profile 1361*8e33eff8Schristos dumps enabled/disabled. If this option is enabled, every unique 1362*8e33eff8Schristos backtrace must be stored for the duration of execution. Depending on 1363*8e33eff8Schristos the application, this can impose a large memory overhead, and the 1364*8e33eff8Schristos cumulative counts are not always of interest. This option is disabled 1365*8e33eff8Schristos by default.</para></listitem> 1366*8e33eff8Schristos </varlistentry> 1367*8e33eff8Schristos 1368*8e33eff8Schristos <varlistentry id="opt.lg_prof_interval"> 1369*8e33eff8Schristos <term> 1370*8e33eff8Schristos <mallctl>opt.lg_prof_interval</mallctl> 1371*8e33eff8Schristos (<type>ssize_t</type>) 1372*8e33eff8Schristos <literal>r-</literal> 1373*8e33eff8Schristos [<option>--enable-prof</option>] 1374*8e33eff8Schristos </term> 1375*8e33eff8Schristos <listitem><para>Average interval (log base 2) between memory profile 1376*8e33eff8Schristos dumps, as measured in bytes of allocation activity. The actual 1377*8e33eff8Schristos interval between dumps may be sporadic because decentralized allocation 1378*8e33eff8Schristos counters are used to avoid synchronization bottlenecks. Profiles are 1379*8e33eff8Schristos dumped to files named according to the pattern 1380*8e33eff8Schristos <filename><prefix>.<pid>.<seq>.i<iseq>.heap</filename>, 1381*8e33eff8Schristos where <literal><prefix></literal> is controlled by the 1382*8e33eff8Schristos <link 1383*8e33eff8Schristos linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> 1384*8e33eff8Schristos option. By default, interval-triggered profile dumping is disabled 1385*8e33eff8Schristos (encoded as -1). 1386*8e33eff8Schristos </para></listitem> 1387*8e33eff8Schristos </varlistentry> 1388*8e33eff8Schristos 1389*8e33eff8Schristos <varlistentry id="opt.prof_gdump"> 1390*8e33eff8Schristos <term> 1391*8e33eff8Schristos <mallctl>opt.prof_gdump</mallctl> 1392*8e33eff8Schristos (<type>bool</type>) 1393*8e33eff8Schristos <literal>r-</literal> 1394*8e33eff8Schristos [<option>--enable-prof</option>] 1395*8e33eff8Schristos </term> 1396*8e33eff8Schristos <listitem><para>Set the initial state of <link 1397*8e33eff8Schristos linkend="prof.gdump"><mallctl>prof.gdump</mallctl></link>, which when 1398*8e33eff8Schristos enabled triggers a memory profile dump every time the total virtual 1399*8e33eff8Schristos memory exceeds the previous maximum. This option is disabled by 1400*8e33eff8Schristos default.</para></listitem> 1401*8e33eff8Schristos </varlistentry> 1402*8e33eff8Schristos 1403*8e33eff8Schristos <varlistentry id="opt.prof_final"> 1404*8e33eff8Schristos <term> 1405*8e33eff8Schristos <mallctl>opt.prof_final</mallctl> 1406*8e33eff8Schristos (<type>bool</type>) 1407*8e33eff8Schristos <literal>r-</literal> 1408*8e33eff8Schristos [<option>--enable-prof</option>] 1409*8e33eff8Schristos </term> 1410*8e33eff8Schristos <listitem><para>Use an 1411*8e33eff8Schristos <citerefentry><refentrytitle>atexit</refentrytitle> 1412*8e33eff8Schristos <manvolnum>3</manvolnum></citerefentry> function to dump final memory 1413*8e33eff8Schristos usage to a file named according to the pattern 1414*8e33eff8Schristos <filename><prefix>.<pid>.<seq>.f.heap</filename>, 1415*8e33eff8Schristos where <literal><prefix></literal> is controlled by the <link 1416*8e33eff8Schristos linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> 1417*8e33eff8Schristos option. Note that <function>atexit()</function> may allocate 1418*8e33eff8Schristos memory during application initialization and then deadlock internally 1419*8e33eff8Schristos when jemalloc in turn calls <function>atexit()</function>, so 1420*8e33eff8Schristos this option is not universally usable (though the application can 1421*8e33eff8Schristos register its own <function>atexit()</function> function with 1422*8e33eff8Schristos equivalent functionality). This option is disabled by 1423*8e33eff8Schristos default.</para></listitem> 1424*8e33eff8Schristos </varlistentry> 1425*8e33eff8Schristos 1426*8e33eff8Schristos <varlistentry id="opt.prof_leak"> 1427*8e33eff8Schristos <term> 1428*8e33eff8Schristos <mallctl>opt.prof_leak</mallctl> 1429*8e33eff8Schristos (<type>bool</type>) 1430*8e33eff8Schristos <literal>r-</literal> 1431*8e33eff8Schristos [<option>--enable-prof</option>] 1432*8e33eff8Schristos </term> 1433*8e33eff8Schristos <listitem><para>Leak reporting enabled/disabled. If enabled, use an 1434*8e33eff8Schristos <citerefentry><refentrytitle>atexit</refentrytitle> 1435*8e33eff8Schristos <manvolnum>3</manvolnum></citerefentry> function to report memory leaks 1436*8e33eff8Schristos detected by allocation sampling. See the 1437*8e33eff8Schristos <link linkend="opt.prof"><mallctl>opt.prof</mallctl></link> option for 1438*8e33eff8Schristos information on analyzing heap profile output. This option is disabled 1439*8e33eff8Schristos by default.</para></listitem> 1440*8e33eff8Schristos </varlistentry> 1441*8e33eff8Schristos 1442*8e33eff8Schristos <varlistentry id="thread.arena"> 1443*8e33eff8Schristos <term> 1444*8e33eff8Schristos <mallctl>thread.arena</mallctl> 1445*8e33eff8Schristos (<type>unsigned</type>) 1446*8e33eff8Schristos <literal>rw</literal> 1447*8e33eff8Schristos </term> 1448*8e33eff8Schristos <listitem><para>Get or set the arena associated with the calling 1449*8e33eff8Schristos thread. If the specified arena was not initialized beforehand (see the 1450*8e33eff8Schristos <link 1451*8e33eff8Schristos linkend="arena.i.initialized"><mallctl>arena.i.initialized</mallctl></link> 1452*8e33eff8Schristos mallctl), it will be automatically initialized as a side effect of 1453*8e33eff8Schristos calling this interface.</para></listitem> 1454*8e33eff8Schristos </varlistentry> 1455*8e33eff8Schristos 1456*8e33eff8Schristos <varlistentry id="thread.allocated"> 1457*8e33eff8Schristos <term> 1458*8e33eff8Schristos <mallctl>thread.allocated</mallctl> 1459*8e33eff8Schristos (<type>uint64_t</type>) 1460*8e33eff8Schristos <literal>r-</literal> 1461*8e33eff8Schristos [<option>--enable-stats</option>] 1462*8e33eff8Schristos </term> 1463*8e33eff8Schristos <listitem><para>Get the total number of bytes ever allocated by the 1464*8e33eff8Schristos calling thread. This counter has the potential to wrap around; it is 1465*8e33eff8Schristos up to the application to appropriately interpret the counter in such 1466*8e33eff8Schristos cases.</para></listitem> 1467*8e33eff8Schristos </varlistentry> 1468*8e33eff8Schristos 1469*8e33eff8Schristos <varlistentry id="thread.allocatedp"> 1470*8e33eff8Schristos <term> 1471*8e33eff8Schristos <mallctl>thread.allocatedp</mallctl> 1472*8e33eff8Schristos (<type>uint64_t *</type>) 1473*8e33eff8Schristos <literal>r-</literal> 1474*8e33eff8Schristos [<option>--enable-stats</option>] 1475*8e33eff8Schristos </term> 1476*8e33eff8Schristos <listitem><para>Get a pointer to the the value that is returned by the 1477*8e33eff8Schristos <link 1478*8e33eff8Schristos linkend="thread.allocated"><mallctl>thread.allocated</mallctl></link> 1479*8e33eff8Schristos mallctl. This is useful for avoiding the overhead of repeated 1480*8e33eff8Schristos <function>mallctl*()</function> calls.</para></listitem> 1481*8e33eff8Schristos </varlistentry> 1482*8e33eff8Schristos 1483*8e33eff8Schristos <varlistentry id="thread.deallocated"> 1484*8e33eff8Schristos <term> 1485*8e33eff8Schristos <mallctl>thread.deallocated</mallctl> 1486*8e33eff8Schristos (<type>uint64_t</type>) 1487*8e33eff8Schristos <literal>r-</literal> 1488*8e33eff8Schristos [<option>--enable-stats</option>] 1489*8e33eff8Schristos </term> 1490*8e33eff8Schristos <listitem><para>Get the total number of bytes ever deallocated by the 1491*8e33eff8Schristos calling thread. This counter has the potential to wrap around; it is 1492*8e33eff8Schristos up to the application to appropriately interpret the counter in such 1493*8e33eff8Schristos cases.</para></listitem> 1494*8e33eff8Schristos </varlistentry> 1495*8e33eff8Schristos 1496*8e33eff8Schristos <varlistentry id="thread.deallocatedp"> 1497*8e33eff8Schristos <term> 1498*8e33eff8Schristos <mallctl>thread.deallocatedp</mallctl> 1499*8e33eff8Schristos (<type>uint64_t *</type>) 1500*8e33eff8Schristos <literal>r-</literal> 1501*8e33eff8Schristos [<option>--enable-stats</option>] 1502*8e33eff8Schristos </term> 1503*8e33eff8Schristos <listitem><para>Get a pointer to the the value that is returned by the 1504*8e33eff8Schristos <link 1505*8e33eff8Schristos linkend="thread.deallocated"><mallctl>thread.deallocated</mallctl></link> 1506*8e33eff8Schristos mallctl. This is useful for avoiding the overhead of repeated 1507*8e33eff8Schristos <function>mallctl*()</function> calls.</para></listitem> 1508*8e33eff8Schristos </varlistentry> 1509*8e33eff8Schristos 1510*8e33eff8Schristos <varlistentry id="thread.tcache.enabled"> 1511*8e33eff8Schristos <term> 1512*8e33eff8Schristos <mallctl>thread.tcache.enabled</mallctl> 1513*8e33eff8Schristos (<type>bool</type>) 1514*8e33eff8Schristos <literal>rw</literal> 1515*8e33eff8Schristos </term> 1516*8e33eff8Schristos <listitem><para>Enable/disable calling thread's tcache. The tcache is 1517*8e33eff8Schristos implicitly flushed as a side effect of becoming 1518*8e33eff8Schristos disabled (see <link 1519*8e33eff8Schristos linkend="thread.tcache.flush"><mallctl>thread.tcache.flush</mallctl></link>). 1520*8e33eff8Schristos </para></listitem> 1521*8e33eff8Schristos </varlistentry> 1522*8e33eff8Schristos 1523*8e33eff8Schristos <varlistentry id="thread.tcache.flush"> 1524*8e33eff8Schristos <term> 1525*8e33eff8Schristos <mallctl>thread.tcache.flush</mallctl> 1526*8e33eff8Schristos (<type>void</type>) 1527*8e33eff8Schristos <literal>--</literal> 1528*8e33eff8Schristos </term> 1529*8e33eff8Schristos <listitem><para>Flush calling thread's thread-specific cache (tcache). 1530*8e33eff8Schristos This interface releases all cached objects and internal data structures 1531*8e33eff8Schristos associated with the calling thread's tcache. Ordinarily, this interface 1532*8e33eff8Schristos need not be called, since automatic periodic incremental garbage 1533*8e33eff8Schristos collection occurs, and the thread cache is automatically discarded when 1534*8e33eff8Schristos a thread exits. However, garbage collection is triggered by allocation 1535*8e33eff8Schristos activity, so it is possible for a thread that stops 1536*8e33eff8Schristos allocating/deallocating to retain its cache indefinitely, in which case 1537*8e33eff8Schristos the developer may find manual flushing useful.</para></listitem> 1538*8e33eff8Schristos </varlistentry> 1539*8e33eff8Schristos 1540*8e33eff8Schristos <varlistentry id="thread.prof.name"> 1541*8e33eff8Schristos <term> 1542*8e33eff8Schristos <mallctl>thread.prof.name</mallctl> 1543*8e33eff8Schristos (<type>const char *</type>) 1544*8e33eff8Schristos <literal>r-</literal> or 1545*8e33eff8Schristos <literal>-w</literal> 1546*8e33eff8Schristos [<option>--enable-prof</option>] 1547*8e33eff8Schristos </term> 1548*8e33eff8Schristos <listitem><para>Get/set the descriptive name associated with the calling 1549*8e33eff8Schristos thread in memory profile dumps. An internal copy of the name string is 1550*8e33eff8Schristos created, so the input string need not be maintained after this interface 1551*8e33eff8Schristos completes execution. The output string of this interface should be 1552*8e33eff8Schristos copied for non-ephemeral uses, because multiple implementation details 1553*8e33eff8Schristos can cause asynchronous string deallocation. Furthermore, each 1554*8e33eff8Schristos invocation of this interface can only read or write; simultaneous 1555*8e33eff8Schristos read/write is not supported due to string lifetime limitations. The 1556*8e33eff8Schristos name string must be nil-terminated and comprised only of characters in 1557*8e33eff8Schristos the sets recognized 1558*8e33eff8Schristos by <citerefentry><refentrytitle>isgraph</refentrytitle> 1559*8e33eff8Schristos <manvolnum>3</manvolnum></citerefentry> and 1560*8e33eff8Schristos <citerefentry><refentrytitle>isblank</refentrytitle> 1561*8e33eff8Schristos <manvolnum>3</manvolnum></citerefentry>.</para></listitem> 1562*8e33eff8Schristos </varlistentry> 1563*8e33eff8Schristos 1564*8e33eff8Schristos <varlistentry id="thread.prof.active"> 1565*8e33eff8Schristos <term> 1566*8e33eff8Schristos <mallctl>thread.prof.active</mallctl> 1567*8e33eff8Schristos (<type>bool</type>) 1568*8e33eff8Schristos <literal>rw</literal> 1569*8e33eff8Schristos [<option>--enable-prof</option>] 1570*8e33eff8Schristos </term> 1571*8e33eff8Schristos <listitem><para>Control whether sampling is currently active for the 1572*8e33eff8Schristos calling thread. This is an activation mechanism in addition to <link 1573*8e33eff8Schristos linkend="prof.active"><mallctl>prof.active</mallctl></link>; both must 1574*8e33eff8Schristos be active for the calling thread to sample. This flag is enabled by 1575*8e33eff8Schristos default.</para></listitem> 1576*8e33eff8Schristos </varlistentry> 1577*8e33eff8Schristos 1578*8e33eff8Schristos <varlistentry id="tcache.create"> 1579*8e33eff8Schristos <term> 1580*8e33eff8Schristos <mallctl>tcache.create</mallctl> 1581*8e33eff8Schristos (<type>unsigned</type>) 1582*8e33eff8Schristos <literal>r-</literal> 1583*8e33eff8Schristos </term> 1584*8e33eff8Schristos <listitem><para>Create an explicit thread-specific cache (tcache) and 1585*8e33eff8Schristos return an identifier that can be passed to the <link 1586*8e33eff8Schristos linkend="MALLOCX_TCACHE"><constant>MALLOCX_TCACHE(<parameter>tc</parameter>)</constant></link> 1587*8e33eff8Schristos macro to explicitly use the specified cache rather than the 1588*8e33eff8Schristos automatically managed one that is used by default. Each explicit cache 1589*8e33eff8Schristos can be used by only one thread at a time; the application must assure 1590*8e33eff8Schristos that this constraint holds. 1591*8e33eff8Schristos </para></listitem> 1592*8e33eff8Schristos </varlistentry> 1593*8e33eff8Schristos 1594*8e33eff8Schristos <varlistentry id="tcache.flush"> 1595*8e33eff8Schristos <term> 1596*8e33eff8Schristos <mallctl>tcache.flush</mallctl> 1597*8e33eff8Schristos (<type>unsigned</type>) 1598*8e33eff8Schristos <literal>-w</literal> 1599*8e33eff8Schristos </term> 1600*8e33eff8Schristos <listitem><para>Flush the specified thread-specific cache (tcache). The 1601*8e33eff8Schristos same considerations apply to this interface as to <link 1602*8e33eff8Schristos linkend="thread.tcache.flush"><mallctl>thread.tcache.flush</mallctl></link>, 1603*8e33eff8Schristos except that the tcache will never be automatically discarded. 1604*8e33eff8Schristos </para></listitem> 1605*8e33eff8Schristos </varlistentry> 1606*8e33eff8Schristos 1607*8e33eff8Schristos <varlistentry id="tcache.destroy"> 1608*8e33eff8Schristos <term> 1609*8e33eff8Schristos <mallctl>tcache.destroy</mallctl> 1610*8e33eff8Schristos (<type>unsigned</type>) 1611*8e33eff8Schristos <literal>-w</literal> 1612*8e33eff8Schristos </term> 1613*8e33eff8Schristos <listitem><para>Flush the specified thread-specific cache (tcache) and 1614*8e33eff8Schristos make the identifier available for use during a future tcache creation. 1615*8e33eff8Schristos </para></listitem> 1616*8e33eff8Schristos </varlistentry> 1617*8e33eff8Schristos 1618*8e33eff8Schristos <varlistentry id="arena.i.initialized"> 1619*8e33eff8Schristos <term> 1620*8e33eff8Schristos <mallctl>arena.<i>.initialized</mallctl> 1621*8e33eff8Schristos (<type>bool</type>) 1622*8e33eff8Schristos <literal>r-</literal> 1623*8e33eff8Schristos </term> 1624*8e33eff8Schristos <listitem><para>Get whether the specified arena's statistics are 1625*8e33eff8Schristos initialized (i.e. the arena was initialized prior to the current epoch). 1626*8e33eff8Schristos This interface can also be nominally used to query whether the merged 1627*8e33eff8Schristos statistics corresponding to <constant>MALLCTL_ARENAS_ALL</constant> are 1628*8e33eff8Schristos initialized (always true).</para></listitem> 1629*8e33eff8Schristos </varlistentry> 1630*8e33eff8Schristos 1631*8e33eff8Schristos <varlistentry id="arena.i.decay"> 1632*8e33eff8Schristos <term> 1633*8e33eff8Schristos <mallctl>arena.<i>.decay</mallctl> 1634*8e33eff8Schristos (<type>void</type>) 1635*8e33eff8Schristos <literal>--</literal> 1636*8e33eff8Schristos </term> 1637*8e33eff8Schristos <listitem><para>Trigger decay-based purging of unused dirty/muzzy pages 1638*8e33eff8Schristos for arena <i>, or for all arenas if <i> equals 1639*8e33eff8Schristos <constant>MALLCTL_ARENAS_ALL</constant>. The proportion of unused 1640*8e33eff8Schristos dirty/muzzy pages to be purged depends on the current time; see <link 1641*8e33eff8Schristos linkend="opt.dirty_decay_ms"><mallctl>opt.dirty_decay_ms</mallctl></link> 1642*8e33eff8Schristos and <link 1643*8e33eff8Schristos linkend="opt.muzzy_decay_ms"><mallctl>opt.muzy_decay_ms</mallctl></link> 1644*8e33eff8Schristos for details.</para></listitem> 1645*8e33eff8Schristos </varlistentry> 1646*8e33eff8Schristos 1647*8e33eff8Schristos <varlistentry id="arena.i.purge"> 1648*8e33eff8Schristos <term> 1649*8e33eff8Schristos <mallctl>arena.<i>.purge</mallctl> 1650*8e33eff8Schristos (<type>void</type>) 1651*8e33eff8Schristos <literal>--</literal> 1652*8e33eff8Schristos </term> 1653*8e33eff8Schristos <listitem><para>Purge all unused dirty pages for arena <i>, or for 1654*8e33eff8Schristos all arenas if <i> equals <constant>MALLCTL_ARENAS_ALL</constant>. 1655*8e33eff8Schristos </para></listitem> 1656*8e33eff8Schristos </varlistentry> 1657*8e33eff8Schristos 1658*8e33eff8Schristos <varlistentry id="arena.i.reset"> 1659*8e33eff8Schristos <term> 1660*8e33eff8Schristos <mallctl>arena.<i>.reset</mallctl> 1661*8e33eff8Schristos (<type>void</type>) 1662*8e33eff8Schristos <literal>--</literal> 1663*8e33eff8Schristos </term> 1664*8e33eff8Schristos <listitem><para>Discard all of the arena's extant allocations. This 1665*8e33eff8Schristos interface can only be used with arenas explicitly created via <link 1666*8e33eff8Schristos linkend="arenas.create"><mallctl>arenas.create</mallctl></link>. None 1667*8e33eff8Schristos of the arena's discarded/cached allocations may accessed afterward. As 1668*8e33eff8Schristos part of this requirement, all thread caches which were used to 1669*8e33eff8Schristos allocate/deallocate in conjunction with the arena must be flushed 1670*8e33eff8Schristos beforehand.</para></listitem> 1671*8e33eff8Schristos </varlistentry> 1672*8e33eff8Schristos 1673*8e33eff8Schristos <varlistentry id="arena.i.destroy"> 1674*8e33eff8Schristos <term> 1675*8e33eff8Schristos <mallctl>arena.<i>.destroy</mallctl> 1676*8e33eff8Schristos (<type>void</type>) 1677*8e33eff8Schristos <literal>--</literal> 1678*8e33eff8Schristos </term> 1679*8e33eff8Schristos <listitem><para>Destroy the arena. Discard all of the arena's extant 1680*8e33eff8Schristos allocations using the same mechanism as for <link 1681*8e33eff8Schristos linkend="arena.i.reset"><mallctl>arena.<i>.reset</mallctl></link> 1682*8e33eff8Schristos (with all the same constraints and side effects), merge the arena stats 1683*8e33eff8Schristos into those accessible at arena index 1684*8e33eff8Schristos <constant>MALLCTL_ARENAS_DESTROYED</constant>, and then completely 1685*8e33eff8Schristos discard all metadata associated with the arena. Future calls to <link 1686*8e33eff8Schristos linkend="arenas.create"><mallctl>arenas.create</mallctl></link> may 1687*8e33eff8Schristos recycle the arena index. Destruction will fail if any threads are 1688*8e33eff8Schristos currently associated with the arena as a result of calls to <link 1689*8e33eff8Schristos linkend="thread.arena"><mallctl>thread.arena</mallctl></link>.</para></listitem> 1690*8e33eff8Schristos </varlistentry> 1691*8e33eff8Schristos 1692*8e33eff8Schristos <varlistentry id="arena.i.dss"> 1693*8e33eff8Schristos <term> 1694*8e33eff8Schristos <mallctl>arena.<i>.dss</mallctl> 1695*8e33eff8Schristos (<type>const char *</type>) 1696*8e33eff8Schristos <literal>rw</literal> 1697*8e33eff8Schristos </term> 1698*8e33eff8Schristos <listitem><para>Set the precedence of dss allocation as related to mmap 1699*8e33eff8Schristos allocation for arena <i>, or for all arenas if <i> equals 1700*8e33eff8Schristos <constant>MALLCTL_ARENAS_ALL</constant>. See <link 1701*8e33eff8Schristos linkend="opt.dss"><mallctl>opt.dss</mallctl></link> for supported 1702*8e33eff8Schristos settings.</para></listitem> 1703*8e33eff8Schristos </varlistentry> 1704*8e33eff8Schristos 1705*8e33eff8Schristos <varlistentry id="arena.i.dirty_decay_ms"> 1706*8e33eff8Schristos <term> 1707*8e33eff8Schristos <mallctl>arena.<i>.dirty_decay_ms</mallctl> 1708*8e33eff8Schristos (<type>ssize_t</type>) 1709*8e33eff8Schristos <literal>rw</literal> 1710*8e33eff8Schristos </term> 1711*8e33eff8Schristos <listitem><para>Current per-arena approximate time in milliseconds from 1712*8e33eff8Schristos the creation of a set of unused dirty pages until an equivalent set of 1713*8e33eff8Schristos unused dirty pages is purged and/or reused. Each time this interface is 1714*8e33eff8Schristos set, all currently unused dirty pages are considered to have fully 1715*8e33eff8Schristos decayed, which causes immediate purging of all unused dirty pages unless 1716*8e33eff8Schristos the decay time is set to -1 (i.e. purging disabled). See <link 1717*8e33eff8Schristos linkend="opt.dirty_decay_ms"><mallctl>opt.dirty_decay_ms</mallctl></link> 1718*8e33eff8Schristos for additional information.</para></listitem> 1719*8e33eff8Schristos </varlistentry> 1720*8e33eff8Schristos 1721*8e33eff8Schristos <varlistentry id="arena.i.muzzy_decay_ms"> 1722*8e33eff8Schristos <term> 1723*8e33eff8Schristos <mallctl>arena.<i>.muzzy_decay_ms</mallctl> 1724*8e33eff8Schristos (<type>ssize_t</type>) 1725*8e33eff8Schristos <literal>rw</literal> 1726*8e33eff8Schristos </term> 1727*8e33eff8Schristos <listitem><para>Current per-arena approximate time in milliseconds from 1728*8e33eff8Schristos the creation of a set of unused muzzy pages until an equivalent set of 1729*8e33eff8Schristos unused muzzy pages is purged and/or reused. Each time this interface is 1730*8e33eff8Schristos set, all currently unused muzzy pages are considered to have fully 1731*8e33eff8Schristos decayed, which causes immediate purging of all unused muzzy pages unless 1732*8e33eff8Schristos the decay time is set to -1 (i.e. purging disabled). See <link 1733*8e33eff8Schristos linkend="opt.muzzy_decay_ms"><mallctl>opt.muzzy_decay_ms</mallctl></link> 1734*8e33eff8Schristos for additional information.</para></listitem> 1735*8e33eff8Schristos </varlistentry> 1736*8e33eff8Schristos 1737*8e33eff8Schristos <varlistentry id="arena.i.retain_grow_limit"> 1738*8e33eff8Schristos <term> 1739*8e33eff8Schristos <mallctl>arena.<i>.retain_grow_limit</mallctl> 1740*8e33eff8Schristos (<type>size_t</type>) 1741*8e33eff8Schristos <literal>rw</literal> 1742*8e33eff8Schristos </term> 1743*8e33eff8Schristos <listitem><para>Maximum size to grow retained region (only relevant when 1744*8e33eff8Schristos <link linkend="opt.retain"><mallctl>opt.retain</mallctl></link> is 1745*8e33eff8Schristos enabled). This controls the maximum increment to expand virtual memory, 1746*8e33eff8Schristos or allocation through <link 1747*8e33eff8Schristos linkend="arena.i.extent_hooks"><mallctl>arena.<i>extent_hooks</mallctl></link>. 1748*8e33eff8Schristos In particular, if customized extent hooks reserve physical memory 1749*8e33eff8Schristos (e.g. 1G huge pages), this is useful to control the allocation hook's 1750*8e33eff8Schristos input size. The default is no limit.</para></listitem> 1751*8e33eff8Schristos </varlistentry> 1752*8e33eff8Schristos 1753*8e33eff8Schristos <varlistentry id="arena.i.extent_hooks"> 1754*8e33eff8Schristos <term> 1755*8e33eff8Schristos <mallctl>arena.<i>.extent_hooks</mallctl> 1756*8e33eff8Schristos (<type>extent_hooks_t *</type>) 1757*8e33eff8Schristos <literal>rw</literal> 1758*8e33eff8Schristos </term> 1759*8e33eff8Schristos <listitem><para>Get or set the extent management hook functions for 1760*8e33eff8Schristos arena <i>. The functions must be capable of operating on all 1761*8e33eff8Schristos extant extents associated with arena <i>, usually by passing 1762*8e33eff8Schristos unknown extents to the replaced functions. In practice, it is feasible 1763*8e33eff8Schristos to control allocation for arenas explicitly created via <link 1764*8e33eff8Schristos linkend="arenas.create"><mallctl>arenas.create</mallctl></link> such 1765*8e33eff8Schristos that all extents originate from an application-supplied extent allocator 1766*8e33eff8Schristos (by specifying the custom extent hook functions during arena creation), 1767*8e33eff8Schristos but the automatically created arenas will have already created extents 1768*8e33eff8Schristos prior to the application having an opportunity to take over extent 1769*8e33eff8Schristos allocation.</para> 1770*8e33eff8Schristos 1771*8e33eff8Schristos <programlisting language="C"><![CDATA[ 1772*8e33eff8Schristostypedef extent_hooks_s extent_hooks_t; 1773*8e33eff8Schristosstruct extent_hooks_s { 1774*8e33eff8Schristos extent_alloc_t *alloc; 1775*8e33eff8Schristos extent_dalloc_t *dalloc; 1776*8e33eff8Schristos extent_destroy_t *destroy; 1777*8e33eff8Schristos extent_commit_t *commit; 1778*8e33eff8Schristos extent_decommit_t *decommit; 1779*8e33eff8Schristos extent_purge_t *purge_lazy; 1780*8e33eff8Schristos extent_purge_t *purge_forced; 1781*8e33eff8Schristos extent_split_t *split; 1782*8e33eff8Schristos extent_merge_t *merge; 1783*8e33eff8Schristos};]]></programlisting> 1784*8e33eff8Schristos <para>The <type>extent_hooks_t</type> structure comprises function 1785*8e33eff8Schristos pointers which are described individually below. jemalloc uses these 1786*8e33eff8Schristos functions to manage extent lifetime, which starts off with allocation of 1787*8e33eff8Schristos mapped committed memory, in the simplest case followed by deallocation. 1788*8e33eff8Schristos However, there are performance and platform reasons to retain extents 1789*8e33eff8Schristos for later reuse. Cleanup attempts cascade from deallocation to decommit 1790*8e33eff8Schristos to forced purging to lazy purging, which gives the extent management 1791*8e33eff8Schristos functions opportunities to reject the most permanent cleanup operations 1792*8e33eff8Schristos in favor of less permanent (and often less costly) operations. All 1793*8e33eff8Schristos operations except allocation can be universally opted out of by setting 1794*8e33eff8Schristos the hook pointers to <constant>NULL</constant>, or selectively opted out 1795*8e33eff8Schristos of by returning failure. Note that once the extent hook is set, the 1796*8e33eff8Schristos structure is accessed directly by the associated arenas, so it must 1797*8e33eff8Schristos remain valid for the entire lifetime of the arenas.</para> 1798*8e33eff8Schristos 1799*8e33eff8Schristos <funcsynopsis><funcprototype> 1800*8e33eff8Schristos <funcdef>typedef void *<function>(extent_alloc_t)</function></funcdef> 1801*8e33eff8Schristos <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef> 1802*8e33eff8Schristos <paramdef>void *<parameter>new_addr</parameter></paramdef> 1803*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 1804*8e33eff8Schristos <paramdef>size_t <parameter>alignment</parameter></paramdef> 1805*8e33eff8Schristos <paramdef>bool *<parameter>zero</parameter></paramdef> 1806*8e33eff8Schristos <paramdef>bool *<parameter>commit</parameter></paramdef> 1807*8e33eff8Schristos <paramdef>unsigned <parameter>arena_ind</parameter></paramdef> 1808*8e33eff8Schristos </funcprototype></funcsynopsis> 1809*8e33eff8Schristos <literallayout></literallayout> 1810*8e33eff8Schristos <para>An extent allocation function conforms to the 1811*8e33eff8Schristos <type>extent_alloc_t</type> type and upon success returns a pointer to 1812*8e33eff8Schristos <parameter>size</parameter> bytes of mapped memory on behalf of arena 1813*8e33eff8Schristos <parameter>arena_ind</parameter> such that the extent's base address is 1814*8e33eff8Schristos a multiple of <parameter>alignment</parameter>, as well as setting 1815*8e33eff8Schristos <parameter>*zero</parameter> to indicate whether the extent is zeroed 1816*8e33eff8Schristos and <parameter>*commit</parameter> to indicate whether the extent is 1817*8e33eff8Schristos committed. Upon error the function returns <constant>NULL</constant> 1818*8e33eff8Schristos and leaves <parameter>*zero</parameter> and 1819*8e33eff8Schristos <parameter>*commit</parameter> unmodified. The 1820*8e33eff8Schristos <parameter>size</parameter> parameter is always a multiple of the page 1821*8e33eff8Schristos size. The <parameter>alignment</parameter> parameter is always a power 1822*8e33eff8Schristos of two at least as large as the page size. Zeroing is mandatory if 1823*8e33eff8Schristos <parameter>*zero</parameter> is true upon function entry. Committing is 1824*8e33eff8Schristos mandatory if <parameter>*commit</parameter> is true upon function entry. 1825*8e33eff8Schristos If <parameter>new_addr</parameter> is not <constant>NULL</constant>, the 1826*8e33eff8Schristos returned pointer must be <parameter>new_addr</parameter> on success or 1827*8e33eff8Schristos <constant>NULL</constant> on error. Committed memory may be committed 1828*8e33eff8Schristos in absolute terms as on a system that does not overcommit, or in 1829*8e33eff8Schristos implicit terms as on a system that overcommits and satisfies physical 1830*8e33eff8Schristos memory needs on demand via soft page faults. Note that replacing the 1831*8e33eff8Schristos default extent allocation function makes the arena's <link 1832*8e33eff8Schristos linkend="arena.i.dss"><mallctl>arena.<i>.dss</mallctl></link> 1833*8e33eff8Schristos setting irrelevant.</para> 1834*8e33eff8Schristos 1835*8e33eff8Schristos <funcsynopsis><funcprototype> 1836*8e33eff8Schristos <funcdef>typedef bool <function>(extent_dalloc_t)</function></funcdef> 1837*8e33eff8Schristos <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef> 1838*8e33eff8Schristos <paramdef>void *<parameter>addr</parameter></paramdef> 1839*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 1840*8e33eff8Schristos <paramdef>bool <parameter>committed</parameter></paramdef> 1841*8e33eff8Schristos <paramdef>unsigned <parameter>arena_ind</parameter></paramdef> 1842*8e33eff8Schristos </funcprototype></funcsynopsis> 1843*8e33eff8Schristos <literallayout></literallayout> 1844*8e33eff8Schristos <para> 1845*8e33eff8Schristos An extent deallocation function conforms to the 1846*8e33eff8Schristos <type>extent_dalloc_t</type> type and deallocates an extent at given 1847*8e33eff8Schristos <parameter>addr</parameter> and <parameter>size</parameter> with 1848*8e33eff8Schristos <parameter>committed</parameter>/decommited memory as indicated, on 1849*8e33eff8Schristos behalf of arena <parameter>arena_ind</parameter>, returning false upon 1850*8e33eff8Schristos success. If the function returns true, this indicates opt-out from 1851*8e33eff8Schristos deallocation; the virtual memory mapping associated with the extent 1852*8e33eff8Schristos remains mapped, in the same commit state, and available for future use, 1853*8e33eff8Schristos in which case it will be automatically retained for later reuse.</para> 1854*8e33eff8Schristos 1855*8e33eff8Schristos <funcsynopsis><funcprototype> 1856*8e33eff8Schristos <funcdef>typedef void <function>(extent_destroy_t)</function></funcdef> 1857*8e33eff8Schristos <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef> 1858*8e33eff8Schristos <paramdef>void *<parameter>addr</parameter></paramdef> 1859*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 1860*8e33eff8Schristos <paramdef>bool <parameter>committed</parameter></paramdef> 1861*8e33eff8Schristos <paramdef>unsigned <parameter>arena_ind</parameter></paramdef> 1862*8e33eff8Schristos </funcprototype></funcsynopsis> 1863*8e33eff8Schristos <literallayout></literallayout> 1864*8e33eff8Schristos <para> 1865*8e33eff8Schristos An extent destruction function conforms to the 1866*8e33eff8Schristos <type>extent_destroy_t</type> type and unconditionally destroys an 1867*8e33eff8Schristos extent at given <parameter>addr</parameter> and 1868*8e33eff8Schristos <parameter>size</parameter> with 1869*8e33eff8Schristos <parameter>committed</parameter>/decommited memory as indicated, on 1870*8e33eff8Schristos behalf of arena <parameter>arena_ind</parameter>. This function may be 1871*8e33eff8Schristos called to destroy retained extents during arena destruction (see <link 1872*8e33eff8Schristos linkend="arena.i.destroy"><mallctl>arena.<i>.destroy</mallctl></link>).</para> 1873*8e33eff8Schristos 1874*8e33eff8Schristos <funcsynopsis><funcprototype> 1875*8e33eff8Schristos <funcdef>typedef bool <function>(extent_commit_t)</function></funcdef> 1876*8e33eff8Schristos <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef> 1877*8e33eff8Schristos <paramdef>void *<parameter>addr</parameter></paramdef> 1878*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 1879*8e33eff8Schristos <paramdef>size_t <parameter>offset</parameter></paramdef> 1880*8e33eff8Schristos <paramdef>size_t <parameter>length</parameter></paramdef> 1881*8e33eff8Schristos <paramdef>unsigned <parameter>arena_ind</parameter></paramdef> 1882*8e33eff8Schristos </funcprototype></funcsynopsis> 1883*8e33eff8Schristos <literallayout></literallayout> 1884*8e33eff8Schristos <para>An extent commit function conforms to the 1885*8e33eff8Schristos <type>extent_commit_t</type> type and commits zeroed physical memory to 1886*8e33eff8Schristos back pages within an extent at given <parameter>addr</parameter> and 1887*8e33eff8Schristos <parameter>size</parameter> at <parameter>offset</parameter> bytes, 1888*8e33eff8Schristos extending for <parameter>length</parameter> on behalf of arena 1889*8e33eff8Schristos <parameter>arena_ind</parameter>, returning false upon success. 1890*8e33eff8Schristos Committed memory may be committed in absolute terms as on a system that 1891*8e33eff8Schristos does not overcommit, or in implicit terms as on a system that 1892*8e33eff8Schristos overcommits and satisfies physical memory needs on demand via soft page 1893*8e33eff8Schristos faults. If the function returns true, this indicates insufficient 1894*8e33eff8Schristos physical memory to satisfy the request.</para> 1895*8e33eff8Schristos 1896*8e33eff8Schristos <funcsynopsis><funcprototype> 1897*8e33eff8Schristos <funcdef>typedef bool <function>(extent_decommit_t)</function></funcdef> 1898*8e33eff8Schristos <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef> 1899*8e33eff8Schristos <paramdef>void *<parameter>addr</parameter></paramdef> 1900*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 1901*8e33eff8Schristos <paramdef>size_t <parameter>offset</parameter></paramdef> 1902*8e33eff8Schristos <paramdef>size_t <parameter>length</parameter></paramdef> 1903*8e33eff8Schristos <paramdef>unsigned <parameter>arena_ind</parameter></paramdef> 1904*8e33eff8Schristos </funcprototype></funcsynopsis> 1905*8e33eff8Schristos <literallayout></literallayout> 1906*8e33eff8Schristos <para>An extent decommit function conforms to the 1907*8e33eff8Schristos <type>extent_decommit_t</type> type and decommits any physical memory 1908*8e33eff8Schristos that is backing pages within an extent at given 1909*8e33eff8Schristos <parameter>addr</parameter> and <parameter>size</parameter> at 1910*8e33eff8Schristos <parameter>offset</parameter> bytes, extending for 1911*8e33eff8Schristos <parameter>length</parameter> on behalf of arena 1912*8e33eff8Schristos <parameter>arena_ind</parameter>, returning false upon success, in which 1913*8e33eff8Schristos case the pages will be committed via the extent commit function before 1914*8e33eff8Schristos being reused. If the function returns true, this indicates opt-out from 1915*8e33eff8Schristos decommit; the memory remains committed and available for future use, in 1916*8e33eff8Schristos which case it will be automatically retained for later reuse.</para> 1917*8e33eff8Schristos 1918*8e33eff8Schristos <funcsynopsis><funcprototype> 1919*8e33eff8Schristos <funcdef>typedef bool <function>(extent_purge_t)</function></funcdef> 1920*8e33eff8Schristos <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef> 1921*8e33eff8Schristos <paramdef>void *<parameter>addr</parameter></paramdef> 1922*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 1923*8e33eff8Schristos <paramdef>size_t <parameter>offset</parameter></paramdef> 1924*8e33eff8Schristos <paramdef>size_t <parameter>length</parameter></paramdef> 1925*8e33eff8Schristos <paramdef>unsigned <parameter>arena_ind</parameter></paramdef> 1926*8e33eff8Schristos </funcprototype></funcsynopsis> 1927*8e33eff8Schristos <literallayout></literallayout> 1928*8e33eff8Schristos <para>An extent purge function conforms to the 1929*8e33eff8Schristos <type>extent_purge_t</type> type and discards physical pages 1930*8e33eff8Schristos within the virtual memory mapping associated with an extent at given 1931*8e33eff8Schristos <parameter>addr</parameter> and <parameter>size</parameter> at 1932*8e33eff8Schristos <parameter>offset</parameter> bytes, extending for 1933*8e33eff8Schristos <parameter>length</parameter> on behalf of arena 1934*8e33eff8Schristos <parameter>arena_ind</parameter>. A lazy extent purge function (e.g. 1935*8e33eff8Schristos implemented via 1936*8e33eff8Schristos <function>madvise(<parameter>...</parameter><parameter><constant>MADV_FREE</constant></parameter>)</function>) 1937*8e33eff8Schristos can delay purging indefinitely and leave the pages within the purged 1938*8e33eff8Schristos virtual memory range in an indeterminite state, whereas a forced extent 1939*8e33eff8Schristos purge function immediately purges, and the pages within the virtual 1940*8e33eff8Schristos memory range will be zero-filled the next time they are accessed. If 1941*8e33eff8Schristos the function returns true, this indicates failure to purge.</para> 1942*8e33eff8Schristos 1943*8e33eff8Schristos <funcsynopsis><funcprototype> 1944*8e33eff8Schristos <funcdef>typedef bool <function>(extent_split_t)</function></funcdef> 1945*8e33eff8Schristos <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef> 1946*8e33eff8Schristos <paramdef>void *<parameter>addr</parameter></paramdef> 1947*8e33eff8Schristos <paramdef>size_t <parameter>size</parameter></paramdef> 1948*8e33eff8Schristos <paramdef>size_t <parameter>size_a</parameter></paramdef> 1949*8e33eff8Schristos <paramdef>size_t <parameter>size_b</parameter></paramdef> 1950*8e33eff8Schristos <paramdef>bool <parameter>committed</parameter></paramdef> 1951*8e33eff8Schristos <paramdef>unsigned <parameter>arena_ind</parameter></paramdef> 1952*8e33eff8Schristos </funcprototype></funcsynopsis> 1953*8e33eff8Schristos <literallayout></literallayout> 1954*8e33eff8Schristos <para>An extent split function conforms to the 1955*8e33eff8Schristos <type>extent_split_t</type> type and optionally splits an extent at 1956*8e33eff8Schristos given <parameter>addr</parameter> and <parameter>size</parameter> into 1957*8e33eff8Schristos two adjacent extents, the first of <parameter>size_a</parameter> bytes, 1958*8e33eff8Schristos and the second of <parameter>size_b</parameter> bytes, operating on 1959*8e33eff8Schristos <parameter>committed</parameter>/decommitted memory as indicated, on 1960*8e33eff8Schristos behalf of arena <parameter>arena_ind</parameter>, returning false upon 1961*8e33eff8Schristos success. If the function returns true, this indicates that the extent 1962*8e33eff8Schristos remains unsplit and therefore should continue to be operated on as a 1963*8e33eff8Schristos whole.</para> 1964*8e33eff8Schristos 1965*8e33eff8Schristos <funcsynopsis><funcprototype> 1966*8e33eff8Schristos <funcdef>typedef bool <function>(extent_merge_t)</function></funcdef> 1967*8e33eff8Schristos <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef> 1968*8e33eff8Schristos <paramdef>void *<parameter>addr_a</parameter></paramdef> 1969*8e33eff8Schristos <paramdef>size_t <parameter>size_a</parameter></paramdef> 1970*8e33eff8Schristos <paramdef>void *<parameter>addr_b</parameter></paramdef> 1971*8e33eff8Schristos <paramdef>size_t <parameter>size_b</parameter></paramdef> 1972*8e33eff8Schristos <paramdef>bool <parameter>committed</parameter></paramdef> 1973*8e33eff8Schristos <paramdef>unsigned <parameter>arena_ind</parameter></paramdef> 1974*8e33eff8Schristos </funcprototype></funcsynopsis> 1975*8e33eff8Schristos <literallayout></literallayout> 1976*8e33eff8Schristos <para>An extent merge function conforms to the 1977*8e33eff8Schristos <type>extent_merge_t</type> type and optionally merges adjacent extents, 1978*8e33eff8Schristos at given <parameter>addr_a</parameter> and <parameter>size_a</parameter> 1979*8e33eff8Schristos with given <parameter>addr_b</parameter> and 1980*8e33eff8Schristos <parameter>size_b</parameter> into one contiguous extent, operating on 1981*8e33eff8Schristos <parameter>committed</parameter>/decommitted memory as indicated, on 1982*8e33eff8Schristos behalf of arena <parameter>arena_ind</parameter>, returning false upon 1983*8e33eff8Schristos success. If the function returns true, this indicates that the extents 1984*8e33eff8Schristos remain distinct mappings and therefore should continue to be operated on 1985*8e33eff8Schristos independently.</para> 1986*8e33eff8Schristos </listitem> 1987*8e33eff8Schristos </varlistentry> 1988*8e33eff8Schristos 1989*8e33eff8Schristos <varlistentry id="arenas.narenas"> 1990*8e33eff8Schristos <term> 1991*8e33eff8Schristos <mallctl>arenas.narenas</mallctl> 1992*8e33eff8Schristos (<type>unsigned</type>) 1993*8e33eff8Schristos <literal>r-</literal> 1994*8e33eff8Schristos </term> 1995*8e33eff8Schristos <listitem><para>Current limit on number of arenas.</para></listitem> 1996*8e33eff8Schristos </varlistentry> 1997*8e33eff8Schristos 1998*8e33eff8Schristos <varlistentry id="arenas.dirty_decay_ms"> 1999*8e33eff8Schristos <term> 2000*8e33eff8Schristos <mallctl>arenas.dirty_decay_ms</mallctl> 2001*8e33eff8Schristos (<type>ssize_t</type>) 2002*8e33eff8Schristos <literal>rw</literal> 2003*8e33eff8Schristos </term> 2004*8e33eff8Schristos <listitem><para>Current default per-arena approximate time in 2005*8e33eff8Schristos milliseconds from the creation of a set of unused dirty pages until an 2006*8e33eff8Schristos equivalent set of unused dirty pages is purged and/or reused, used to 2007*8e33eff8Schristos initialize <link 2008*8e33eff8Schristos linkend="arena.i.dirty_decay_ms"><mallctl>arena.<i>.dirty_decay_ms</mallctl></link> 2009*8e33eff8Schristos during arena creation. See <link 2010*8e33eff8Schristos linkend="opt.dirty_decay_ms"><mallctl>opt.dirty_decay_ms</mallctl></link> 2011*8e33eff8Schristos for additional information.</para></listitem> 2012*8e33eff8Schristos </varlistentry> 2013*8e33eff8Schristos 2014*8e33eff8Schristos <varlistentry id="arenas.muzzy_decay_ms"> 2015*8e33eff8Schristos <term> 2016*8e33eff8Schristos <mallctl>arenas.muzzy_decay_ms</mallctl> 2017*8e33eff8Schristos (<type>ssize_t</type>) 2018*8e33eff8Schristos <literal>rw</literal> 2019*8e33eff8Schristos </term> 2020*8e33eff8Schristos <listitem><para>Current default per-arena approximate time in 2021*8e33eff8Schristos milliseconds from the creation of a set of unused muzzy pages until an 2022*8e33eff8Schristos equivalent set of unused muzzy pages is purged and/or reused, used to 2023*8e33eff8Schristos initialize <link 2024*8e33eff8Schristos linkend="arena.i.muzzy_decay_ms"><mallctl>arena.<i>.muzzy_decay_ms</mallctl></link> 2025*8e33eff8Schristos during arena creation. See <link 2026*8e33eff8Schristos linkend="opt.muzzy_decay_ms"><mallctl>opt.muzzy_decay_ms</mallctl></link> 2027*8e33eff8Schristos for additional information.</para></listitem> 2028*8e33eff8Schristos </varlistentry> 2029*8e33eff8Schristos 2030*8e33eff8Schristos <varlistentry id="arenas.quantum"> 2031*8e33eff8Schristos <term> 2032*8e33eff8Schristos <mallctl>arenas.quantum</mallctl> 2033*8e33eff8Schristos (<type>size_t</type>) 2034*8e33eff8Schristos <literal>r-</literal> 2035*8e33eff8Schristos </term> 2036*8e33eff8Schristos <listitem><para>Quantum size.</para></listitem> 2037*8e33eff8Schristos </varlistentry> 2038*8e33eff8Schristos 2039*8e33eff8Schristos <varlistentry id="arenas.page"> 2040*8e33eff8Schristos <term> 2041*8e33eff8Schristos <mallctl>arenas.page</mallctl> 2042*8e33eff8Schristos (<type>size_t</type>) 2043*8e33eff8Schristos <literal>r-</literal> 2044*8e33eff8Schristos </term> 2045*8e33eff8Schristos <listitem><para>Page size.</para></listitem> 2046*8e33eff8Schristos </varlistentry> 2047*8e33eff8Schristos 2048*8e33eff8Schristos <varlistentry id="arenas.tcache_max"> 2049*8e33eff8Schristos <term> 2050*8e33eff8Schristos <mallctl>arenas.tcache_max</mallctl> 2051*8e33eff8Schristos (<type>size_t</type>) 2052*8e33eff8Schristos <literal>r-</literal> 2053*8e33eff8Schristos </term> 2054*8e33eff8Schristos <listitem><para>Maximum thread-cached size class.</para></listitem> 2055*8e33eff8Schristos </varlistentry> 2056*8e33eff8Schristos 2057*8e33eff8Schristos <varlistentry id="arenas.nbins"> 2058*8e33eff8Schristos <term> 2059*8e33eff8Schristos <mallctl>arenas.nbins</mallctl> 2060*8e33eff8Schristos (<type>unsigned</type>) 2061*8e33eff8Schristos <literal>r-</literal> 2062*8e33eff8Schristos </term> 2063*8e33eff8Schristos <listitem><para>Number of bin size classes.</para></listitem> 2064*8e33eff8Schristos </varlistentry> 2065*8e33eff8Schristos 2066*8e33eff8Schristos <varlistentry id="arenas.nhbins"> 2067*8e33eff8Schristos <term> 2068*8e33eff8Schristos <mallctl>arenas.nhbins</mallctl> 2069*8e33eff8Schristos (<type>unsigned</type>) 2070*8e33eff8Schristos <literal>r-</literal> 2071*8e33eff8Schristos </term> 2072*8e33eff8Schristos <listitem><para>Total number of thread cache bin size 2073*8e33eff8Schristos classes.</para></listitem> 2074*8e33eff8Schristos </varlistentry> 2075*8e33eff8Schristos 2076*8e33eff8Schristos <varlistentry id="arenas.bin.i.size"> 2077*8e33eff8Schristos <term> 2078*8e33eff8Schristos <mallctl>arenas.bin.<i>.size</mallctl> 2079*8e33eff8Schristos (<type>size_t</type>) 2080*8e33eff8Schristos <literal>r-</literal> 2081*8e33eff8Schristos </term> 2082*8e33eff8Schristos <listitem><para>Maximum size supported by size class.</para></listitem> 2083*8e33eff8Schristos </varlistentry> 2084*8e33eff8Schristos 2085*8e33eff8Schristos <varlistentry id="arenas.bin.i.nregs"> 2086*8e33eff8Schristos <term> 2087*8e33eff8Schristos <mallctl>arenas.bin.<i>.nregs</mallctl> 2088*8e33eff8Schristos (<type>uint32_t</type>) 2089*8e33eff8Schristos <literal>r-</literal> 2090*8e33eff8Schristos </term> 2091*8e33eff8Schristos <listitem><para>Number of regions per slab.</para></listitem> 2092*8e33eff8Schristos </varlistentry> 2093*8e33eff8Schristos 2094*8e33eff8Schristos <varlistentry id="arenas.bin.i.slab_size"> 2095*8e33eff8Schristos <term> 2096*8e33eff8Schristos <mallctl>arenas.bin.<i>.slab_size</mallctl> 2097*8e33eff8Schristos (<type>size_t</type>) 2098*8e33eff8Schristos <literal>r-</literal> 2099*8e33eff8Schristos </term> 2100*8e33eff8Schristos <listitem><para>Number of bytes per slab.</para></listitem> 2101*8e33eff8Schristos </varlistentry> 2102*8e33eff8Schristos 2103*8e33eff8Schristos <varlistentry id="arenas.nlextents"> 2104*8e33eff8Schristos <term> 2105*8e33eff8Schristos <mallctl>arenas.nlextents</mallctl> 2106*8e33eff8Schristos (<type>unsigned</type>) 2107*8e33eff8Schristos <literal>r-</literal> 2108*8e33eff8Schristos </term> 2109*8e33eff8Schristos <listitem><para>Total number of large size classes.</para></listitem> 2110*8e33eff8Schristos </varlistentry> 2111*8e33eff8Schristos 2112*8e33eff8Schristos <varlistentry id="arenas.lextent.i.size"> 2113*8e33eff8Schristos <term> 2114*8e33eff8Schristos <mallctl>arenas.lextent.<i>.size</mallctl> 2115*8e33eff8Schristos (<type>size_t</type>) 2116*8e33eff8Schristos <literal>r-</literal> 2117*8e33eff8Schristos </term> 2118*8e33eff8Schristos <listitem><para>Maximum size supported by this large size 2119*8e33eff8Schristos class.</para></listitem> 2120*8e33eff8Schristos </varlistentry> 2121*8e33eff8Schristos 2122*8e33eff8Schristos <varlistentry id="arenas.create"> 2123*8e33eff8Schristos <term> 2124*8e33eff8Schristos <mallctl>arenas.create</mallctl> 2125*8e33eff8Schristos (<type>unsigned</type>, <type>extent_hooks_t *</type>) 2126*8e33eff8Schristos <literal>rw</literal> 2127*8e33eff8Schristos </term> 2128*8e33eff8Schristos <listitem><para>Explicitly create a new arena outside the range of 2129*8e33eff8Schristos automatically managed arenas, with optionally specified extent hooks, 2130*8e33eff8Schristos and return the new arena index.</para></listitem> 2131*8e33eff8Schristos </varlistentry> 2132*8e33eff8Schristos 2133*8e33eff8Schristos <varlistentry id="arenas.lookup"> 2134*8e33eff8Schristos <term> 2135*8e33eff8Schristos <mallctl>arenas.lookup</mallctl> 2136*8e33eff8Schristos (<type>unsigned</type>, <type>void*</type>) 2137*8e33eff8Schristos <literal>rw</literal> 2138*8e33eff8Schristos </term> 2139*8e33eff8Schristos <listitem><para>Index of the arena to which an allocation belongs to.</para></listitem> 2140*8e33eff8Schristos </varlistentry> 2141*8e33eff8Schristos 2142*8e33eff8Schristos <varlistentry id="prof.thread_active_init"> 2143*8e33eff8Schristos <term> 2144*8e33eff8Schristos <mallctl>prof.thread_active_init</mallctl> 2145*8e33eff8Schristos (<type>bool</type>) 2146*8e33eff8Schristos <literal>rw</literal> 2147*8e33eff8Schristos [<option>--enable-prof</option>] 2148*8e33eff8Schristos </term> 2149*8e33eff8Schristos <listitem><para>Control the initial setting for <link 2150*8e33eff8Schristos linkend="thread.prof.active"><mallctl>thread.prof.active</mallctl></link> 2151*8e33eff8Schristos in newly created threads. See the <link 2152*8e33eff8Schristos linkend="opt.prof_thread_active_init"><mallctl>opt.prof_thread_active_init</mallctl></link> 2153*8e33eff8Schristos option for additional information.</para></listitem> 2154*8e33eff8Schristos </varlistentry> 2155*8e33eff8Schristos 2156*8e33eff8Schristos <varlistentry id="prof.active"> 2157*8e33eff8Schristos <term> 2158*8e33eff8Schristos <mallctl>prof.active</mallctl> 2159*8e33eff8Schristos (<type>bool</type>) 2160*8e33eff8Schristos <literal>rw</literal> 2161*8e33eff8Schristos [<option>--enable-prof</option>] 2162*8e33eff8Schristos </term> 2163*8e33eff8Schristos <listitem><para>Control whether sampling is currently active. See the 2164*8e33eff8Schristos <link 2165*8e33eff8Schristos linkend="opt.prof_active"><mallctl>opt.prof_active</mallctl></link> 2166*8e33eff8Schristos option for additional information, as well as the interrelated <link 2167*8e33eff8Schristos linkend="thread.prof.active"><mallctl>thread.prof.active</mallctl></link> 2168*8e33eff8Schristos mallctl.</para></listitem> 2169*8e33eff8Schristos </varlistentry> 2170*8e33eff8Schristos 2171*8e33eff8Schristos <varlistentry id="prof.dump"> 2172*8e33eff8Schristos <term> 2173*8e33eff8Schristos <mallctl>prof.dump</mallctl> 2174*8e33eff8Schristos (<type>const char *</type>) 2175*8e33eff8Schristos <literal>-w</literal> 2176*8e33eff8Schristos [<option>--enable-prof</option>] 2177*8e33eff8Schristos </term> 2178*8e33eff8Schristos <listitem><para>Dump a memory profile to the specified file, or if NULL 2179*8e33eff8Schristos is specified, to a file according to the pattern 2180*8e33eff8Schristos <filename><prefix>.<pid>.<seq>.m<mseq>.heap</filename>, 2181*8e33eff8Schristos where <literal><prefix></literal> is controlled by the 2182*8e33eff8Schristos <link 2183*8e33eff8Schristos linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> 2184*8e33eff8Schristos option.</para></listitem> 2185*8e33eff8Schristos </varlistentry> 2186*8e33eff8Schristos 2187*8e33eff8Schristos <varlistentry id="prof.gdump"> 2188*8e33eff8Schristos <term> 2189*8e33eff8Schristos <mallctl>prof.gdump</mallctl> 2190*8e33eff8Schristos (<type>bool</type>) 2191*8e33eff8Schristos <literal>rw</literal> 2192*8e33eff8Schristos [<option>--enable-prof</option>] 2193*8e33eff8Schristos </term> 2194*8e33eff8Schristos <listitem><para>When enabled, trigger a memory profile dump every time 2195*8e33eff8Schristos the total virtual memory exceeds the previous maximum. Profiles are 2196*8e33eff8Schristos dumped to files named according to the pattern 2197*8e33eff8Schristos <filename><prefix>.<pid>.<seq>.u<useq>.heap</filename>, 2198*8e33eff8Schristos where <literal><prefix></literal> is controlled by the <link 2199*8e33eff8Schristos linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> 2200*8e33eff8Schristos option.</para></listitem> 2201*8e33eff8Schristos </varlistentry> 2202*8e33eff8Schristos 2203*8e33eff8Schristos <varlistentry id="prof.reset"> 2204*8e33eff8Schristos <term> 2205*8e33eff8Schristos <mallctl>prof.reset</mallctl> 2206*8e33eff8Schristos (<type>size_t</type>) 2207*8e33eff8Schristos <literal>-w</literal> 2208*8e33eff8Schristos [<option>--enable-prof</option>] 2209*8e33eff8Schristos </term> 2210*8e33eff8Schristos <listitem><para>Reset all memory profile statistics, and optionally 2211*8e33eff8Schristos update the sample rate (see <link 2212*8e33eff8Schristos linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link> 2213*8e33eff8Schristos and <link 2214*8e33eff8Schristos linkend="prof.lg_sample"><mallctl>prof.lg_sample</mallctl></link>). 2215*8e33eff8Schristos </para></listitem> 2216*8e33eff8Schristos </varlistentry> 2217*8e33eff8Schristos 2218*8e33eff8Schristos <varlistentry id="prof.lg_sample"> 2219*8e33eff8Schristos <term> 2220*8e33eff8Schristos <mallctl>prof.lg_sample</mallctl> 2221*8e33eff8Schristos (<type>size_t</type>) 2222*8e33eff8Schristos <literal>r-</literal> 2223*8e33eff8Schristos [<option>--enable-prof</option>] 2224*8e33eff8Schristos </term> 2225*8e33eff8Schristos <listitem><para>Get the current sample rate (see <link 2226*8e33eff8Schristos linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link>). 2227*8e33eff8Schristos </para></listitem> 2228*8e33eff8Schristos </varlistentry> 2229*8e33eff8Schristos 2230*8e33eff8Schristos <varlistentry id="prof.interval"> 2231*8e33eff8Schristos <term> 2232*8e33eff8Schristos <mallctl>prof.interval</mallctl> 2233*8e33eff8Schristos (<type>uint64_t</type>) 2234*8e33eff8Schristos <literal>r-</literal> 2235*8e33eff8Schristos [<option>--enable-prof</option>] 2236*8e33eff8Schristos </term> 2237*8e33eff8Schristos <listitem><para>Average number of bytes allocated between 2238*8e33eff8Schristos interval-based profile dumps. See the 2239*8e33eff8Schristos <link 2240*8e33eff8Schristos linkend="opt.lg_prof_interval"><mallctl>opt.lg_prof_interval</mallctl></link> 2241*8e33eff8Schristos option for additional information.</para></listitem> 2242*8e33eff8Schristos </varlistentry> 2243*8e33eff8Schristos 2244*8e33eff8Schristos <varlistentry id="stats.allocated"> 2245*8e33eff8Schristos <term> 2246*8e33eff8Schristos <mallctl>stats.allocated</mallctl> 2247*8e33eff8Schristos (<type>size_t</type>) 2248*8e33eff8Schristos <literal>r-</literal> 2249*8e33eff8Schristos [<option>--enable-stats</option>] 2250*8e33eff8Schristos </term> 2251*8e33eff8Schristos <listitem><para>Total number of bytes allocated by the 2252*8e33eff8Schristos application.</para></listitem> 2253*8e33eff8Schristos </varlistentry> 2254*8e33eff8Schristos 2255*8e33eff8Schristos <varlistentry id="stats.active"> 2256*8e33eff8Schristos <term> 2257*8e33eff8Schristos <mallctl>stats.active</mallctl> 2258*8e33eff8Schristos (<type>size_t</type>) 2259*8e33eff8Schristos <literal>r-</literal> 2260*8e33eff8Schristos [<option>--enable-stats</option>] 2261*8e33eff8Schristos </term> 2262*8e33eff8Schristos <listitem><para>Total number of bytes in active pages allocated by the 2263*8e33eff8Schristos application. This is a multiple of the page size, and greater than or 2264*8e33eff8Schristos equal to <link 2265*8e33eff8Schristos linkend="stats.allocated"><mallctl>stats.allocated</mallctl></link>. 2266*8e33eff8Schristos This does not include <link linkend="stats.arenas.i.pdirty"> 2267*8e33eff8Schristos <mallctl>stats.arenas.<i>.pdirty</mallctl></link>, 2268*8e33eff8Schristos <link linkend="stats.arenas.i.pmuzzy"> 2269*8e33eff8Schristos <mallctl>stats.arenas.<i>.pmuzzy</mallctl></link>, nor pages 2270*8e33eff8Schristos entirely devoted to allocator metadata.</para></listitem> 2271*8e33eff8Schristos </varlistentry> 2272*8e33eff8Schristos 2273*8e33eff8Schristos <varlistentry id="stats.metadata"> 2274*8e33eff8Schristos <term> 2275*8e33eff8Schristos <mallctl>stats.metadata</mallctl> 2276*8e33eff8Schristos (<type>size_t</type>) 2277*8e33eff8Schristos <literal>r-</literal> 2278*8e33eff8Schristos [<option>--enable-stats</option>] 2279*8e33eff8Schristos </term> 2280*8e33eff8Schristos <listitem><para>Total number of bytes dedicated to metadata, which 2281*8e33eff8Schristos comprise base allocations used for bootstrap-sensitive allocator 2282*8e33eff8Schristos metadata structures (see <link 2283*8e33eff8Schristos linkend="stats.arenas.i.base"><mallctl>stats.arenas.<i>.base</mallctl></link>) 2284*8e33eff8Schristos and internal allocations (see <link 2285*8e33eff8Schristos linkend="stats.arenas.i.internal"><mallctl>stats.arenas.<i>.internal</mallctl></link>). 2286*8e33eff8Schristos Transparent huge page (enabled with <link 2287*8e33eff8Schristos linkend="opt.metadata_thp">opt.metadata_thp</link>) usage is not 2288*8e33eff8Schristos considered.</para></listitem> 2289*8e33eff8Schristos </varlistentry> 2290*8e33eff8Schristos 2291*8e33eff8Schristos <varlistentry id="stats.metadata_thp"> 2292*8e33eff8Schristos <term> 2293*8e33eff8Schristos <mallctl>stats.metadata_thp</mallctl> 2294*8e33eff8Schristos (<type>size_t</type>) 2295*8e33eff8Schristos <literal>r-</literal> 2296*8e33eff8Schristos [<option>--enable-stats</option>] 2297*8e33eff8Schristos </term> 2298*8e33eff8Schristos <listitem><para>Number of transparent huge pages (THP) used for 2299*8e33eff8Schristos metadata. See <link 2300*8e33eff8Schristos linkend="stats.metadata"><mallctl>stats.metadata</mallctl></link> and 2301*8e33eff8Schristos <link linkend="opt.metadata_thp">opt.metadata_thp</link>) for 2302*8e33eff8Schristos details.</para></listitem> 2303*8e33eff8Schristos </varlistentry> 2304*8e33eff8Schristos 2305*8e33eff8Schristos <varlistentry id="stats.resident"> 2306*8e33eff8Schristos <term> 2307*8e33eff8Schristos <mallctl>stats.resident</mallctl> 2308*8e33eff8Schristos (<type>size_t</type>) 2309*8e33eff8Schristos <literal>r-</literal> 2310*8e33eff8Schristos [<option>--enable-stats</option>] 2311*8e33eff8Schristos </term> 2312*8e33eff8Schristos <listitem><para>Maximum number of bytes in physically resident data 2313*8e33eff8Schristos pages mapped by the allocator, comprising all pages dedicated to 2314*8e33eff8Schristos allocator metadata, pages backing active allocations, and unused dirty 2315*8e33eff8Schristos pages. This is a maximum rather than precise because pages may not 2316*8e33eff8Schristos actually be physically resident if they correspond to demand-zeroed 2317*8e33eff8Schristos virtual memory that has not yet been touched. This is a multiple of the 2318*8e33eff8Schristos page size, and is larger than <link 2319*8e33eff8Schristos linkend="stats.active"><mallctl>stats.active</mallctl></link>.</para></listitem> 2320*8e33eff8Schristos </varlistentry> 2321*8e33eff8Schristos 2322*8e33eff8Schristos <varlistentry id="stats.mapped"> 2323*8e33eff8Schristos <term> 2324*8e33eff8Schristos <mallctl>stats.mapped</mallctl> 2325*8e33eff8Schristos (<type>size_t</type>) 2326*8e33eff8Schristos <literal>r-</literal> 2327*8e33eff8Schristos [<option>--enable-stats</option>] 2328*8e33eff8Schristos </term> 2329*8e33eff8Schristos <listitem><para>Total number of bytes in active extents mapped by the 2330*8e33eff8Schristos allocator. This is larger than <link 2331*8e33eff8Schristos linkend="stats.active"><mallctl>stats.active</mallctl></link>. This 2332*8e33eff8Schristos does not include inactive extents, even those that contain unused dirty 2333*8e33eff8Schristos pages, which means that there is no strict ordering between this and 2334*8e33eff8Schristos <link 2335*8e33eff8Schristos linkend="stats.resident"><mallctl>stats.resident</mallctl></link>.</para></listitem> 2336*8e33eff8Schristos </varlistentry> 2337*8e33eff8Schristos 2338*8e33eff8Schristos <varlistentry id="stats.retained"> 2339*8e33eff8Schristos <term> 2340*8e33eff8Schristos <mallctl>stats.retained</mallctl> 2341*8e33eff8Schristos (<type>size_t</type>) 2342*8e33eff8Schristos <literal>r-</literal> 2343*8e33eff8Schristos [<option>--enable-stats</option>] 2344*8e33eff8Schristos </term> 2345*8e33eff8Schristos <listitem><para>Total number of bytes in virtual memory mappings that 2346*8e33eff8Schristos were retained rather than being returned to the operating system via 2347*8e33eff8Schristos e.g. <citerefentry><refentrytitle>munmap</refentrytitle> 2348*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry> or similar. Retained virtual 2349*8e33eff8Schristos memory is typically untouched, decommitted, or purged, so it has no 2350*8e33eff8Schristos strongly associated physical memory (see <link 2351*8e33eff8Schristos linkend="arena.i.extent_hooks">extent hooks</link> for details). 2352*8e33eff8Schristos Retained memory is excluded from mapped memory statistics, e.g. <link 2353*8e33eff8Schristos linkend="stats.mapped"><mallctl>stats.mapped</mallctl></link>. 2354*8e33eff8Schristos </para></listitem> 2355*8e33eff8Schristos </varlistentry> 2356*8e33eff8Schristos 2357*8e33eff8Schristos <varlistentry id="stats.background_thread.num_threads"> 2358*8e33eff8Schristos <term> 2359*8e33eff8Schristos <mallctl>stats.background_thread.num_threads</mallctl> 2360*8e33eff8Schristos (<type>size_t</type>) 2361*8e33eff8Schristos <literal>r-</literal> 2362*8e33eff8Schristos [<option>--enable-stats</option>] 2363*8e33eff8Schristos </term> 2364*8e33eff8Schristos <listitem><para> Number of <link linkend="background_thread">background 2365*8e33eff8Schristos threads</link> running currently.</para></listitem> 2366*8e33eff8Schristos </varlistentry> 2367*8e33eff8Schristos 2368*8e33eff8Schristos <varlistentry id="stats.background_thread.num_runs"> 2369*8e33eff8Schristos <term> 2370*8e33eff8Schristos <mallctl>stats.background_thread.num_runs</mallctl> 2371*8e33eff8Schristos (<type>uint64_t</type>) 2372*8e33eff8Schristos <literal>r-</literal> 2373*8e33eff8Schristos [<option>--enable-stats</option>] 2374*8e33eff8Schristos </term> 2375*8e33eff8Schristos <listitem><para> Total number of runs from all <link 2376*8e33eff8Schristos linkend="background_thread">background threads</link>.</para></listitem> 2377*8e33eff8Schristos </varlistentry> 2378*8e33eff8Schristos 2379*8e33eff8Schristos <varlistentry id="stats.background_thread.run_interval"> 2380*8e33eff8Schristos <term> 2381*8e33eff8Schristos <mallctl>stats.background_thread.run_interval</mallctl> 2382*8e33eff8Schristos (<type>uint64_t</type>) 2383*8e33eff8Schristos <literal>r-</literal> 2384*8e33eff8Schristos [<option>--enable-stats</option>] 2385*8e33eff8Schristos </term> 2386*8e33eff8Schristos <listitem><para> Average run interval in nanoseconds of <link 2387*8e33eff8Schristos linkend="background_thread">background threads</link>.</para></listitem> 2388*8e33eff8Schristos </varlistentry> 2389*8e33eff8Schristos 2390*8e33eff8Schristos <varlistentry id="stats.mutexes.ctl"> 2391*8e33eff8Schristos <term> 2392*8e33eff8Schristos <mallctl>stats.mutexes.ctl.{counter};</mallctl> 2393*8e33eff8Schristos (<type>counter specific type</type>) 2394*8e33eff8Schristos <literal>r-</literal> 2395*8e33eff8Schristos [<option>--enable-stats</option>] 2396*8e33eff8Schristos </term> 2397*8e33eff8Schristos <listitem><para>Statistics on <varname>ctl</varname> mutex (global 2398*8e33eff8Schristos scope; mallctl related). <mallctl>{counter}</mallctl> is one of the 2399*8e33eff8Schristos counters below:</para> 2400*8e33eff8Schristos <varlistentry id="mutex_counters"> 2401*8e33eff8Schristos <listitem><para><varname>num_ops</varname> (<type>uint64_t</type>): 2402*8e33eff8Schristos Total number of lock acquisition operations on this mutex.</para> 2403*8e33eff8Schristos 2404*8e33eff8Schristos <para><varname>num_spin_acq</varname> (<type>uint64_t</type>): Number 2405*8e33eff8Schristos of times the mutex was spin-acquired. When the mutex is currently 2406*8e33eff8Schristos locked and cannot be acquired immediately, a short period of 2407*8e33eff8Schristos spin-retry within jemalloc will be performed. Acquired through spin 2408*8e33eff8Schristos generally means the contention was lightweight and not causing context 2409*8e33eff8Schristos switches.</para> 2410*8e33eff8Schristos 2411*8e33eff8Schristos <para><varname>num_wait</varname> (<type>uint64_t</type>): Number of 2412*8e33eff8Schristos times the mutex was wait-acquired, which means the mutex contention 2413*8e33eff8Schristos was not solved by spin-retry, and blocking operation was likely 2414*8e33eff8Schristos involved in order to acquire the mutex. This event generally implies 2415*8e33eff8Schristos higher cost / longer delay, and should be investigated if it happens 2416*8e33eff8Schristos often.</para> 2417*8e33eff8Schristos 2418*8e33eff8Schristos <para><varname>max_wait_time</varname> (<type>uint64_t</type>): 2419*8e33eff8Schristos Maximum length of time in nanoseconds spent on a single wait-acquired 2420*8e33eff8Schristos lock operation. Note that to avoid profiling overhead on the common 2421*8e33eff8Schristos path, this does not consider spin-acquired cases.</para> 2422*8e33eff8Schristos 2423*8e33eff8Schristos <para><varname>total_wait_time</varname> (<type>uint64_t</type>): 2424*8e33eff8Schristos Cumulative time in nanoseconds spent on wait-acquired lock operations. 2425*8e33eff8Schristos Similarly, spin-acquired cases are not considered.</para> 2426*8e33eff8Schristos 2427*8e33eff8Schristos <para><varname>max_num_thds</varname> (<type>uint32_t</type>): Maximum 2428*8e33eff8Schristos number of threads waiting on this mutex simultaneously. Similarly, 2429*8e33eff8Schristos spin-acquired cases are not considered.</para> 2430*8e33eff8Schristos 2431*8e33eff8Schristos <para><varname>num_owner_switch</varname> (<type>uint64_t</type>): 2432*8e33eff8Schristos Number of times the current mutex owner is different from the previous 2433*8e33eff8Schristos one. This event does not generally imply an issue; rather it is an 2434*8e33eff8Schristos indicator of how often the protected data are accessed by different 2435*8e33eff8Schristos threads. 2436*8e33eff8Schristos </para> 2437*8e33eff8Schristos </listitem> 2438*8e33eff8Schristos </varlistentry> 2439*8e33eff8Schristos </listitem> 2440*8e33eff8Schristos </varlistentry> 2441*8e33eff8Schristos 2442*8e33eff8Schristos <varlistentry id="stats.mutexes.background_thread"> 2443*8e33eff8Schristos <term> 2444*8e33eff8Schristos <mallctl>stats.mutexes.background_thread.{counter}</mallctl> 2445*8e33eff8Schristos (<type>counter specific type</type>) <literal>r-</literal> 2446*8e33eff8Schristos [<option>--enable-stats</option>] 2447*8e33eff8Schristos </term> 2448*8e33eff8Schristos <listitem><para>Statistics on <varname>background_thread</varname> mutex 2449*8e33eff8Schristos (global scope; <link 2450*8e33eff8Schristos linkend="background_thread"><mallctl>background_thread</mallctl></link> 2451*8e33eff8Schristos related). <mallctl>{counter}</mallctl> is one of the counters in <link 2452*8e33eff8Schristos linkend="mutex_counters">mutex profiling 2453*8e33eff8Schristos counters</link>.</para></listitem> 2454*8e33eff8Schristos </varlistentry> 2455*8e33eff8Schristos 2456*8e33eff8Schristos <varlistentry id="stats.mutexes.prof"> 2457*8e33eff8Schristos <term> 2458*8e33eff8Schristos <mallctl>stats.mutexes.prof.{counter}</mallctl> 2459*8e33eff8Schristos (<type>counter specific type</type>) <literal>r-</literal> 2460*8e33eff8Schristos [<option>--enable-stats</option>] 2461*8e33eff8Schristos </term> 2462*8e33eff8Schristos <listitem><para>Statistics on <varname>prof</varname> mutex (global 2463*8e33eff8Schristos scope; profiling related). <mallctl>{counter}</mallctl> is one of the 2464*8e33eff8Schristos counters in <link linkend="mutex_counters">mutex profiling 2465*8e33eff8Schristos counters</link>.</para></listitem> 2466*8e33eff8Schristos </varlistentry> 2467*8e33eff8Schristos 2468*8e33eff8Schristos <varlistentry id="stats.mutexes.reset"> 2469*8e33eff8Schristos <term> 2470*8e33eff8Schristos <mallctl>stats.mutexes.reset</mallctl> 2471*8e33eff8Schristos (<type>void</type>) <literal>--</literal> 2472*8e33eff8Schristos [<option>--enable-stats</option>] 2473*8e33eff8Schristos </term> 2474*8e33eff8Schristos <listitem><para>Reset all mutex profile statistics, including global 2475*8e33eff8Schristos mutexes, arena mutexes and bin mutexes.</para></listitem> 2476*8e33eff8Schristos </varlistentry> 2477*8e33eff8Schristos 2478*8e33eff8Schristos <varlistentry id="stats.arenas.i.dss"> 2479*8e33eff8Schristos <term> 2480*8e33eff8Schristos <mallctl>stats.arenas.<i>.dss</mallctl> 2481*8e33eff8Schristos (<type>const char *</type>) 2482*8e33eff8Schristos <literal>r-</literal> 2483*8e33eff8Schristos </term> 2484*8e33eff8Schristos <listitem><para>dss (<citerefentry><refentrytitle>sbrk</refentrytitle> 2485*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry>) allocation precedence as 2486*8e33eff8Schristos related to <citerefentry><refentrytitle>mmap</refentrytitle> 2487*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry> allocation. See <link 2488*8e33eff8Schristos linkend="opt.dss"><mallctl>opt.dss</mallctl></link> for details. 2489*8e33eff8Schristos </para></listitem> 2490*8e33eff8Schristos </varlistentry> 2491*8e33eff8Schristos 2492*8e33eff8Schristos <varlistentry id="stats.arenas.i.dirty_decay_ms"> 2493*8e33eff8Schristos <term> 2494*8e33eff8Schristos <mallctl>stats.arenas.<i>.dirty_decay_ms</mallctl> 2495*8e33eff8Schristos (<type>ssize_t</type>) 2496*8e33eff8Schristos <literal>r-</literal> 2497*8e33eff8Schristos </term> 2498*8e33eff8Schristos <listitem><para>Approximate time in milliseconds from the creation of a 2499*8e33eff8Schristos set of unused dirty pages until an equivalent set of unused dirty pages 2500*8e33eff8Schristos is purged and/or reused. See <link 2501*8e33eff8Schristos linkend="opt.dirty_decay_ms"><mallctl>opt.dirty_decay_ms</mallctl></link> 2502*8e33eff8Schristos for details.</para></listitem> 2503*8e33eff8Schristos </varlistentry> 2504*8e33eff8Schristos 2505*8e33eff8Schristos <varlistentry id="stats.arenas.i.muzzy_decay_ms"> 2506*8e33eff8Schristos <term> 2507*8e33eff8Schristos <mallctl>stats.arenas.<i>.muzzy_decay_ms</mallctl> 2508*8e33eff8Schristos (<type>ssize_t</type>) 2509*8e33eff8Schristos <literal>r-</literal> 2510*8e33eff8Schristos </term> 2511*8e33eff8Schristos <listitem><para>Approximate time in milliseconds from the creation of a 2512*8e33eff8Schristos set of unused muzzy pages until an equivalent set of unused muzzy pages 2513*8e33eff8Schristos is purged and/or reused. See <link 2514*8e33eff8Schristos linkend="opt.muzzy_decay_ms"><mallctl>opt.muzzy_decay_ms</mallctl></link> 2515*8e33eff8Schristos for details.</para></listitem> 2516*8e33eff8Schristos </varlistentry> 2517*8e33eff8Schristos 2518*8e33eff8Schristos <varlistentry id="stats.arenas.i.nthreads"> 2519*8e33eff8Schristos <term> 2520*8e33eff8Schristos <mallctl>stats.arenas.<i>.nthreads</mallctl> 2521*8e33eff8Schristos (<type>unsigned</type>) 2522*8e33eff8Schristos <literal>r-</literal> 2523*8e33eff8Schristos </term> 2524*8e33eff8Schristos <listitem><para>Number of threads currently assigned to 2525*8e33eff8Schristos arena.</para></listitem> 2526*8e33eff8Schristos </varlistentry> 2527*8e33eff8Schristos 2528*8e33eff8Schristos <varlistentry id="stats.arenas.i.uptime"> 2529*8e33eff8Schristos <term> 2530*8e33eff8Schristos <mallctl>stats.arenas.<i>.uptime</mallctl> 2531*8e33eff8Schristos (<type>uint64_t</type>) 2532*8e33eff8Schristos <literal>r-</literal> 2533*8e33eff8Schristos </term> 2534*8e33eff8Schristos <listitem><para>Time elapsed (in nanoseconds) since the arena was 2535*8e33eff8Schristos created. If <i> equals <constant>0</constant> or 2536*8e33eff8Schristos <constant>MALLCTL_ARENAS_ALL</constant>, this is the uptime since malloc 2537*8e33eff8Schristos initialization.</para></listitem> 2538*8e33eff8Schristos </varlistentry> 2539*8e33eff8Schristos 2540*8e33eff8Schristos <varlistentry id="stats.arenas.i.pactive"> 2541*8e33eff8Schristos <term> 2542*8e33eff8Schristos <mallctl>stats.arenas.<i>.pactive</mallctl> 2543*8e33eff8Schristos (<type>size_t</type>) 2544*8e33eff8Schristos <literal>r-</literal> 2545*8e33eff8Schristos </term> 2546*8e33eff8Schristos <listitem><para>Number of pages in active extents.</para></listitem> 2547*8e33eff8Schristos </varlistentry> 2548*8e33eff8Schristos 2549*8e33eff8Schristos <varlistentry id="stats.arenas.i.pdirty"> 2550*8e33eff8Schristos <term> 2551*8e33eff8Schristos <mallctl>stats.arenas.<i>.pdirty</mallctl> 2552*8e33eff8Schristos (<type>size_t</type>) 2553*8e33eff8Schristos <literal>r-</literal> 2554*8e33eff8Schristos </term> 2555*8e33eff8Schristos <listitem><para>Number of pages within unused extents that are 2556*8e33eff8Schristos potentially dirty, and for which <function>madvise()</function> or 2557*8e33eff8Schristos similar has not been called. See <link 2558*8e33eff8Schristos linkend="opt.dirty_decay_ms"><mallctl>opt.dirty_decay_ms</mallctl></link> 2559*8e33eff8Schristos for a description of dirty pages.</para></listitem> 2560*8e33eff8Schristos </varlistentry> 2561*8e33eff8Schristos 2562*8e33eff8Schristos <varlistentry id="stats.arenas.i.pmuzzy"> 2563*8e33eff8Schristos <term> 2564*8e33eff8Schristos <mallctl>stats.arenas.<i>.pmuzzy</mallctl> 2565*8e33eff8Schristos (<type>size_t</type>) 2566*8e33eff8Schristos <literal>r-</literal> 2567*8e33eff8Schristos </term> 2568*8e33eff8Schristos <listitem><para>Number of pages within unused extents that are muzzy. 2569*8e33eff8Schristos See <link 2570*8e33eff8Schristos linkend="opt.muzzy_decay_ms"><mallctl>opt.muzzy_decay_ms</mallctl></link> 2571*8e33eff8Schristos for a description of muzzy pages.</para></listitem> 2572*8e33eff8Schristos </varlistentry> 2573*8e33eff8Schristos 2574*8e33eff8Schristos <varlistentry id="stats.arenas.i.mapped"> 2575*8e33eff8Schristos <term> 2576*8e33eff8Schristos <mallctl>stats.arenas.<i>.mapped</mallctl> 2577*8e33eff8Schristos (<type>size_t</type>) 2578*8e33eff8Schristos <literal>r-</literal> 2579*8e33eff8Schristos [<option>--enable-stats</option>] 2580*8e33eff8Schristos </term> 2581*8e33eff8Schristos <listitem><para>Number of mapped bytes.</para></listitem> 2582*8e33eff8Schristos </varlistentry> 2583*8e33eff8Schristos 2584*8e33eff8Schristos <varlistentry id="stats.arenas.i.retained"> 2585*8e33eff8Schristos <term> 2586*8e33eff8Schristos <mallctl>stats.arenas.<i>.retained</mallctl> 2587*8e33eff8Schristos (<type>size_t</type>) 2588*8e33eff8Schristos <literal>r-</literal> 2589*8e33eff8Schristos [<option>--enable-stats</option>] 2590*8e33eff8Schristos </term> 2591*8e33eff8Schristos <listitem><para>Number of retained bytes. See <link 2592*8e33eff8Schristos linkend="stats.retained"><mallctl>stats.retained</mallctl></link> for 2593*8e33eff8Schristos details.</para></listitem> 2594*8e33eff8Schristos </varlistentry> 2595*8e33eff8Schristos 2596*8e33eff8Schristos <varlistentry id="stats.arenas.i.base"> 2597*8e33eff8Schristos <term> 2598*8e33eff8Schristos <mallctl>stats.arenas.<i>.base</mallctl> 2599*8e33eff8Schristos (<type>size_t</type>) 2600*8e33eff8Schristos <literal>r-</literal> 2601*8e33eff8Schristos [<option>--enable-stats</option>] 2602*8e33eff8Schristos </term> 2603*8e33eff8Schristos <listitem><para> 2604*8e33eff8Schristos Number of bytes dedicated to bootstrap-sensitive allocator metadata 2605*8e33eff8Schristos structures.</para></listitem> 2606*8e33eff8Schristos </varlistentry> 2607*8e33eff8Schristos 2608*8e33eff8Schristos <varlistentry id="stats.arenas.i.internal"> 2609*8e33eff8Schristos <term> 2610*8e33eff8Schristos <mallctl>stats.arenas.<i>.internal</mallctl> 2611*8e33eff8Schristos (<type>size_t</type>) 2612*8e33eff8Schristos <literal>r-</literal> 2613*8e33eff8Schristos [<option>--enable-stats</option>] 2614*8e33eff8Schristos </term> 2615*8e33eff8Schristos <listitem><para>Number of bytes dedicated to internal allocations. 2616*8e33eff8Schristos Internal allocations differ from application-originated allocations in 2617*8e33eff8Schristos that they are for internal use, and that they are omitted from heap 2618*8e33eff8Schristos profiles.</para></listitem> 2619*8e33eff8Schristos </varlistentry> 2620*8e33eff8Schristos 2621*8e33eff8Schristos <varlistentry id="stats.arenas.i.metadata_thp"> 2622*8e33eff8Schristos <term> 2623*8e33eff8Schristos <mallctl>stats.arenas.<i>.metadata_thp</mallctl> 2624*8e33eff8Schristos (<type>size_t</type>) 2625*8e33eff8Schristos <literal>r-</literal> 2626*8e33eff8Schristos [<option>--enable-stats</option>] 2627*8e33eff8Schristos </term> 2628*8e33eff8Schristos <listitem><para>Number of transparent huge pages (THP) used for 2629*8e33eff8Schristos metadata. See <link linkend="opt.metadata_thp">opt.metadata_thp</link> 2630*8e33eff8Schristos for details.</para></listitem> 2631*8e33eff8Schristos </varlistentry> 2632*8e33eff8Schristos 2633*8e33eff8Schristos <varlistentry id="stats.arenas.i.resident"> 2634*8e33eff8Schristos <term> 2635*8e33eff8Schristos <mallctl>stats.arenas.<i>.resident</mallctl> 2636*8e33eff8Schristos (<type>size_t</type>) 2637*8e33eff8Schristos <literal>r-</literal> 2638*8e33eff8Schristos [<option>--enable-stats</option>] 2639*8e33eff8Schristos </term> 2640*8e33eff8Schristos <listitem><para>Maximum number of bytes in physically resident data 2641*8e33eff8Schristos pages mapped by the arena, comprising all pages dedicated to allocator 2642*8e33eff8Schristos metadata, pages backing active allocations, and unused dirty pages. 2643*8e33eff8Schristos This is a maximum rather than precise because pages may not actually be 2644*8e33eff8Schristos physically resident if they correspond to demand-zeroed virtual memory 2645*8e33eff8Schristos that has not yet been touched. This is a multiple of the page 2646*8e33eff8Schristos size.</para></listitem> 2647*8e33eff8Schristos </varlistentry> 2648*8e33eff8Schristos 2649*8e33eff8Schristos <varlistentry id="stats.arenas.i.dirty_npurge"> 2650*8e33eff8Schristos <term> 2651*8e33eff8Schristos <mallctl>stats.arenas.<i>.dirty_npurge</mallctl> 2652*8e33eff8Schristos (<type>uint64_t</type>) 2653*8e33eff8Schristos <literal>r-</literal> 2654*8e33eff8Schristos [<option>--enable-stats</option>] 2655*8e33eff8Schristos </term> 2656*8e33eff8Schristos <listitem><para>Number of dirty page purge sweeps performed. 2657*8e33eff8Schristos </para></listitem> 2658*8e33eff8Schristos </varlistentry> 2659*8e33eff8Schristos 2660*8e33eff8Schristos <varlistentry id="stats.arenas.i.dirty_nmadvise"> 2661*8e33eff8Schristos <term> 2662*8e33eff8Schristos <mallctl>stats.arenas.<i>.dirty_nmadvise</mallctl> 2663*8e33eff8Schristos (<type>uint64_t</type>) 2664*8e33eff8Schristos <literal>r-</literal> 2665*8e33eff8Schristos [<option>--enable-stats</option>] 2666*8e33eff8Schristos </term> 2667*8e33eff8Schristos <listitem><para>Number of <function>madvise()</function> or similar 2668*8e33eff8Schristos calls made to purge dirty pages.</para></listitem> 2669*8e33eff8Schristos </varlistentry> 2670*8e33eff8Schristos 2671*8e33eff8Schristos <varlistentry id="stats.arenas.i.dirty_purged"> 2672*8e33eff8Schristos <term> 2673*8e33eff8Schristos <mallctl>stats.arenas.<i>.dirty_purged</mallctl> 2674*8e33eff8Schristos (<type>uint64_t</type>) 2675*8e33eff8Schristos <literal>r-</literal> 2676*8e33eff8Schristos [<option>--enable-stats</option>] 2677*8e33eff8Schristos </term> 2678*8e33eff8Schristos <listitem><para>Number of dirty pages purged.</para></listitem> 2679*8e33eff8Schristos </varlistentry> 2680*8e33eff8Schristos 2681*8e33eff8Schristos <varlistentry id="stats.arenas.i.muzzy_npurge"> 2682*8e33eff8Schristos <term> 2683*8e33eff8Schristos <mallctl>stats.arenas.<i>.muzzy_npurge</mallctl> 2684*8e33eff8Schristos (<type>uint64_t</type>) 2685*8e33eff8Schristos <literal>r-</literal> 2686*8e33eff8Schristos [<option>--enable-stats</option>] 2687*8e33eff8Schristos </term> 2688*8e33eff8Schristos <listitem><para>Number of muzzy page purge sweeps performed. 2689*8e33eff8Schristos </para></listitem> 2690*8e33eff8Schristos </varlistentry> 2691*8e33eff8Schristos 2692*8e33eff8Schristos <varlistentry id="stats.arenas.i.muzzy_nmadvise"> 2693*8e33eff8Schristos <term> 2694*8e33eff8Schristos <mallctl>stats.arenas.<i>.muzzy_nmadvise</mallctl> 2695*8e33eff8Schristos (<type>uint64_t</type>) 2696*8e33eff8Schristos <literal>r-</literal> 2697*8e33eff8Schristos [<option>--enable-stats</option>] 2698*8e33eff8Schristos </term> 2699*8e33eff8Schristos <listitem><para>Number of <function>madvise()</function> or similar 2700*8e33eff8Schristos calls made to purge muzzy pages.</para></listitem> 2701*8e33eff8Schristos </varlistentry> 2702*8e33eff8Schristos 2703*8e33eff8Schristos <varlistentry id="stats.arenas.i.muzzy_purged"> 2704*8e33eff8Schristos <term> 2705*8e33eff8Schristos <mallctl>stats.arenas.<i>.muzzy_purged</mallctl> 2706*8e33eff8Schristos (<type>uint64_t</type>) 2707*8e33eff8Schristos <literal>r-</literal> 2708*8e33eff8Schristos [<option>--enable-stats</option>] 2709*8e33eff8Schristos </term> 2710*8e33eff8Schristos <listitem><para>Number of muzzy pages purged.</para></listitem> 2711*8e33eff8Schristos </varlistentry> 2712*8e33eff8Schristos 2713*8e33eff8Schristos <varlistentry id="stats.arenas.i.small.allocated"> 2714*8e33eff8Schristos <term> 2715*8e33eff8Schristos <mallctl>stats.arenas.<i>.small.allocated</mallctl> 2716*8e33eff8Schristos (<type>size_t</type>) 2717*8e33eff8Schristos <literal>r-</literal> 2718*8e33eff8Schristos [<option>--enable-stats</option>] 2719*8e33eff8Schristos </term> 2720*8e33eff8Schristos <listitem><para>Number of bytes currently allocated by small objects. 2721*8e33eff8Schristos </para></listitem> 2722*8e33eff8Schristos </varlistentry> 2723*8e33eff8Schristos 2724*8e33eff8Schristos <varlistentry id="stats.arenas.i.small.nmalloc"> 2725*8e33eff8Schristos <term> 2726*8e33eff8Schristos <mallctl>stats.arenas.<i>.small.nmalloc</mallctl> 2727*8e33eff8Schristos (<type>uint64_t</type>) 2728*8e33eff8Schristos <literal>r-</literal> 2729*8e33eff8Schristos [<option>--enable-stats</option>] 2730*8e33eff8Schristos </term> 2731*8e33eff8Schristos <listitem><para>Cumulative number of times a small allocation was 2732*8e33eff8Schristos requested from the arena's bins, whether to fill the relevant tcache if 2733*8e33eff8Schristos <link linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is 2734*8e33eff8Schristos enabled, or to directly satisfy an allocation request 2735*8e33eff8Schristos otherwise.</para></listitem> 2736*8e33eff8Schristos </varlistentry> 2737*8e33eff8Schristos 2738*8e33eff8Schristos <varlistentry id="stats.arenas.i.small.ndalloc"> 2739*8e33eff8Schristos <term> 2740*8e33eff8Schristos <mallctl>stats.arenas.<i>.small.ndalloc</mallctl> 2741*8e33eff8Schristos (<type>uint64_t</type>) 2742*8e33eff8Schristos <literal>r-</literal> 2743*8e33eff8Schristos [<option>--enable-stats</option>] 2744*8e33eff8Schristos </term> 2745*8e33eff8Schristos <listitem><para>Cumulative number of times a small allocation was 2746*8e33eff8Schristos returned to the arena's bins, whether to flush the relevant tcache if 2747*8e33eff8Schristos <link linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is 2748*8e33eff8Schristos enabled, or to directly deallocate an allocation 2749*8e33eff8Schristos otherwise.</para></listitem> 2750*8e33eff8Schristos </varlistentry> 2751*8e33eff8Schristos 2752*8e33eff8Schristos <varlistentry id="stats.arenas.i.small.nrequests"> 2753*8e33eff8Schristos <term> 2754*8e33eff8Schristos <mallctl>stats.arenas.<i>.small.nrequests</mallctl> 2755*8e33eff8Schristos (<type>uint64_t</type>) 2756*8e33eff8Schristos <literal>r-</literal> 2757*8e33eff8Schristos [<option>--enable-stats</option>] 2758*8e33eff8Schristos </term> 2759*8e33eff8Schristos <listitem><para>Cumulative number of allocation requests satisfied by 2760*8e33eff8Schristos all bin size classes.</para></listitem> 2761*8e33eff8Schristos </varlistentry> 2762*8e33eff8Schristos 2763*8e33eff8Schristos <varlistentry id="stats.arenas.i.large.allocated"> 2764*8e33eff8Schristos <term> 2765*8e33eff8Schristos <mallctl>stats.arenas.<i>.large.allocated</mallctl> 2766*8e33eff8Schristos (<type>size_t</type>) 2767*8e33eff8Schristos <literal>r-</literal> 2768*8e33eff8Schristos [<option>--enable-stats</option>] 2769*8e33eff8Schristos </term> 2770*8e33eff8Schristos <listitem><para>Number of bytes currently allocated by large objects. 2771*8e33eff8Schristos </para></listitem> 2772*8e33eff8Schristos </varlistentry> 2773*8e33eff8Schristos 2774*8e33eff8Schristos <varlistentry id="stats.arenas.i.large.nmalloc"> 2775*8e33eff8Schristos <term> 2776*8e33eff8Schristos <mallctl>stats.arenas.<i>.large.nmalloc</mallctl> 2777*8e33eff8Schristos (<type>uint64_t</type>) 2778*8e33eff8Schristos <literal>r-</literal> 2779*8e33eff8Schristos [<option>--enable-stats</option>] 2780*8e33eff8Schristos </term> 2781*8e33eff8Schristos <listitem><para>Cumulative number of times a large extent was allocated 2782*8e33eff8Schristos from the arena, whether to fill the relevant tcache if <link 2783*8e33eff8Schristos linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is enabled and 2784*8e33eff8Schristos the size class is within the range being cached, or to directly satisfy 2785*8e33eff8Schristos an allocation request otherwise.</para></listitem> 2786*8e33eff8Schristos </varlistentry> 2787*8e33eff8Schristos 2788*8e33eff8Schristos <varlistentry id="stats.arenas.i.large.ndalloc"> 2789*8e33eff8Schristos <term> 2790*8e33eff8Schristos <mallctl>stats.arenas.<i>.large.ndalloc</mallctl> 2791*8e33eff8Schristos (<type>uint64_t</type>) 2792*8e33eff8Schristos <literal>r-</literal> 2793*8e33eff8Schristos [<option>--enable-stats</option>] 2794*8e33eff8Schristos </term> 2795*8e33eff8Schristos <listitem><para>Cumulative number of times a large extent was returned 2796*8e33eff8Schristos to the arena, whether to flush the relevant tcache if <link 2797*8e33eff8Schristos linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is enabled and 2798*8e33eff8Schristos the size class is within the range being cached, or to directly 2799*8e33eff8Schristos deallocate an allocation otherwise.</para></listitem> 2800*8e33eff8Schristos </varlistentry> 2801*8e33eff8Schristos 2802*8e33eff8Schristos <varlistentry id="stats.arenas.i.large.nrequests"> 2803*8e33eff8Schristos <term> 2804*8e33eff8Schristos <mallctl>stats.arenas.<i>.large.nrequests</mallctl> 2805*8e33eff8Schristos (<type>uint64_t</type>) 2806*8e33eff8Schristos <literal>r-</literal> 2807*8e33eff8Schristos [<option>--enable-stats</option>] 2808*8e33eff8Schristos </term> 2809*8e33eff8Schristos <listitem><para>Cumulative number of allocation requests satisfied by 2810*8e33eff8Schristos all large size classes.</para></listitem> 2811*8e33eff8Schristos </varlistentry> 2812*8e33eff8Schristos 2813*8e33eff8Schristos <varlistentry id="stats.arenas.i.bins.j.nmalloc"> 2814*8e33eff8Schristos <term> 2815*8e33eff8Schristos <mallctl>stats.arenas.<i>.bins.<j>.nmalloc</mallctl> 2816*8e33eff8Schristos (<type>uint64_t</type>) 2817*8e33eff8Schristos <literal>r-</literal> 2818*8e33eff8Schristos [<option>--enable-stats</option>] 2819*8e33eff8Schristos </term> 2820*8e33eff8Schristos <listitem><para>Cumulative number of times a bin region of the 2821*8e33eff8Schristos corresponding size class was allocated from the arena, whether to fill 2822*8e33eff8Schristos the relevant tcache if <link 2823*8e33eff8Schristos linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is enabled, or 2824*8e33eff8Schristos to directly satisfy an allocation request otherwise.</para></listitem> 2825*8e33eff8Schristos </varlistentry> 2826*8e33eff8Schristos 2827*8e33eff8Schristos <varlistentry id="stats.arenas.i.bins.j.ndalloc"> 2828*8e33eff8Schristos <term> 2829*8e33eff8Schristos <mallctl>stats.arenas.<i>.bins.<j>.ndalloc</mallctl> 2830*8e33eff8Schristos (<type>uint64_t</type>) 2831*8e33eff8Schristos <literal>r-</literal> 2832*8e33eff8Schristos [<option>--enable-stats</option>] 2833*8e33eff8Schristos </term> 2834*8e33eff8Schristos <listitem><para>Cumulative number of times a bin region of the 2835*8e33eff8Schristos corresponding size class was returned to the arena, whether to flush the 2836*8e33eff8Schristos relevant tcache if <link 2837*8e33eff8Schristos linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is enabled, or 2838*8e33eff8Schristos to directly deallocate an allocation otherwise.</para></listitem> 2839*8e33eff8Schristos </varlistentry> 2840*8e33eff8Schristos 2841*8e33eff8Schristos <varlistentry id="stats.arenas.i.bins.j.nrequests"> 2842*8e33eff8Schristos <term> 2843*8e33eff8Schristos <mallctl>stats.arenas.<i>.bins.<j>.nrequests</mallctl> 2844*8e33eff8Schristos (<type>uint64_t</type>) 2845*8e33eff8Schristos <literal>r-</literal> 2846*8e33eff8Schristos [<option>--enable-stats</option>] 2847*8e33eff8Schristos </term> 2848*8e33eff8Schristos <listitem><para>Cumulative number of allocation requests satisfied by 2849*8e33eff8Schristos bin regions of the corresponding size class.</para></listitem> 2850*8e33eff8Schristos </varlistentry> 2851*8e33eff8Schristos 2852*8e33eff8Schristos <varlistentry id="stats.arenas.i.bins.j.curregs"> 2853*8e33eff8Schristos <term> 2854*8e33eff8Schristos <mallctl>stats.arenas.<i>.bins.<j>.curregs</mallctl> 2855*8e33eff8Schristos (<type>size_t</type>) 2856*8e33eff8Schristos <literal>r-</literal> 2857*8e33eff8Schristos [<option>--enable-stats</option>] 2858*8e33eff8Schristos </term> 2859*8e33eff8Schristos <listitem><para>Current number of regions for this size 2860*8e33eff8Schristos class.</para></listitem> 2861*8e33eff8Schristos </varlistentry> 2862*8e33eff8Schristos 2863*8e33eff8Schristos <varlistentry id="stats.arenas.i.bins.j.nfills"> 2864*8e33eff8Schristos <term> 2865*8e33eff8Schristos <mallctl>stats.arenas.<i>.bins.<j>.nfills</mallctl> 2866*8e33eff8Schristos (<type>uint64_t</type>) 2867*8e33eff8Schristos <literal>r-</literal> 2868*8e33eff8Schristos </term> 2869*8e33eff8Schristos <listitem><para>Cumulative number of tcache fills.</para></listitem> 2870*8e33eff8Schristos </varlistentry> 2871*8e33eff8Schristos 2872*8e33eff8Schristos <varlistentry id="stats.arenas.i.bins.j.nflushes"> 2873*8e33eff8Schristos <term> 2874*8e33eff8Schristos <mallctl>stats.arenas.<i>.bins.<j>.nflushes</mallctl> 2875*8e33eff8Schristos (<type>uint64_t</type>) 2876*8e33eff8Schristos <literal>r-</literal> 2877*8e33eff8Schristos </term> 2878*8e33eff8Schristos <listitem><para>Cumulative number of tcache flushes.</para></listitem> 2879*8e33eff8Schristos </varlistentry> 2880*8e33eff8Schristos 2881*8e33eff8Schristos <varlistentry id="stats.arenas.i.bins.j.nslabs"> 2882*8e33eff8Schristos <term> 2883*8e33eff8Schristos <mallctl>stats.arenas.<i>.bins.<j>.nslabs</mallctl> 2884*8e33eff8Schristos (<type>uint64_t</type>) 2885*8e33eff8Schristos <literal>r-</literal> 2886*8e33eff8Schristos [<option>--enable-stats</option>] 2887*8e33eff8Schristos </term> 2888*8e33eff8Schristos <listitem><para>Cumulative number of slabs created.</para></listitem> 2889*8e33eff8Schristos </varlistentry> 2890*8e33eff8Schristos 2891*8e33eff8Schristos <varlistentry id="stats.arenas.i.bins.j.nreslabs"> 2892*8e33eff8Schristos <term> 2893*8e33eff8Schristos <mallctl>stats.arenas.<i>.bins.<j>.nreslabs</mallctl> 2894*8e33eff8Schristos (<type>uint64_t</type>) 2895*8e33eff8Schristos <literal>r-</literal> 2896*8e33eff8Schristos [<option>--enable-stats</option>] 2897*8e33eff8Schristos </term> 2898*8e33eff8Schristos <listitem><para>Cumulative number of times the current slab from which 2899*8e33eff8Schristos to allocate changed.</para></listitem> 2900*8e33eff8Schristos </varlistentry> 2901*8e33eff8Schristos 2902*8e33eff8Schristos <varlistentry id="stats.arenas.i.bins.j.curslabs"> 2903*8e33eff8Schristos <term> 2904*8e33eff8Schristos <mallctl>stats.arenas.<i>.bins.<j>.curslabs</mallctl> 2905*8e33eff8Schristos (<type>size_t</type>) 2906*8e33eff8Schristos <literal>r-</literal> 2907*8e33eff8Schristos [<option>--enable-stats</option>] 2908*8e33eff8Schristos </term> 2909*8e33eff8Schristos <listitem><para>Current number of slabs.</para></listitem> 2910*8e33eff8Schristos </varlistentry> 2911*8e33eff8Schristos 2912*8e33eff8Schristos <varlistentry id="stats.arenas.i.bins.mutex"> 2913*8e33eff8Schristos <term> 2914*8e33eff8Schristos <mallctl>stats.arenas.<i>.bins.<j>.mutex.{counter}</mallctl> 2915*8e33eff8Schristos (<type>counter specific type</type>) <literal>r-</literal> 2916*8e33eff8Schristos [<option>--enable-stats</option>] 2917*8e33eff8Schristos </term> 2918*8e33eff8Schristos <listitem><para>Statistics on 2919*8e33eff8Schristos <varname>arena.<i>.bins.<j></varname> mutex (arena bin 2920*8e33eff8Schristos scope; bin operation related). <mallctl>{counter}</mallctl> is one of 2921*8e33eff8Schristos the counters in <link linkend="mutex_counters">mutex profiling 2922*8e33eff8Schristos counters</link>.</para></listitem> 2923*8e33eff8Schristos </varlistentry> 2924*8e33eff8Schristos 2925*8e33eff8Schristos <varlistentry id="stats.arenas.i.lextents.j.nmalloc"> 2926*8e33eff8Schristos <term> 2927*8e33eff8Schristos <mallctl>stats.arenas.<i>.lextents.<j>.nmalloc</mallctl> 2928*8e33eff8Schristos (<type>uint64_t</type>) 2929*8e33eff8Schristos <literal>r-</literal> 2930*8e33eff8Schristos [<option>--enable-stats</option>] 2931*8e33eff8Schristos </term> 2932*8e33eff8Schristos <listitem><para>Cumulative number of times a large extent of the 2933*8e33eff8Schristos corresponding size class was allocated from the arena, whether to fill 2934*8e33eff8Schristos the relevant tcache if <link 2935*8e33eff8Schristos linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is enabled and 2936*8e33eff8Schristos the size class is within the range being cached, or to directly satisfy 2937*8e33eff8Schristos an allocation request otherwise.</para></listitem> 2938*8e33eff8Schristos </varlistentry> 2939*8e33eff8Schristos 2940*8e33eff8Schristos <varlistentry id="stats.arenas.i.lextents.j.ndalloc"> 2941*8e33eff8Schristos <term> 2942*8e33eff8Schristos <mallctl>stats.arenas.<i>.lextents.<j>.ndalloc</mallctl> 2943*8e33eff8Schristos (<type>uint64_t</type>) 2944*8e33eff8Schristos <literal>r-</literal> 2945*8e33eff8Schristos [<option>--enable-stats</option>] 2946*8e33eff8Schristos </term> 2947*8e33eff8Schristos <listitem><para>Cumulative number of times a large extent of the 2948*8e33eff8Schristos corresponding size class was returned to the arena, whether to flush the 2949*8e33eff8Schristos relevant tcache if <link 2950*8e33eff8Schristos linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is enabled and 2951*8e33eff8Schristos the size class is within the range being cached, or to directly 2952*8e33eff8Schristos deallocate an allocation otherwise.</para></listitem> 2953*8e33eff8Schristos </varlistentry> 2954*8e33eff8Schristos 2955*8e33eff8Schristos <varlistentry id="stats.arenas.i.lextents.j.nrequests"> 2956*8e33eff8Schristos <term> 2957*8e33eff8Schristos <mallctl>stats.arenas.<i>.lextents.<j>.nrequests</mallctl> 2958*8e33eff8Schristos (<type>uint64_t</type>) 2959*8e33eff8Schristos <literal>r-</literal> 2960*8e33eff8Schristos [<option>--enable-stats</option>] 2961*8e33eff8Schristos </term> 2962*8e33eff8Schristos <listitem><para>Cumulative number of allocation requests satisfied by 2963*8e33eff8Schristos large extents of the corresponding size class.</para></listitem> 2964*8e33eff8Schristos </varlistentry> 2965*8e33eff8Schristos 2966*8e33eff8Schristos <varlistentry id="stats.arenas.i.lextents.j.curlextents"> 2967*8e33eff8Schristos <term> 2968*8e33eff8Schristos <mallctl>stats.arenas.<i>.lextents.<j>.curlextents</mallctl> 2969*8e33eff8Schristos (<type>size_t</type>) 2970*8e33eff8Schristos <literal>r-</literal> 2971*8e33eff8Schristos [<option>--enable-stats</option>] 2972*8e33eff8Schristos </term> 2973*8e33eff8Schristos <listitem><para>Current number of large allocations for this size class. 2974*8e33eff8Schristos </para></listitem> 2975*8e33eff8Schristos </varlistentry> 2976*8e33eff8Schristos 2977*8e33eff8Schristos <varlistentry id="stats.arenas.i.mutexes.large"> 2978*8e33eff8Schristos <term> 2979*8e33eff8Schristos <mallctl>stats.arenas.<i>.mutexes.large.{counter}</mallctl> 2980*8e33eff8Schristos (<type>counter specific type</type>) <literal>r-</literal> 2981*8e33eff8Schristos [<option>--enable-stats</option>] 2982*8e33eff8Schristos </term> 2983*8e33eff8Schristos <listitem><para>Statistics on <varname>arena.<i>.large</varname> 2984*8e33eff8Schristos mutex (arena scope; large allocation related). 2985*8e33eff8Schristos <mallctl>{counter}</mallctl> is one of the counters in <link 2986*8e33eff8Schristos linkend="mutex_counters">mutex profiling 2987*8e33eff8Schristos counters</link>.</para></listitem> 2988*8e33eff8Schristos </varlistentry> 2989*8e33eff8Schristos 2990*8e33eff8Schristos <varlistentry id="stats.arenas.i.mutexes.extent_avail"> 2991*8e33eff8Schristos <term> 2992*8e33eff8Schristos <mallctl>stats.arenas.<i>.mutexes.extent_avail.{counter}</mallctl> 2993*8e33eff8Schristos (<type>counter specific type</type>) <literal>r-</literal> 2994*8e33eff8Schristos [<option>--enable-stats</option>] 2995*8e33eff8Schristos </term> 2996*8e33eff8Schristos <listitem><para>Statistics on <varname>arena.<i>.extent_avail 2997*8e33eff8Schristos </varname> mutex (arena scope; extent avail related). 2998*8e33eff8Schristos <mallctl>{counter}</mallctl> is one of the counters in <link 2999*8e33eff8Schristos linkend="mutex_counters">mutex profiling 3000*8e33eff8Schristos counters</link>.</para></listitem> 3001*8e33eff8Schristos </varlistentry> 3002*8e33eff8Schristos 3003*8e33eff8Schristos <varlistentry id="stats.arenas.i.mutexes.extents_dirty"> 3004*8e33eff8Schristos <term> 3005*8e33eff8Schristos <mallctl>stats.arenas.<i>.mutexes.extents_dirty.{counter}</mallctl> 3006*8e33eff8Schristos (<type>counter specific type</type>) <literal>r-</literal> 3007*8e33eff8Schristos [<option>--enable-stats</option>] 3008*8e33eff8Schristos </term> 3009*8e33eff8Schristos <listitem><para>Statistics on <varname>arena.<i>.extents_dirty 3010*8e33eff8Schristos </varname> mutex (arena scope; dirty extents related). 3011*8e33eff8Schristos <mallctl>{counter}</mallctl> is one of the counters in <link 3012*8e33eff8Schristos linkend="mutex_counters">mutex profiling 3013*8e33eff8Schristos counters</link>.</para></listitem> 3014*8e33eff8Schristos </varlistentry> 3015*8e33eff8Schristos 3016*8e33eff8Schristos <varlistentry id="stats.arenas.i.mutexes.extents_muzzy"> 3017*8e33eff8Schristos <term> 3018*8e33eff8Schristos <mallctl>stats.arenas.<i>.mutexes.extents_muzzy.{counter}</mallctl> 3019*8e33eff8Schristos (<type>counter specific type</type>) <literal>r-</literal> 3020*8e33eff8Schristos [<option>--enable-stats</option>] 3021*8e33eff8Schristos </term> 3022*8e33eff8Schristos <listitem><para>Statistics on <varname>arena.<i>.extents_muzzy 3023*8e33eff8Schristos </varname> mutex (arena scope; muzzy extents related). 3024*8e33eff8Schristos <mallctl>{counter}</mallctl> is one of the counters in <link 3025*8e33eff8Schristos linkend="mutex_counters">mutex profiling 3026*8e33eff8Schristos counters</link>.</para></listitem> 3027*8e33eff8Schristos </varlistentry> 3028*8e33eff8Schristos 3029*8e33eff8Schristos <varlistentry id="stats.arenas.i.mutexes.extents_retained"> 3030*8e33eff8Schristos <term> 3031*8e33eff8Schristos <mallctl>stats.arenas.<i>.mutexes.extents_retained.{counter}</mallctl> 3032*8e33eff8Schristos (<type>counter specific type</type>) <literal>r-</literal> 3033*8e33eff8Schristos [<option>--enable-stats</option>] 3034*8e33eff8Schristos </term> 3035*8e33eff8Schristos <listitem><para>Statistics on <varname>arena.<i>.extents_retained 3036*8e33eff8Schristos </varname> mutex (arena scope; retained extents related). 3037*8e33eff8Schristos <mallctl>{counter}</mallctl> is one of the counters in <link 3038*8e33eff8Schristos linkend="mutex_counters">mutex profiling 3039*8e33eff8Schristos counters</link>.</para></listitem> 3040*8e33eff8Schristos </varlistentry> 3041*8e33eff8Schristos 3042*8e33eff8Schristos <varlistentry id="stats.arenas.i.mutexes.decay_dirty"> 3043*8e33eff8Schristos <term> 3044*8e33eff8Schristos <mallctl>stats.arenas.<i>.mutexes.decay_dirty.{counter}</mallctl> 3045*8e33eff8Schristos (<type>counter specific type</type>) <literal>r-</literal> 3046*8e33eff8Schristos [<option>--enable-stats</option>] 3047*8e33eff8Schristos </term> 3048*8e33eff8Schristos <listitem><para>Statistics on <varname>arena.<i>.decay_dirty 3049*8e33eff8Schristos </varname> mutex (arena scope; decay for dirty pages related). 3050*8e33eff8Schristos <mallctl>{counter}</mallctl> is one of the counters in <link 3051*8e33eff8Schristos linkend="mutex_counters">mutex profiling 3052*8e33eff8Schristos counters</link>.</para></listitem> 3053*8e33eff8Schristos </varlistentry> 3054*8e33eff8Schristos 3055*8e33eff8Schristos <varlistentry id="stats.arenas.i.mutexes.decay_muzzy"> 3056*8e33eff8Schristos <term> 3057*8e33eff8Schristos <mallctl>stats.arenas.<i>.mutexes.decay_muzzy.{counter}</mallctl> 3058*8e33eff8Schristos (<type>counter specific type</type>) <literal>r-</literal> 3059*8e33eff8Schristos [<option>--enable-stats</option>] 3060*8e33eff8Schristos </term> 3061*8e33eff8Schristos <listitem><para>Statistics on <varname>arena.<i>.decay_muzzy 3062*8e33eff8Schristos </varname> mutex (arena scope; decay for muzzy pages related). 3063*8e33eff8Schristos <mallctl>{counter}</mallctl> is one of the counters in <link 3064*8e33eff8Schristos linkend="mutex_counters">mutex profiling 3065*8e33eff8Schristos counters</link>.</para></listitem> 3066*8e33eff8Schristos </varlistentry> 3067*8e33eff8Schristos 3068*8e33eff8Schristos <varlistentry id="stats.arenas.i.mutexes.base"> 3069*8e33eff8Schristos <term> 3070*8e33eff8Schristos <mallctl>stats.arenas.<i>.mutexes.base.{counter}</mallctl> 3071*8e33eff8Schristos (<type>counter specific type</type>) <literal>r-</literal> 3072*8e33eff8Schristos [<option>--enable-stats</option>] 3073*8e33eff8Schristos </term> 3074*8e33eff8Schristos <listitem><para>Statistics on <varname>arena.<i>.base</varname> 3075*8e33eff8Schristos mutex (arena scope; base allocator related). 3076*8e33eff8Schristos <mallctl>{counter}</mallctl> is one of the counters in <link 3077*8e33eff8Schristos linkend="mutex_counters">mutex profiling 3078*8e33eff8Schristos counters</link>.</para></listitem> 3079*8e33eff8Schristos </varlistentry> 3080*8e33eff8Schristos 3081*8e33eff8Schristos <varlistentry id="stats.arenas.i.mutexes.tcache_list"> 3082*8e33eff8Schristos <term> 3083*8e33eff8Schristos <mallctl>stats.arenas.<i>.mutexes.tcache_list.{counter}</mallctl> 3084*8e33eff8Schristos (<type>counter specific type</type>) <literal>r-</literal> 3085*8e33eff8Schristos [<option>--enable-stats</option>] 3086*8e33eff8Schristos </term> 3087*8e33eff8Schristos <listitem><para>Statistics on 3088*8e33eff8Schristos <varname>arena.<i>.tcache_list</varname> mutex (arena scope; 3089*8e33eff8Schristos tcache to arena association related). This mutex is expected to be 3090*8e33eff8Schristos accessed less often. <mallctl>{counter}</mallctl> is one of the 3091*8e33eff8Schristos counters in <link linkend="mutex_counters">mutex profiling 3092*8e33eff8Schristos counters</link>.</para></listitem> 3093*8e33eff8Schristos </varlistentry> 3094*8e33eff8Schristos 3095*8e33eff8Schristos </variablelist> 3096*8e33eff8Schristos </refsect1> 3097*8e33eff8Schristos <refsect1 id="heap_profile_format"> 3098*8e33eff8Schristos <title>HEAP PROFILE FORMAT</title> 3099*8e33eff8Schristos <para>Although the heap profiling functionality was originally designed to 3100*8e33eff8Schristos be compatible with the 3101*8e33eff8Schristos <command>pprof</command> command that is developed as part of the <ulink 3102*8e33eff8Schristos url="http://code.google.com/p/gperftools/">gperftools 3103*8e33eff8Schristos package</ulink>, the addition of per thread heap profiling functionality 3104*8e33eff8Schristos required a different heap profile format. The <command>jeprof</command> 3105*8e33eff8Schristos command is derived from <command>pprof</command>, with enhancements to 3106*8e33eff8Schristos support the heap profile format described here.</para> 3107*8e33eff8Schristos 3108*8e33eff8Schristos <para>In the following hypothetical heap profile, <constant>[...]</constant> 3109*8e33eff8Schristos indicates elision for the sake of compactness. <programlisting><![CDATA[ 3110*8e33eff8Schristosheap_v2/524288 3111*8e33eff8Schristos t*: 28106: 56637512 [0: 0] 3112*8e33eff8Schristos [...] 3113*8e33eff8Schristos t3: 352: 16777344 [0: 0] 3114*8e33eff8Schristos [...] 3115*8e33eff8Schristos t99: 17754: 29341640 [0: 0] 3116*8e33eff8Schristos [...] 3117*8e33eff8Schristos@ 0x5f86da8 0x5f5a1dc [...] 0x29e4d4e 0xa200316 0xabb2988 [...] 3118*8e33eff8Schristos t*: 13: 6688 [0: 0] 3119*8e33eff8Schristos t3: 12: 6496 [0: ] 3120*8e33eff8Schristos t99: 1: 192 [0: 0] 3121*8e33eff8Schristos[...] 3122*8e33eff8Schristos 3123*8e33eff8SchristosMAPPED_LIBRARIES: 3124*8e33eff8Schristos[...]]]></programlisting> The following matches the above heap profile, but most 3125*8e33eff8Schristostokens are replaced with <constant><description></constant> to indicate 3126*8e33eff8Schristosdescriptions of the corresponding fields. <programlisting><![CDATA[ 3127*8e33eff8Schristos<heap_profile_format_version>/<mean_sample_interval> 3128*8e33eff8Schristos <aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>] 3129*8e33eff8Schristos [...] 3130*8e33eff8Schristos <thread_3_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>] 3131*8e33eff8Schristos [...] 3132*8e33eff8Schristos <thread_99_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>] 3133*8e33eff8Schristos [...] 3134*8e33eff8Schristos@ <top_frame> <frame> [...] <frame> <frame> <frame> [...] 3135*8e33eff8Schristos <backtrace_aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>] 3136*8e33eff8Schristos <backtrace_thread_3>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>] 3137*8e33eff8Schristos <backtrace_thread_99>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>] 3138*8e33eff8Schristos[...] 3139*8e33eff8Schristos 3140*8e33eff8SchristosMAPPED_LIBRARIES: 3141*8e33eff8Schristos</proc/<pid>/maps>]]></programlisting></para> 3142*8e33eff8Schristos </refsect1> 3143*8e33eff8Schristos 3144*8e33eff8Schristos <refsect1 id="debugging_malloc_problems"> 3145*8e33eff8Schristos <title>DEBUGGING MALLOC PROBLEMS</title> 3146*8e33eff8Schristos <para>When debugging, it is a good idea to configure/build jemalloc with 3147*8e33eff8Schristos the <option>--enable-debug</option> and <option>--enable-fill</option> 3148*8e33eff8Schristos options, and recompile the program with suitable options and symbols for 3149*8e33eff8Schristos debugger support. When so configured, jemalloc incorporates a wide variety 3150*8e33eff8Schristos of run-time assertions that catch application errors such as double-free, 3151*8e33eff8Schristos write-after-free, etc.</para> 3152*8e33eff8Schristos 3153*8e33eff8Schristos <para>Programs often accidentally depend on <quote>uninitialized</quote> 3154*8e33eff8Schristos memory actually being filled with zero bytes. Junk filling 3155*8e33eff8Schristos (see the <link linkend="opt.junk"><mallctl>opt.junk</mallctl></link> 3156*8e33eff8Schristos option) tends to expose such bugs in the form of obviously incorrect 3157*8e33eff8Schristos results and/or coredumps. Conversely, zero 3158*8e33eff8Schristos filling (see the <link 3159*8e33eff8Schristos linkend="opt.zero"><mallctl>opt.zero</mallctl></link> option) eliminates 3160*8e33eff8Schristos the symptoms of such bugs. Between these two options, it is usually 3161*8e33eff8Schristos possible to quickly detect, diagnose, and eliminate such bugs.</para> 3162*8e33eff8Schristos 3163*8e33eff8Schristos <para>This implementation does not provide much detail about the problems 3164*8e33eff8Schristos it detects, because the performance impact for storing such information 3165*8e33eff8Schristos would be prohibitive.</para> 3166*8e33eff8Schristos </refsect1> 3167*8e33eff8Schristos <refsect1 id="diagnostic_messages"> 3168*8e33eff8Schristos <title>DIAGNOSTIC MESSAGES</title> 3169*8e33eff8Schristos <para>If any of the memory allocation/deallocation functions detect an 3170*8e33eff8Schristos error or warning condition, a message will be printed to file descriptor 3171*8e33eff8Schristos <constant>STDERR_FILENO</constant>. Errors will result in the process 3172*8e33eff8Schristos dumping core. If the <link 3173*8e33eff8Schristos linkend="opt.abort"><mallctl>opt.abort</mallctl></link> option is set, most 3174*8e33eff8Schristos warnings are treated as errors.</para> 3175*8e33eff8Schristos 3176*8e33eff8Schristos <para>The <varname>malloc_message</varname> variable allows the programmer 3177*8e33eff8Schristos to override the function which emits the text strings forming the errors 3178*8e33eff8Schristos and warnings if for some reason the <constant>STDERR_FILENO</constant> file 3179*8e33eff8Schristos descriptor is not suitable for this. 3180*8e33eff8Schristos <function>malloc_message()</function> takes the 3181*8e33eff8Schristos <parameter>cbopaque</parameter> pointer argument that is 3182*8e33eff8Schristos <constant>NULL</constant> unless overridden by the arguments in a call to 3183*8e33eff8Schristos <function>malloc_stats_print()</function>, followed by a string 3184*8e33eff8Schristos pointer. Please note that doing anything which tries to allocate memory in 3185*8e33eff8Schristos this function is likely to result in a crash or deadlock.</para> 3186*8e33eff8Schristos 3187*8e33eff8Schristos <para>All messages are prefixed by 3188*8e33eff8Schristos <quote><computeroutput><jemalloc>: </computeroutput></quote>.</para> 3189*8e33eff8Schristos </refsect1> 3190*8e33eff8Schristos <refsect1 id="return_values"> 3191*8e33eff8Schristos <title>RETURN VALUES</title> 3192*8e33eff8Schristos <refsect2> 3193*8e33eff8Schristos <title>Standard API</title> 3194*8e33eff8Schristos <para>The <function>malloc()</function> and 3195*8e33eff8Schristos <function>calloc()</function> functions return a pointer to the 3196*8e33eff8Schristos allocated memory if successful; otherwise a <constant>NULL</constant> 3197*8e33eff8Schristos pointer is returned and <varname>errno</varname> is set to 3198*8e33eff8Schristos <errorname>ENOMEM</errorname>.</para> 3199*8e33eff8Schristos 3200*8e33eff8Schristos <para>The <function>posix_memalign()</function> function 3201*8e33eff8Schristos returns the value 0 if successful; otherwise it returns an error value. 3202*8e33eff8Schristos The <function>posix_memalign()</function> function will fail 3203*8e33eff8Schristos if: 3204*8e33eff8Schristos <variablelist> 3205*8e33eff8Schristos <varlistentry> 3206*8e33eff8Schristos <term><errorname>EINVAL</errorname></term> 3207*8e33eff8Schristos 3208*8e33eff8Schristos <listitem><para>The <parameter>alignment</parameter> parameter is 3209*8e33eff8Schristos not a power of 2 at least as large as 3210*8e33eff8Schristos <code language="C">sizeof(<type>void *</type>)</code>. 3211*8e33eff8Schristos </para></listitem> 3212*8e33eff8Schristos </varlistentry> 3213*8e33eff8Schristos <varlistentry> 3214*8e33eff8Schristos <term><errorname>ENOMEM</errorname></term> 3215*8e33eff8Schristos 3216*8e33eff8Schristos <listitem><para>Memory allocation error.</para></listitem> 3217*8e33eff8Schristos </varlistentry> 3218*8e33eff8Schristos </variablelist> 3219*8e33eff8Schristos </para> 3220*8e33eff8Schristos 3221*8e33eff8Schristos <para>The <function>aligned_alloc()</function> function returns 3222*8e33eff8Schristos a pointer to the allocated memory if successful; otherwise a 3223*8e33eff8Schristos <constant>NULL</constant> pointer is returned and 3224*8e33eff8Schristos <varname>errno</varname> is set. The 3225*8e33eff8Schristos <function>aligned_alloc()</function> function will fail if: 3226*8e33eff8Schristos <variablelist> 3227*8e33eff8Schristos <varlistentry> 3228*8e33eff8Schristos <term><errorname>EINVAL</errorname></term> 3229*8e33eff8Schristos 3230*8e33eff8Schristos <listitem><para>The <parameter>alignment</parameter> parameter is 3231*8e33eff8Schristos not a power of 2. 3232*8e33eff8Schristos </para></listitem> 3233*8e33eff8Schristos </varlistentry> 3234*8e33eff8Schristos <varlistentry> 3235*8e33eff8Schristos <term><errorname>ENOMEM</errorname></term> 3236*8e33eff8Schristos 3237*8e33eff8Schristos <listitem><para>Memory allocation error.</para></listitem> 3238*8e33eff8Schristos </varlistentry> 3239*8e33eff8Schristos </variablelist> 3240*8e33eff8Schristos </para> 3241*8e33eff8Schristos 3242*8e33eff8Schristos <para>The <function>realloc()</function> function returns a 3243*8e33eff8Schristos pointer, possibly identical to <parameter>ptr</parameter>, to the 3244*8e33eff8Schristos allocated memory if successful; otherwise a <constant>NULL</constant> 3245*8e33eff8Schristos pointer is returned, and <varname>errno</varname> is set to 3246*8e33eff8Schristos <errorname>ENOMEM</errorname> if the error was the result of an 3247*8e33eff8Schristos allocation failure. The <function>realloc()</function> 3248*8e33eff8Schristos function always leaves the original buffer intact when an error occurs. 3249*8e33eff8Schristos </para> 3250*8e33eff8Schristos 3251*8e33eff8Schristos <para>The <function>free()</function> function returns no 3252*8e33eff8Schristos value.</para> 3253*8e33eff8Schristos </refsect2> 3254*8e33eff8Schristos <refsect2> 3255*8e33eff8Schristos <title>Non-standard API</title> 3256*8e33eff8Schristos <para>The <function>mallocx()</function> and 3257*8e33eff8Schristos <function>rallocx()</function> functions return a pointer to 3258*8e33eff8Schristos the allocated memory if successful; otherwise a <constant>NULL</constant> 3259*8e33eff8Schristos pointer is returned to indicate insufficient contiguous memory was 3260*8e33eff8Schristos available to service the allocation request. </para> 3261*8e33eff8Schristos 3262*8e33eff8Schristos <para>The <function>xallocx()</function> function returns the 3263*8e33eff8Schristos real size of the resulting resized allocation pointed to by 3264*8e33eff8Schristos <parameter>ptr</parameter>, which is a value less than 3265*8e33eff8Schristos <parameter>size</parameter> if the allocation could not be adequately 3266*8e33eff8Schristos grown in place. </para> 3267*8e33eff8Schristos 3268*8e33eff8Schristos <para>The <function>sallocx()</function> function returns the 3269*8e33eff8Schristos real size of the allocation pointed to by <parameter>ptr</parameter>. 3270*8e33eff8Schristos </para> 3271*8e33eff8Schristos 3272*8e33eff8Schristos <para>The <function>nallocx()</function> returns the real size 3273*8e33eff8Schristos that would result from a successful equivalent 3274*8e33eff8Schristos <function>mallocx()</function> function call, or zero if 3275*8e33eff8Schristos insufficient memory is available to perform the size computation. </para> 3276*8e33eff8Schristos 3277*8e33eff8Schristos <para>The <function>mallctl()</function>, 3278*8e33eff8Schristos <function>mallctlnametomib()</function>, and 3279*8e33eff8Schristos <function>mallctlbymib()</function> functions return 0 on 3280*8e33eff8Schristos success; otherwise they return an error value. The functions will fail 3281*8e33eff8Schristos if: 3282*8e33eff8Schristos <variablelist> 3283*8e33eff8Schristos <varlistentry> 3284*8e33eff8Schristos <term><errorname>EINVAL</errorname></term> 3285*8e33eff8Schristos 3286*8e33eff8Schristos <listitem><para><parameter>newp</parameter> is not 3287*8e33eff8Schristos <constant>NULL</constant>, and <parameter>newlen</parameter> is too 3288*8e33eff8Schristos large or too small. Alternatively, <parameter>*oldlenp</parameter> 3289*8e33eff8Schristos is too large or too small; in this case as much data as possible 3290*8e33eff8Schristos are read despite the error.</para></listitem> 3291*8e33eff8Schristos </varlistentry> 3292*8e33eff8Schristos <varlistentry> 3293*8e33eff8Schristos <term><errorname>ENOENT</errorname></term> 3294*8e33eff8Schristos 3295*8e33eff8Schristos <listitem><para><parameter>name</parameter> or 3296*8e33eff8Schristos <parameter>mib</parameter> specifies an unknown/invalid 3297*8e33eff8Schristos value.</para></listitem> 3298*8e33eff8Schristos </varlistentry> 3299*8e33eff8Schristos <varlistentry> 3300*8e33eff8Schristos <term><errorname>EPERM</errorname></term> 3301*8e33eff8Schristos 3302*8e33eff8Schristos <listitem><para>Attempt to read or write void value, or attempt to 3303*8e33eff8Schristos write read-only value.</para></listitem> 3304*8e33eff8Schristos </varlistentry> 3305*8e33eff8Schristos <varlistentry> 3306*8e33eff8Schristos <term><errorname>EAGAIN</errorname></term> 3307*8e33eff8Schristos 3308*8e33eff8Schristos <listitem><para>A memory allocation failure 3309*8e33eff8Schristos occurred.</para></listitem> 3310*8e33eff8Schristos </varlistentry> 3311*8e33eff8Schristos <varlistentry> 3312*8e33eff8Schristos <term><errorname>EFAULT</errorname></term> 3313*8e33eff8Schristos 3314*8e33eff8Schristos <listitem><para>An interface with side effects failed in some way 3315*8e33eff8Schristos not directly related to <function>mallctl*()</function> 3316*8e33eff8Schristos read/write processing.</para></listitem> 3317*8e33eff8Schristos </varlistentry> 3318*8e33eff8Schristos </variablelist> 3319*8e33eff8Schristos </para> 3320*8e33eff8Schristos 3321*8e33eff8Schristos <para>The <function>malloc_usable_size()</function> function 3322*8e33eff8Schristos returns the usable size of the allocation pointed to by 3323*8e33eff8Schristos <parameter>ptr</parameter>. </para> 3324*8e33eff8Schristos </refsect2> 3325*8e33eff8Schristos </refsect1> 3326*8e33eff8Schristos <refsect1 id="environment"> 3327*8e33eff8Schristos <title>ENVIRONMENT</title> 3328*8e33eff8Schristos <para>The following environment variable affects the execution of the 3329*8e33eff8Schristos allocation functions: 3330*8e33eff8Schristos <variablelist> 3331*8e33eff8Schristos <varlistentry> 3332*8e33eff8Schristos <term><envar>MALLOC_CONF</envar></term> 3333*8e33eff8Schristos 3334*8e33eff8Schristos <listitem><para>If the environment variable 3335*8e33eff8Schristos <envar>MALLOC_CONF</envar> is set, the characters it contains 3336*8e33eff8Schristos will be interpreted as options.</para></listitem> 3337*8e33eff8Schristos </varlistentry> 3338*8e33eff8Schristos </variablelist> 3339*8e33eff8Schristos </para> 3340*8e33eff8Schristos </refsect1> 3341*8e33eff8Schristos <refsect1 id="examples"> 3342*8e33eff8Schristos <title>EXAMPLES</title> 3343*8e33eff8Schristos <para>To dump core whenever a problem occurs: 3344*8e33eff8Schristos <screen>ln -s 'abort:true' /etc/malloc.conf</screen> 3345*8e33eff8Schristos </para> 3346*8e33eff8Schristos <para>To specify in the source that only one arena should be automatically 3347*8e33eff8Schristos created: 3348*8e33eff8Schristos <programlisting language="C"><![CDATA[ 3349*8e33eff8Schristosmalloc_conf = "narenas:1";]]></programlisting></para> 3350*8e33eff8Schristos </refsect1> 3351*8e33eff8Schristos <refsect1 id="see_also"> 3352*8e33eff8Schristos <title>SEE ALSO</title> 3353*8e33eff8Schristos <para><citerefentry><refentrytitle>madvise</refentrytitle> 3354*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry>, 3355*8e33eff8Schristos <citerefentry><refentrytitle>mmap</refentrytitle> 3356*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry>, 3357*8e33eff8Schristos <citerefentry><refentrytitle>sbrk</refentrytitle> 3358*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry>, 3359*8e33eff8Schristos <citerefentry><refentrytitle>utrace</refentrytitle> 3360*8e33eff8Schristos <manvolnum>2</manvolnum></citerefentry>, 3361*8e33eff8Schristos <citerefentry><refentrytitle>alloca</refentrytitle> 3362*8e33eff8Schristos <manvolnum>3</manvolnum></citerefentry>, 3363*8e33eff8Schristos <citerefentry><refentrytitle>atexit</refentrytitle> 3364*8e33eff8Schristos <manvolnum>3</manvolnum></citerefentry>, 3365*8e33eff8Schristos <citerefentry><refentrytitle>getpagesize</refentrytitle> 3366*8e33eff8Schristos <manvolnum>3</manvolnum></citerefentry></para> 3367*8e33eff8Schristos </refsect1> 3368*8e33eff8Schristos <refsect1 id="standards"> 3369*8e33eff8Schristos <title>STANDARDS</title> 3370*8e33eff8Schristos <para>The <function>malloc()</function>, 3371*8e33eff8Schristos <function>calloc()</function>, 3372*8e33eff8Schristos <function>realloc()</function>, and 3373*8e33eff8Schristos <function>free()</function> functions conform to ISO/IEC 3374*8e33eff8Schristos 9899:1990 (<quote>ISO C90</quote>).</para> 3375*8e33eff8Schristos 3376*8e33eff8Schristos <para>The <function>posix_memalign()</function> function conforms 3377*8e33eff8Schristos to IEEE Std 1003.1-2001 (<quote>POSIX.1</quote>).</para> 3378*8e33eff8Schristos </refsect1> 3379*8e33eff8Schristos</refentry> 3380