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