1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/memory/jemalloc/src/doc/jemalloc.xml.in Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,2173 @@ 1.4 +<?xml version='1.0' encoding='UTF-8'?> 1.5 +<?xml-stylesheet type="text/xsl" 1.6 + href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?> 1.7 +<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" 1.8 + "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ 1.9 +]> 1.10 + 1.11 +<refentry> 1.12 + <refentryinfo> 1.13 + <title>User Manual</title> 1.14 + <productname>jemalloc</productname> 1.15 + <releaseinfo role="version">@jemalloc_version@</releaseinfo> 1.16 + <authorgroup> 1.17 + <author> 1.18 + <firstname>Jason</firstname> 1.19 + <surname>Evans</surname> 1.20 + <personblurb>Author</personblurb> 1.21 + </author> 1.22 + </authorgroup> 1.23 + </refentryinfo> 1.24 + <refmeta> 1.25 + <refentrytitle>JEMALLOC</refentrytitle> 1.26 + <manvolnum>3</manvolnum> 1.27 + </refmeta> 1.28 + <refnamediv> 1.29 + <refdescriptor>jemalloc</refdescriptor> 1.30 + <refname>jemalloc</refname> 1.31 + <!-- Each refname causes a man page file to be created. Only if this were 1.32 + the system malloc(3) implementation would these files be appropriate. 1.33 + <refname>malloc</refname> 1.34 + <refname>calloc</refname> 1.35 + <refname>posix_memalign</refname> 1.36 + <refname>aligned_alloc</refname> 1.37 + <refname>realloc</refname> 1.38 + <refname>free</refname> 1.39 + <refname>malloc_usable_size</refname> 1.40 + <refname>malloc_stats_print</refname> 1.41 + <refname>mallctl</refname> 1.42 + <refname>mallctlnametomib</refname> 1.43 + <refname>mallctlbymib</refname> 1.44 + <refname>allocm</refname> 1.45 + <refname>rallocm</refname> 1.46 + <refname>sallocm</refname> 1.47 + <refname>dallocm</refname> 1.48 + <refname>nallocm</refname> 1.49 + --> 1.50 + <refpurpose>general purpose memory allocation functions</refpurpose> 1.51 + </refnamediv> 1.52 + <refsect1 id="library"> 1.53 + <title>LIBRARY</title> 1.54 + <para>This manual describes jemalloc @jemalloc_version@. More information 1.55 + can be found at the <ulink 1.56 + url="http://www.canonware.com/jemalloc/">jemalloc website</ulink>.</para> 1.57 + </refsect1> 1.58 + <refsynopsisdiv> 1.59 + <title>SYNOPSIS</title> 1.60 + <funcsynopsis> 1.61 + <funcsynopsisinfo>#include <<filename class="headerfile">stdlib.h</filename>> 1.62 +#include <<filename class="headerfile">jemalloc/jemalloc.h</filename>></funcsynopsisinfo> 1.63 + <refsect2> 1.64 + <title>Standard API</title> 1.65 + <funcprototype> 1.66 + <funcdef>void *<function>malloc</function></funcdef> 1.67 + <paramdef>size_t <parameter>size</parameter></paramdef> 1.68 + </funcprototype> 1.69 + <funcprototype> 1.70 + <funcdef>void *<function>calloc</function></funcdef> 1.71 + <paramdef>size_t <parameter>number</parameter></paramdef> 1.72 + <paramdef>size_t <parameter>size</parameter></paramdef> 1.73 + </funcprototype> 1.74 + <funcprototype> 1.75 + <funcdef>int <function>posix_memalign</function></funcdef> 1.76 + <paramdef>void **<parameter>ptr</parameter></paramdef> 1.77 + <paramdef>size_t <parameter>alignment</parameter></paramdef> 1.78 + <paramdef>size_t <parameter>size</parameter></paramdef> 1.79 + </funcprototype> 1.80 + <funcprototype> 1.81 + <funcdef>void *<function>aligned_alloc</function></funcdef> 1.82 + <paramdef>size_t <parameter>alignment</parameter></paramdef> 1.83 + <paramdef>size_t <parameter>size</parameter></paramdef> 1.84 + </funcprototype> 1.85 + <funcprototype> 1.86 + <funcdef>void *<function>realloc</function></funcdef> 1.87 + <paramdef>void *<parameter>ptr</parameter></paramdef> 1.88 + <paramdef>size_t <parameter>size</parameter></paramdef> 1.89 + </funcprototype> 1.90 + <funcprototype> 1.91 + <funcdef>void <function>free</function></funcdef> 1.92 + <paramdef>void *<parameter>ptr</parameter></paramdef> 1.93 + </funcprototype> 1.94 + </refsect2> 1.95 + <refsect2> 1.96 + <title>Non-standard API</title> 1.97 + <funcprototype> 1.98 + <funcdef>size_t <function>malloc_usable_size</function></funcdef> 1.99 + <paramdef>const void *<parameter>ptr</parameter></paramdef> 1.100 + </funcprototype> 1.101 + <funcprototype> 1.102 + <funcdef>void <function>malloc_stats_print</function></funcdef> 1.103 + <paramdef>void <parameter>(*write_cb)</parameter> 1.104 + <funcparams>void *, const char *</funcparams> 1.105 + </paramdef> 1.106 + <paramdef>void *<parameter>cbopaque</parameter></paramdef> 1.107 + <paramdef>const char *<parameter>opts</parameter></paramdef> 1.108 + </funcprototype> 1.109 + <funcprototype> 1.110 + <funcdef>int <function>mallctl</function></funcdef> 1.111 + <paramdef>const char *<parameter>name</parameter></paramdef> 1.112 + <paramdef>void *<parameter>oldp</parameter></paramdef> 1.113 + <paramdef>size_t *<parameter>oldlenp</parameter></paramdef> 1.114 + <paramdef>void *<parameter>newp</parameter></paramdef> 1.115 + <paramdef>size_t <parameter>newlen</parameter></paramdef> 1.116 + </funcprototype> 1.117 + <funcprototype> 1.118 + <funcdef>int <function>mallctlnametomib</function></funcdef> 1.119 + <paramdef>const char *<parameter>name</parameter></paramdef> 1.120 + <paramdef>size_t *<parameter>mibp</parameter></paramdef> 1.121 + <paramdef>size_t *<parameter>miblenp</parameter></paramdef> 1.122 + </funcprototype> 1.123 + <funcprototype> 1.124 + <funcdef>int <function>mallctlbymib</function></funcdef> 1.125 + <paramdef>const size_t *<parameter>mib</parameter></paramdef> 1.126 + <paramdef>size_t <parameter>miblen</parameter></paramdef> 1.127 + <paramdef>void *<parameter>oldp</parameter></paramdef> 1.128 + <paramdef>size_t *<parameter>oldlenp</parameter></paramdef> 1.129 + <paramdef>void *<parameter>newp</parameter></paramdef> 1.130 + <paramdef>size_t <parameter>newlen</parameter></paramdef> 1.131 + </funcprototype> 1.132 + <funcprototype> 1.133 + <funcdef>void <function>(*malloc_message)</function></funcdef> 1.134 + <paramdef>void *<parameter>cbopaque</parameter></paramdef> 1.135 + <paramdef>const char *<parameter>s</parameter></paramdef> 1.136 + </funcprototype> 1.137 + <para><type>const char *</type><varname>malloc_conf</varname>;</para> 1.138 + </refsect2> 1.139 + <refsect2> 1.140 + <title>Experimental API</title> 1.141 + <funcprototype> 1.142 + <funcdef>int <function>allocm</function></funcdef> 1.143 + <paramdef>void **<parameter>ptr</parameter></paramdef> 1.144 + <paramdef>size_t *<parameter>rsize</parameter></paramdef> 1.145 + <paramdef>size_t <parameter>size</parameter></paramdef> 1.146 + <paramdef>int <parameter>flags</parameter></paramdef> 1.147 + </funcprototype> 1.148 + <funcprototype> 1.149 + <funcdef>int <function>rallocm</function></funcdef> 1.150 + <paramdef>void **<parameter>ptr</parameter></paramdef> 1.151 + <paramdef>size_t *<parameter>rsize</parameter></paramdef> 1.152 + <paramdef>size_t <parameter>size</parameter></paramdef> 1.153 + <paramdef>size_t <parameter>extra</parameter></paramdef> 1.154 + <paramdef>int <parameter>flags</parameter></paramdef> 1.155 + </funcprototype> 1.156 + <funcprototype> 1.157 + <funcdef>int <function>sallocm</function></funcdef> 1.158 + <paramdef>const void *<parameter>ptr</parameter></paramdef> 1.159 + <paramdef>size_t *<parameter>rsize</parameter></paramdef> 1.160 + <paramdef>int <parameter>flags</parameter></paramdef> 1.161 + </funcprototype> 1.162 + <funcprototype> 1.163 + <funcdef>int <function>dallocm</function></funcdef> 1.164 + <paramdef>void *<parameter>ptr</parameter></paramdef> 1.165 + <paramdef>int <parameter>flags</parameter></paramdef> 1.166 + </funcprototype> 1.167 + <funcprototype> 1.168 + <funcdef>int <function>nallocm</function></funcdef> 1.169 + <paramdef>size_t *<parameter>rsize</parameter></paramdef> 1.170 + <paramdef>size_t <parameter>size</parameter></paramdef> 1.171 + <paramdef>int <parameter>flags</parameter></paramdef> 1.172 + </funcprototype> 1.173 + </refsect2> 1.174 + </funcsynopsis> 1.175 + </refsynopsisdiv> 1.176 + <refsect1 id="description"> 1.177 + <title>DESCRIPTION</title> 1.178 + <refsect2> 1.179 + <title>Standard API</title> 1.180 + 1.181 + <para>The <function>malloc<parameter/></function> function allocates 1.182 + <parameter>size</parameter> bytes of uninitialized memory. The allocated 1.183 + space is suitably aligned (after possible pointer coercion) for storage 1.184 + of any type of object.</para> 1.185 + 1.186 + <para>The <function>calloc<parameter/></function> function allocates 1.187 + space for <parameter>number</parameter> objects, each 1.188 + <parameter>size</parameter> bytes in length. The result is identical to 1.189 + calling <function>malloc<parameter/></function> with an argument of 1.190 + <parameter>number</parameter> * <parameter>size</parameter>, with the 1.191 + exception that the allocated memory is explicitly initialized to zero 1.192 + bytes.</para> 1.193 + 1.194 + <para>The <function>posix_memalign<parameter/></function> function 1.195 + allocates <parameter>size</parameter> bytes of memory such that the 1.196 + allocation's base address is an even multiple of 1.197 + <parameter>alignment</parameter>, and returns the allocation in the value 1.198 + pointed to by <parameter>ptr</parameter>. The requested 1.199 + <parameter>alignment</parameter> must be a power of 2 at least as large 1.200 + as <code language="C">sizeof(<type>void *</type>)</code>.</para> 1.201 + 1.202 + <para>The <function>aligned_alloc<parameter/></function> function 1.203 + allocates <parameter>size</parameter> bytes of memory such that the 1.204 + allocation's base address is an even multiple of 1.205 + <parameter>alignment</parameter>. The requested 1.206 + <parameter>alignment</parameter> must be a power of 2. Behavior is 1.207 + undefined if <parameter>size</parameter> is not an integral multiple of 1.208 + <parameter>alignment</parameter>.</para> 1.209 + 1.210 + <para>The <function>realloc<parameter/></function> function changes the 1.211 + size of the previously allocated memory referenced by 1.212 + <parameter>ptr</parameter> to <parameter>size</parameter> bytes. The 1.213 + contents of the memory are unchanged up to the lesser of the new and old 1.214 + sizes. If the new size is larger, the contents of the newly allocated 1.215 + portion of the memory are undefined. Upon success, the memory referenced 1.216 + by <parameter>ptr</parameter> is freed and a pointer to the newly 1.217 + allocated memory is returned. Note that 1.218 + <function>realloc<parameter/></function> may move the memory allocation, 1.219 + resulting in a different return value than <parameter>ptr</parameter>. 1.220 + If <parameter>ptr</parameter> is <constant>NULL</constant>, the 1.221 + <function>realloc<parameter/></function> function behaves identically to 1.222 + <function>malloc<parameter/></function> for the specified size.</para> 1.223 + 1.224 + <para>The <function>free<parameter/></function> function causes the 1.225 + allocated memory referenced by <parameter>ptr</parameter> to be made 1.226 + available for future allocations. If <parameter>ptr</parameter> is 1.227 + <constant>NULL</constant>, no action occurs.</para> 1.228 + </refsect2> 1.229 + <refsect2> 1.230 + <title>Non-standard API</title> 1.231 + 1.232 + <para>The <function>malloc_usable_size<parameter/></function> function 1.233 + returns the usable size of the allocation pointed to by 1.234 + <parameter>ptr</parameter>. The return value may be larger than the size 1.235 + that was requested during allocation. The 1.236 + <function>malloc_usable_size<parameter/></function> function is not a 1.237 + mechanism for in-place <function>realloc<parameter/></function>; rather 1.238 + it is provided solely as a tool for introspection purposes. Any 1.239 + discrepancy between the requested allocation size and the size reported 1.240 + by <function>malloc_usable_size<parameter/></function> should not be 1.241 + depended on, since such behavior is entirely implementation-dependent. 1.242 + </para> 1.243 + 1.244 + <para>The <function>malloc_stats_print<parameter/></function> function 1.245 + writes human-readable summary statistics via the 1.246 + <parameter>write_cb</parameter> callback function pointer and 1.247 + <parameter>cbopaque</parameter> data passed to 1.248 + <parameter>write_cb</parameter>, or 1.249 + <function>malloc_message<parameter/></function> if 1.250 + <parameter>write_cb</parameter> is <constant>NULL</constant>. This 1.251 + function can be called repeatedly. General information that never 1.252 + changes during execution can be omitted by specifying "g" as a character 1.253 + within the <parameter>opts</parameter> string. Note that 1.254 + <function>malloc_message<parameter/></function> uses the 1.255 + <function>mallctl*<parameter/></function> functions internally, so 1.256 + inconsistent statistics can be reported if multiple threads use these 1.257 + functions simultaneously. If <option>--enable-stats</option> is 1.258 + specified during configuration, “m” and “a” can 1.259 + be specified to omit merged arena and per arena statistics, respectively; 1.260 + “b” and “l” can be specified to omit per size 1.261 + class statistics for bins and large objects, respectively. Unrecognized 1.262 + characters are silently ignored. Note that thread caching may prevent 1.263 + some statistics from being completely up to date, since extra locking 1.264 + would be required to merge counters that track thread cache operations. 1.265 + </para> 1.266 + 1.267 + <para>The <function>mallctl<parameter/></function> function provides a 1.268 + general interface for introspecting the memory allocator, as well as 1.269 + setting modifiable parameters and triggering actions. The 1.270 + period-separated <parameter>name</parameter> argument specifies a 1.271 + location in a tree-structured namespace; see the <xref 1.272 + linkend="mallctl_namespace" xrefstyle="template:%t"/> section for 1.273 + documentation on the tree contents. To read a value, pass a pointer via 1.274 + <parameter>oldp</parameter> to adequate space to contain the value, and a 1.275 + pointer to its length via <parameter>oldlenp</parameter>; otherwise pass 1.276 + <constant>NULL</constant> and <constant>NULL</constant>. Similarly, to 1.277 + write a value, pass a pointer to the value via 1.278 + <parameter>newp</parameter>, and its length via 1.279 + <parameter>newlen</parameter>; otherwise pass <constant>NULL</constant> 1.280 + and <constant>0</constant>.</para> 1.281 + 1.282 + <para>The <function>mallctlnametomib<parameter/></function> function 1.283 + provides a way to avoid repeated name lookups for applications that 1.284 + repeatedly query the same portion of the namespace, by translating a name 1.285 + to a “Management Information Base” (MIB) that can be passed 1.286 + repeatedly to <function>mallctlbymib<parameter/></function>. Upon 1.287 + successful return from <function>mallctlnametomib<parameter/></function>, 1.288 + <parameter>mibp</parameter> contains an array of 1.289 + <parameter>*miblenp</parameter> integers, where 1.290 + <parameter>*miblenp</parameter> is the lesser of the number of components 1.291 + in <parameter>name</parameter> and the input value of 1.292 + <parameter>*miblenp</parameter>. Thus it is possible to pass a 1.293 + <parameter>*miblenp</parameter> that is smaller than the number of 1.294 + period-separated name components, which results in a partial MIB that can 1.295 + be used as the basis for constructing a complete MIB. For name 1.296 + components that are integers (e.g. the 2 in 1.297 + <link 1.298 + linkend="arenas.bin.i.size"><mallctl>arenas.bin.2.size</mallctl></link>), 1.299 + the corresponding MIB component will always be that integer. Therefore, 1.300 + it is legitimate to construct code like the following: <programlisting 1.301 + language="C"><![CDATA[ 1.302 +unsigned nbins, i; 1.303 + 1.304 +int mib[4]; 1.305 +size_t len, miblen; 1.306 + 1.307 +len = sizeof(nbins); 1.308 +mallctl("arenas.nbins", &nbins, &len, NULL, 0); 1.309 + 1.310 +miblen = 4; 1.311 +mallnametomib("arenas.bin.0.size", mib, &miblen); 1.312 +for (i = 0; i < nbins; i++) { 1.313 + size_t bin_size; 1.314 + 1.315 + mib[2] = i; 1.316 + len = sizeof(bin_size); 1.317 + mallctlbymib(mib, miblen, &bin_size, &len, NULL, 0); 1.318 + /* Do something with bin_size... */ 1.319 +}]]></programlisting></para> 1.320 + </refsect2> 1.321 + <refsect2> 1.322 + <title>Experimental API</title> 1.323 + <para>The experimental API is subject to change or removal without regard 1.324 + for backward compatibility. If <option>--disable-experimental</option> 1.325 + is specified during configuration, the experimental API is 1.326 + omitted.</para> 1.327 + 1.328 + <para>The <function>allocm<parameter/></function>, 1.329 + <function>rallocm<parameter/></function>, 1.330 + <function>sallocm<parameter/></function>, 1.331 + <function>dallocm<parameter/></function>, and 1.332 + <function>nallocm<parameter/></function> functions all have a 1.333 + <parameter>flags</parameter> argument that can be used to specify 1.334 + options. The functions only check the options that are contextually 1.335 + relevant. Use bitwise or (<code language="C">|</code>) operations to 1.336 + specify one or more of the following: 1.337 + <variablelist> 1.338 + <varlistentry> 1.339 + <term><constant>ALLOCM_LG_ALIGN(<parameter>la</parameter>) 1.340 + </constant></term> 1.341 + 1.342 + <listitem><para>Align the memory allocation to start at an address 1.343 + that is a multiple of <code language="C">(1 << 1.344 + <parameter>la</parameter>)</code>. This macro does not validate 1.345 + that <parameter>la</parameter> is within the valid 1.346 + range.</para></listitem> 1.347 + </varlistentry> 1.348 + <varlistentry> 1.349 + <term><constant>ALLOCM_ALIGN(<parameter>a</parameter>) 1.350 + </constant></term> 1.351 + 1.352 + <listitem><para>Align the memory allocation to start at an address 1.353 + that is a multiple of <parameter>a</parameter>, where 1.354 + <parameter>a</parameter> is a power of two. This macro does not 1.355 + validate that <parameter>a</parameter> is a power of 2. 1.356 + </para></listitem> 1.357 + </varlistentry> 1.358 + <varlistentry> 1.359 + <term><constant>ALLOCM_ZERO</constant></term> 1.360 + 1.361 + <listitem><para>Initialize newly allocated memory to contain zero 1.362 + bytes. In the growing reallocation case, the real size prior to 1.363 + reallocation defines the boundary between untouched bytes and those 1.364 + that are initialized to contain zero bytes. If this option is 1.365 + absent, newly allocated memory is uninitialized.</para></listitem> 1.366 + </varlistentry> 1.367 + <varlistentry> 1.368 + <term><constant>ALLOCM_NO_MOVE</constant></term> 1.369 + 1.370 + <listitem><para>For reallocation, fail rather than moving the 1.371 + object. This constraint can apply to both growth and 1.372 + shrinkage.</para></listitem> 1.373 + </varlistentry> 1.374 + <varlistentry> 1.375 + <term><constant>ALLOCM_ARENA(<parameter>a</parameter>) 1.376 + </constant></term> 1.377 + 1.378 + <listitem><para>Use the arena specified by the index 1.379 + <parameter>a</parameter>. This macro does not validate that 1.380 + <parameter>a</parameter> specifies an arena in the valid 1.381 + range.</para></listitem> 1.382 + </varlistentry> 1.383 + </variablelist> 1.384 + </para> 1.385 + 1.386 + <para>The <function>allocm<parameter/></function> function allocates at 1.387 + least <parameter>size</parameter> bytes of memory, sets 1.388 + <parameter>*ptr</parameter> to the base address of the allocation, and 1.389 + sets <parameter>*rsize</parameter> to the real size of the allocation if 1.390 + <parameter>rsize</parameter> is not <constant>NULL</constant>. Behavior 1.391 + is undefined if <parameter>size</parameter> is 1.392 + <constant>0</constant>.</para> 1.393 + 1.394 + <para>The <function>rallocm<parameter/></function> function resizes the 1.395 + allocation at <parameter>*ptr</parameter> to be at least 1.396 + <parameter>size</parameter> bytes, sets <parameter>*ptr</parameter> to 1.397 + the base address of the allocation if it moved, and sets 1.398 + <parameter>*rsize</parameter> to the real size of the allocation if 1.399 + <parameter>rsize</parameter> is not <constant>NULL</constant>. If 1.400 + <parameter>extra</parameter> is non-zero, an attempt is made to resize 1.401 + the allocation to be at least <code 1.402 + language="C"><parameter>size</parameter> + 1.403 + <parameter>extra</parameter>)</code> bytes, though inability to allocate 1.404 + the extra byte(s) will not by itself result in failure. Behavior is 1.405 + undefined if <parameter>size</parameter> is <constant>0</constant>, or if 1.406 + <code language="C">(<parameter>size</parameter> + 1.407 + <parameter>extra</parameter> > 1.408 + <constant>SIZE_T_MAX</constant>)</code>.</para> 1.409 + 1.410 + <para>The <function>sallocm<parameter/></function> function sets 1.411 + <parameter>*rsize</parameter> to the real size of the allocation.</para> 1.412 + 1.413 + <para>The <function>dallocm<parameter/></function> function causes the 1.414 + memory referenced by <parameter>ptr</parameter> to be made available for 1.415 + future allocations.</para> 1.416 + 1.417 + <para>The <function>nallocm<parameter/></function> function allocates no 1.418 + memory, but it performs the same size computation as the 1.419 + <function>allocm<parameter/></function> function, and if 1.420 + <parameter>rsize</parameter> is not <constant>NULL</constant> it sets 1.421 + <parameter>*rsize</parameter> to the real size of the allocation that 1.422 + would result from the equivalent <function>allocm<parameter/></function> 1.423 + function call. Behavior is undefined if 1.424 + <parameter>size</parameter> is <constant>0</constant>.</para> 1.425 + </refsect2> 1.426 + </refsect1> 1.427 + <refsect1 id="tuning"> 1.428 + <title>TUNING</title> 1.429 + <para>Once, when the first call is made to one of the memory allocation 1.430 + routines, the allocator initializes its internals based in part on various 1.431 + options that can be specified at compile- or run-time.</para> 1.432 + 1.433 + <para>The string pointed to by the global variable 1.434 + <varname>malloc_conf</varname>, the “name” of the file 1.435 + referenced by the symbolic link named <filename 1.436 + class="symlink">/etc/malloc.conf</filename>, and the value of the 1.437 + environment variable <envar>MALLOC_CONF</envar>, will be interpreted, in 1.438 + that order, from left to right as options.</para> 1.439 + 1.440 + <para>An options string is a comma-separated list of option:value pairs. 1.441 + There is one key corresponding to each <link 1.442 + linkend="opt.abort"><mallctl>opt.*</mallctl></link> mallctl (see the <xref 1.443 + linkend="mallctl_namespace" xrefstyle="template:%t"/> section for options 1.444 + documentation). For example, <literal>abort:true,narenas:1</literal> sets 1.445 + the <link linkend="opt.abort"><mallctl>opt.abort</mallctl></link> and <link 1.446 + linkend="opt.narenas"><mallctl>opt.narenas</mallctl></link> options. Some 1.447 + options have boolean values (true/false), others have integer values (base 1.448 + 8, 10, or 16, depending on prefix), and yet others have raw string 1.449 + values.</para> 1.450 + </refsect1> 1.451 + <refsect1 id="implementation_notes"> 1.452 + <title>IMPLEMENTATION NOTES</title> 1.453 + <para>Traditionally, allocators have used 1.454 + <citerefentry><refentrytitle>sbrk</refentrytitle> 1.455 + <manvolnum>2</manvolnum></citerefentry> to obtain memory, which is 1.456 + suboptimal for several reasons, including race conditions, increased 1.457 + fragmentation, and artificial limitations on maximum usable memory. If 1.458 + <option>--enable-dss</option> is specified during configuration, this 1.459 + allocator uses both <citerefentry><refentrytitle>mmap</refentrytitle> 1.460 + <manvolnum>2</manvolnum></citerefentry> and 1.461 + <citerefentry><refentrytitle>sbrk</refentrytitle> 1.462 + <manvolnum>2</manvolnum></citerefentry>, in that order of preference; 1.463 + otherwise only <citerefentry><refentrytitle>mmap</refentrytitle> 1.464 + <manvolnum>2</manvolnum></citerefentry> is used.</para> 1.465 + 1.466 + <para>This allocator uses multiple arenas in order to reduce lock 1.467 + contention for threaded programs on multi-processor systems. This works 1.468 + well with regard to threading scalability, but incurs some costs. There is 1.469 + a small fixed per-arena overhead, and additionally, arenas manage memory 1.470 + completely independently of each other, which means a small fixed increase 1.471 + in overall memory fragmentation. These overheads are not generally an 1.472 + issue, given the number of arenas normally used. Note that using 1.473 + substantially more arenas than the default is not likely to improve 1.474 + performance, mainly due to reduced cache performance. However, it may make 1.475 + sense to reduce the number of arenas if an application does not make much 1.476 + use of the allocation functions.</para> 1.477 + 1.478 + <para>In addition to multiple arenas, unless 1.479 + <option>--disable-tcache</option> is specified during configuration, this 1.480 + allocator supports thread-specific caching for small and large objects, in 1.481 + order to make it possible to completely avoid synchronization for most 1.482 + allocation requests. Such caching allows very fast allocation in the 1.483 + common case, but it increases memory usage and fragmentation, since a 1.484 + bounded number of objects can remain allocated in each thread cache.</para> 1.485 + 1.486 + <para>Memory is conceptually broken into equal-sized chunks, where the 1.487 + chunk size is a power of two that is greater than the page size. Chunks 1.488 + are always aligned to multiples of the chunk size. This alignment makes it 1.489 + possible to find metadata for user objects very quickly.</para> 1.490 + 1.491 + <para>User objects are broken into three categories according to size: 1.492 + small, large, and huge. Small objects are smaller than one page. Large 1.493 + objects are smaller than the chunk size. Huge objects are a multiple of 1.494 + the chunk size. Small and large objects are managed by arenas; huge 1.495 + objects are managed separately in a single data structure that is shared by 1.496 + all threads. Huge objects are used by applications infrequently enough 1.497 + that this single data structure is not a scalability issue.</para> 1.498 + 1.499 + <para>Each chunk that is managed by an arena tracks its contents as runs of 1.500 + contiguous pages (unused, backing a set of small objects, or backing one 1.501 + large object). The combination of chunk alignment and chunk page maps 1.502 + makes it possible to determine all metadata regarding small and large 1.503 + allocations in constant time.</para> 1.504 + 1.505 + <para>Small objects are managed in groups by page runs. Each run maintains 1.506 + a frontier and free list to track which regions are in use. Allocation 1.507 + requests that are no more than half the quantum (8 or 16, depending on 1.508 + architecture) are rounded up to the nearest power of two that is at least 1.509 + <code language="C">sizeof(<type>double</type>)</code>. All other small 1.510 + object size classes are multiples of the quantum, spaced such that internal 1.511 + fragmentation is limited to approximately 25% for all but the smallest size 1.512 + classes. Allocation requests that are larger than the maximum small size 1.513 + class, but small enough to fit in an arena-managed chunk (see the <link 1.514 + linkend="opt.lg_chunk"><mallctl>opt.lg_chunk</mallctl></link> option), are 1.515 + rounded up to the nearest run size. Allocation requests that are too large 1.516 + to fit in an arena-managed chunk are rounded up to the nearest multiple of 1.517 + the chunk size.</para> 1.518 + 1.519 + <para>Allocations are packed tightly together, which can be an issue for 1.520 + multi-threaded applications. If you need to assure that allocations do not 1.521 + suffer from cacheline sharing, round your allocation requests up to the 1.522 + nearest multiple of the cacheline size, or specify cacheline alignment when 1.523 + allocating.</para> 1.524 + 1.525 + <para>Assuming 4 MiB chunks, 4 KiB pages, and a 16-byte quantum on a 64-bit 1.526 + system, the size classes in each category are as shown in <xref 1.527 + linkend="size_classes" xrefstyle="template:Table %n"/>.</para> 1.528 + 1.529 + <table xml:id="size_classes" frame="all"> 1.530 + <title>Size classes</title> 1.531 + <tgroup cols="3" colsep="1" rowsep="1"> 1.532 + <colspec colname="c1" align="left"/> 1.533 + <colspec colname="c2" align="right"/> 1.534 + <colspec colname="c3" align="left"/> 1.535 + <thead> 1.536 + <row> 1.537 + <entry>Category</entry> 1.538 + <entry>Spacing</entry> 1.539 + <entry>Size</entry> 1.540 + </row> 1.541 + </thead> 1.542 + <tbody> 1.543 + <row> 1.544 + <entry morerows="6">Small</entry> 1.545 + <entry>lg</entry> 1.546 + <entry>[8]</entry> 1.547 + </row> 1.548 + <row> 1.549 + <entry>16</entry> 1.550 + <entry>[16, 32, 48, ..., 128]</entry> 1.551 + </row> 1.552 + <row> 1.553 + <entry>32</entry> 1.554 + <entry>[160, 192, 224, 256]</entry> 1.555 + </row> 1.556 + <row> 1.557 + <entry>64</entry> 1.558 + <entry>[320, 384, 448, 512]</entry> 1.559 + </row> 1.560 + <row> 1.561 + <entry>128</entry> 1.562 + <entry>[640, 768, 896, 1024]</entry> 1.563 + </row> 1.564 + <row> 1.565 + <entry>256</entry> 1.566 + <entry>[1280, 1536, 1792, 2048]</entry> 1.567 + </row> 1.568 + <row> 1.569 + <entry>512</entry> 1.570 + <entry>[2560, 3072, 3584]</entry> 1.571 + </row> 1.572 + <row> 1.573 + <entry>Large</entry> 1.574 + <entry>4 KiB</entry> 1.575 + <entry>[4 KiB, 8 KiB, 12 KiB, ..., 4072 KiB]</entry> 1.576 + </row> 1.577 + <row> 1.578 + <entry>Huge</entry> 1.579 + <entry>4 MiB</entry> 1.580 + <entry>[4 MiB, 8 MiB, 12 MiB, ...]</entry> 1.581 + </row> 1.582 + </tbody> 1.583 + </tgroup> 1.584 + </table> 1.585 + </refsect1> 1.586 + <refsect1 id="mallctl_namespace"> 1.587 + <title>MALLCTL NAMESPACE</title> 1.588 + <para>The following names are defined in the namespace accessible via the 1.589 + <function>mallctl*<parameter/></function> functions. Value types are 1.590 + specified in parentheses, their readable/writable statuses are encoded as 1.591 + <literal>rw</literal>, <literal>r-</literal>, <literal>-w</literal>, or 1.592 + <literal>--</literal>, and required build configuration flags follow, if 1.593 + any. A name element encoded as <literal><i></literal> or 1.594 + <literal><j></literal> indicates an integer component, where the 1.595 + integer varies from 0 to some upper value that must be determined via 1.596 + introspection. In the case of <mallctl>stats.arenas.<i>.*</mallctl>, 1.597 + <literal><i></literal> equal to <link 1.598 + linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link> can be 1.599 + used to access the summation of statistics from all arenas. Take special 1.600 + note of the <link linkend="epoch"><mallctl>epoch</mallctl></link> mallctl, 1.601 + which controls refreshing of cached dynamic statistics.</para> 1.602 + 1.603 + <variablelist> 1.604 + <varlistentry> 1.605 + <term> 1.606 + <mallctl>version</mallctl> 1.607 + (<type>const char *</type>) 1.608 + <literal>r-</literal> 1.609 + </term> 1.610 + <listitem><para>Return the jemalloc version string.</para></listitem> 1.611 + </varlistentry> 1.612 + 1.613 + <varlistentry id="epoch"> 1.614 + <term> 1.615 + <mallctl>epoch</mallctl> 1.616 + (<type>uint64_t</type>) 1.617 + <literal>rw</literal> 1.618 + </term> 1.619 + <listitem><para>If a value is passed in, refresh the data from which 1.620 + the <function>mallctl*<parameter/></function> functions report values, 1.621 + and increment the epoch. Return the current epoch. This is useful for 1.622 + detecting whether another thread caused a refresh.</para></listitem> 1.623 + </varlistentry> 1.624 + 1.625 + <varlistentry> 1.626 + <term> 1.627 + <mallctl>config.debug</mallctl> 1.628 + (<type>bool</type>) 1.629 + <literal>r-</literal> 1.630 + </term> 1.631 + <listitem><para><option>--enable-debug</option> was specified during 1.632 + build configuration.</para></listitem> 1.633 + </varlistentry> 1.634 + 1.635 + <varlistentry> 1.636 + <term> 1.637 + <mallctl>config.dss</mallctl> 1.638 + (<type>bool</type>) 1.639 + <literal>r-</literal> 1.640 + </term> 1.641 + <listitem><para><option>--enable-dss</option> was specified during 1.642 + build configuration.</para></listitem> 1.643 + </varlistentry> 1.644 + 1.645 + <varlistentry> 1.646 + <term> 1.647 + <mallctl>config.fill</mallctl> 1.648 + (<type>bool</type>) 1.649 + <literal>r-</literal> 1.650 + </term> 1.651 + <listitem><para><option>--enable-fill</option> was specified during 1.652 + build configuration.</para></listitem> 1.653 + </varlistentry> 1.654 + 1.655 + <varlistentry> 1.656 + <term> 1.657 + <mallctl>config.lazy_lock</mallctl> 1.658 + (<type>bool</type>) 1.659 + <literal>r-</literal> 1.660 + </term> 1.661 + <listitem><para><option>--enable-lazy-lock</option> was specified 1.662 + during build configuration.</para></listitem> 1.663 + </varlistentry> 1.664 + 1.665 + <varlistentry> 1.666 + <term> 1.667 + <mallctl>config.mremap</mallctl> 1.668 + (<type>bool</type>) 1.669 + <literal>r-</literal> 1.670 + </term> 1.671 + <listitem><para><option>--enable-mremap</option> was specified during 1.672 + build configuration.</para></listitem> 1.673 + </varlistentry> 1.674 + 1.675 + <varlistentry> 1.676 + <term> 1.677 + <mallctl>config.munmap</mallctl> 1.678 + (<type>bool</type>) 1.679 + <literal>r-</literal> 1.680 + </term> 1.681 + <listitem><para><option>--enable-munmap</option> was specified during 1.682 + build configuration.</para></listitem> 1.683 + </varlistentry> 1.684 + 1.685 + <varlistentry> 1.686 + <term> 1.687 + <mallctl>config.prof</mallctl> 1.688 + (<type>bool</type>) 1.689 + <literal>r-</literal> 1.690 + </term> 1.691 + <listitem><para><option>--enable-prof</option> was specified during 1.692 + build configuration.</para></listitem> 1.693 + </varlistentry> 1.694 + 1.695 + <varlistentry> 1.696 + <term> 1.697 + <mallctl>config.prof_libgcc</mallctl> 1.698 + (<type>bool</type>) 1.699 + <literal>r-</literal> 1.700 + </term> 1.701 + <listitem><para><option>--disable-prof-libgcc</option> was not 1.702 + specified during build configuration.</para></listitem> 1.703 + </varlistentry> 1.704 + 1.705 + <varlistentry> 1.706 + <term> 1.707 + <mallctl>config.prof_libunwind</mallctl> 1.708 + (<type>bool</type>) 1.709 + <literal>r-</literal> 1.710 + </term> 1.711 + <listitem><para><option>--enable-prof-libunwind</option> was specified 1.712 + during build configuration.</para></listitem> 1.713 + </varlistentry> 1.714 + 1.715 + <varlistentry> 1.716 + <term> 1.717 + <mallctl>config.stats</mallctl> 1.718 + (<type>bool</type>) 1.719 + <literal>r-</literal> 1.720 + </term> 1.721 + <listitem><para><option>--enable-stats</option> was specified during 1.722 + build configuration.</para></listitem> 1.723 + </varlistentry> 1.724 + 1.725 + <varlistentry> 1.726 + <term> 1.727 + <mallctl>config.tcache</mallctl> 1.728 + (<type>bool</type>) 1.729 + <literal>r-</literal> 1.730 + </term> 1.731 + <listitem><para><option>--disable-tcache</option> was not specified 1.732 + during build configuration.</para></listitem> 1.733 + </varlistentry> 1.734 + 1.735 + <varlistentry> 1.736 + <term> 1.737 + <mallctl>config.tls</mallctl> 1.738 + (<type>bool</type>) 1.739 + <literal>r-</literal> 1.740 + </term> 1.741 + <listitem><para><option>--disable-tls</option> was not specified during 1.742 + build configuration.</para></listitem> 1.743 + </varlistentry> 1.744 + 1.745 + <varlistentry> 1.746 + <term> 1.747 + <mallctl>config.utrace</mallctl> 1.748 + (<type>bool</type>) 1.749 + <literal>r-</literal> 1.750 + </term> 1.751 + <listitem><para><option>--enable-utrace</option> was specified during 1.752 + build configuration.</para></listitem> 1.753 + </varlistentry> 1.754 + 1.755 + <varlistentry> 1.756 + <term> 1.757 + <mallctl>config.valgrind</mallctl> 1.758 + (<type>bool</type>) 1.759 + <literal>r-</literal> 1.760 + </term> 1.761 + <listitem><para><option>--enable-valgrind</option> was specified during 1.762 + build configuration.</para></listitem> 1.763 + </varlistentry> 1.764 + 1.765 + <varlistentry> 1.766 + <term> 1.767 + <mallctl>config.xmalloc</mallctl> 1.768 + (<type>bool</type>) 1.769 + <literal>r-</literal> 1.770 + </term> 1.771 + <listitem><para><option>--enable-xmalloc</option> was specified during 1.772 + build configuration.</para></listitem> 1.773 + </varlistentry> 1.774 + 1.775 + <varlistentry id="opt.abort"> 1.776 + <term> 1.777 + <mallctl>opt.abort</mallctl> 1.778 + (<type>bool</type>) 1.779 + <literal>r-</literal> 1.780 + </term> 1.781 + <listitem><para>Abort-on-warning enabled/disabled. If true, most 1.782 + warnings are fatal. The process will call 1.783 + <citerefentry><refentrytitle>abort</refentrytitle> 1.784 + <manvolnum>3</manvolnum></citerefentry> in these cases. This option is 1.785 + disabled by default unless <option>--enable-debug</option> is 1.786 + specified during configuration, in which case it is enabled by default. 1.787 + </para></listitem> 1.788 + </varlistentry> 1.789 + 1.790 + <varlistentry id="opt.lg_chunk"> 1.791 + <term> 1.792 + <mallctl>opt.lg_chunk</mallctl> 1.793 + (<type>size_t</type>) 1.794 + <literal>r-</literal> 1.795 + </term> 1.796 + <listitem><para>Virtual memory chunk size (log base 2). The default 1.797 + chunk size is 4 MiB (2^22).</para></listitem> 1.798 + </varlistentry> 1.799 + 1.800 + <varlistentry id="opt.dss"> 1.801 + <term> 1.802 + <mallctl>opt.dss</mallctl> 1.803 + (<type>const char *</type>) 1.804 + <literal>r-</literal> 1.805 + </term> 1.806 + <listitem><para>dss (<citerefentry><refentrytitle>sbrk</refentrytitle> 1.807 + <manvolnum>2</manvolnum></citerefentry>) allocation precedence as 1.808 + related to <citerefentry><refentrytitle>mmap</refentrytitle> 1.809 + <manvolnum>2</manvolnum></citerefentry> allocation. The following 1.810 + settings are supported: “disabled”, “primary”, 1.811 + and “secondary” (default).</para></listitem> 1.812 + </varlistentry> 1.813 + 1.814 + <varlistentry id="opt.narenas"> 1.815 + <term> 1.816 + <mallctl>opt.narenas</mallctl> 1.817 + (<type>size_t</type>) 1.818 + <literal>r-</literal> 1.819 + </term> 1.820 + <listitem><para>Maximum number of arenas to use for automatic 1.821 + multiplexing of threads and arenas. The default is four times the 1.822 + number of CPUs, or one if there is a single CPU.</para></listitem> 1.823 + </varlistentry> 1.824 + 1.825 + <varlistentry id="opt.lg_dirty_mult"> 1.826 + <term> 1.827 + <mallctl>opt.lg_dirty_mult</mallctl> 1.828 + (<type>ssize_t</type>) 1.829 + <literal>r-</literal> 1.830 + </term> 1.831 + <listitem><para>Per-arena minimum ratio (log base 2) of active to dirty 1.832 + pages. Some dirty unused pages may be allowed to accumulate, within 1.833 + the limit set by the ratio (or one chunk worth of dirty pages, 1.834 + whichever is greater), before informing the kernel about some of those 1.835 + pages via <citerefentry><refentrytitle>madvise</refentrytitle> 1.836 + <manvolnum>2</manvolnum></citerefentry> or a similar system call. This 1.837 + provides the kernel with sufficient information to recycle dirty pages 1.838 + if physical memory becomes scarce and the pages remain unused. The 1.839 + default minimum ratio is 8:1 (2^3:1); an option value of -1 will 1.840 + disable dirty page purging.</para></listitem> 1.841 + </varlistentry> 1.842 + 1.843 + <varlistentry id="opt.stats_print"> 1.844 + <term> 1.845 + <mallctl>opt.stats_print</mallctl> 1.846 + (<type>bool</type>) 1.847 + <literal>r-</literal> 1.848 + </term> 1.849 + <listitem><para>Enable/disable statistics printing at exit. If 1.850 + enabled, the <function>malloc_stats_print<parameter/></function> 1.851 + function is called at program exit via an 1.852 + <citerefentry><refentrytitle>atexit</refentrytitle> 1.853 + <manvolnum>3</manvolnum></citerefentry> function. If 1.854 + <option>--enable-stats</option> is specified during configuration, this 1.855 + has the potential to cause deadlock for a multi-threaded process that 1.856 + exits while one or more threads are executing in the memory allocation 1.857 + functions. Therefore, this option should only be used with care; it is 1.858 + primarily intended as a performance tuning aid during application 1.859 + development. This option is disabled by default.</para></listitem> 1.860 + </varlistentry> 1.861 + 1.862 + <varlistentry id="opt.junk"> 1.863 + <term> 1.864 + <mallctl>opt.junk</mallctl> 1.865 + (<type>bool</type>) 1.866 + <literal>r-</literal> 1.867 + [<option>--enable-fill</option>] 1.868 + </term> 1.869 + <listitem><para>Junk filling enabled/disabled. If enabled, each byte 1.870 + of uninitialized allocated memory will be initialized to 1.871 + <literal>0xa5</literal>. All deallocated memory will be initialized to 1.872 + <literal>0x5a</literal>. This is intended for debugging and will 1.873 + impact performance negatively. This option is disabled by default 1.874 + unless <option>--enable-debug</option> is specified during 1.875 + configuration, in which case it is enabled by default unless running 1.876 + inside <ulink 1.877 + url="http://valgrind.org/">Valgrind</ulink>.</para></listitem> 1.878 + </varlistentry> 1.879 + 1.880 + <varlistentry id="opt.quarantine"> 1.881 + <term> 1.882 + <mallctl>opt.quarantine</mallctl> 1.883 + (<type>size_t</type>) 1.884 + <literal>r-</literal> 1.885 + [<option>--enable-fill</option>] 1.886 + </term> 1.887 + <listitem><para>Per thread quarantine size in bytes. If non-zero, each 1.888 + thread maintains a FIFO object quarantine that stores up to the 1.889 + specified number of bytes of memory. The quarantined memory is not 1.890 + freed until it is released from quarantine, though it is immediately 1.891 + junk-filled if the <link 1.892 + linkend="opt.junk"><mallctl>opt.junk</mallctl></link> option is 1.893 + enabled. This feature is of particular use in combination with <ulink 1.894 + url="http://valgrind.org/">Valgrind</ulink>, which can detect attempts 1.895 + to access quarantined objects. This is intended for debugging and will 1.896 + impact performance negatively. The default quarantine size is 0 unless 1.897 + running inside Valgrind, in which case the default is 16 1.898 + MiB.</para></listitem> 1.899 + </varlistentry> 1.900 + 1.901 + <varlistentry id="opt.redzone"> 1.902 + <term> 1.903 + <mallctl>opt.redzone</mallctl> 1.904 + (<type>bool</type>) 1.905 + <literal>r-</literal> 1.906 + [<option>--enable-fill</option>] 1.907 + </term> 1.908 + <listitem><para>Redzones enabled/disabled. If enabled, small 1.909 + allocations have redzones before and after them. Furthermore, if the 1.910 + <link linkend="opt.junk"><mallctl>opt.junk</mallctl></link> option is 1.911 + enabled, the redzones are checked for corruption during deallocation. 1.912 + However, the primary intended purpose of this feature is to be used in 1.913 + combination with <ulink url="http://valgrind.org/">Valgrind</ulink>, 1.914 + which needs redzones in order to do effective buffer overflow/underflow 1.915 + detection. This option is intended for debugging and will impact 1.916 + performance negatively. This option is disabled by 1.917 + default unless running inside Valgrind.</para></listitem> 1.918 + </varlistentry> 1.919 + 1.920 + <varlistentry id="opt.zero"> 1.921 + <term> 1.922 + <mallctl>opt.zero</mallctl> 1.923 + (<type>bool</type>) 1.924 + <literal>r-</literal> 1.925 + [<option>--enable-fill</option>] 1.926 + </term> 1.927 + <listitem><para>Zero filling enabled/disabled. If enabled, each byte 1.928 + of uninitialized allocated memory will be initialized to 0. Note that 1.929 + this initialization only happens once for each byte, so 1.930 + <function>realloc<parameter/></function> and 1.931 + <function>rallocm<parameter/></function> calls do not zero memory that 1.932 + was previously allocated. This is intended for debugging and will 1.933 + impact performance negatively. This option is disabled by default. 1.934 + </para></listitem> 1.935 + </varlistentry> 1.936 + 1.937 + <varlistentry id="opt.utrace"> 1.938 + <term> 1.939 + <mallctl>opt.utrace</mallctl> 1.940 + (<type>bool</type>) 1.941 + <literal>r-</literal> 1.942 + [<option>--enable-utrace</option>] 1.943 + </term> 1.944 + <listitem><para>Allocation tracing based on 1.945 + <citerefentry><refentrytitle>utrace</refentrytitle> 1.946 + <manvolnum>2</manvolnum></citerefentry> enabled/disabled. This option 1.947 + is disabled by default.</para></listitem> 1.948 + </varlistentry> 1.949 + 1.950 + <varlistentry id="opt.valgrind"> 1.951 + <term> 1.952 + <mallctl>opt.valgrind</mallctl> 1.953 + (<type>bool</type>) 1.954 + <literal>r-</literal> 1.955 + [<option>--enable-valgrind</option>] 1.956 + </term> 1.957 + <listitem><para><ulink url="http://valgrind.org/">Valgrind</ulink> 1.958 + support enabled/disabled. This option is vestigal because jemalloc 1.959 + auto-detects whether it is running inside Valgrind. This option is 1.960 + disabled by default, unless running inside Valgrind.</para></listitem> 1.961 + </varlistentry> 1.962 + 1.963 + <varlistentry id="opt.xmalloc"> 1.964 + <term> 1.965 + <mallctl>opt.xmalloc</mallctl> 1.966 + (<type>bool</type>) 1.967 + <literal>r-</literal> 1.968 + [<option>--enable-xmalloc</option>] 1.969 + </term> 1.970 + <listitem><para>Abort-on-out-of-memory enabled/disabled. If enabled, 1.971 + rather than returning failure for any allocation function, display a 1.972 + diagnostic message on <constant>STDERR_FILENO</constant> and cause the 1.973 + program to drop core (using 1.974 + <citerefentry><refentrytitle>abort</refentrytitle> 1.975 + <manvolnum>3</manvolnum></citerefentry>). If an application is 1.976 + designed to depend on this behavior, set the option at compile time by 1.977 + including the following in the source code: 1.978 + <programlisting language="C"><![CDATA[ 1.979 +malloc_conf = "xmalloc:true";]]></programlisting> 1.980 + This option is disabled by default.</para></listitem> 1.981 + </varlistentry> 1.982 + 1.983 + <varlistentry id="opt.tcache"> 1.984 + <term> 1.985 + <mallctl>opt.tcache</mallctl> 1.986 + (<type>bool</type>) 1.987 + <literal>r-</literal> 1.988 + [<option>--enable-tcache</option>] 1.989 + </term> 1.990 + <listitem><para>Thread-specific caching enabled/disabled. When there 1.991 + are multiple threads, each thread uses a thread-specific cache for 1.992 + objects up to a certain size. Thread-specific caching allows many 1.993 + allocations to be satisfied without performing any thread 1.994 + synchronization, at the cost of increased memory use. See the 1.995 + <link 1.996 + linkend="opt.lg_tcache_max"><mallctl>opt.lg_tcache_max</mallctl></link> 1.997 + option for related tuning information. This option is enabled by 1.998 + default unless running inside <ulink 1.999 + url="http://valgrind.org/">Valgrind</ulink>.</para></listitem> 1.1000 + </varlistentry> 1.1001 + 1.1002 + <varlistentry id="opt.lg_tcache_max"> 1.1003 + <term> 1.1004 + <mallctl>opt.lg_tcache_max</mallctl> 1.1005 + (<type>size_t</type>) 1.1006 + <literal>r-</literal> 1.1007 + [<option>--enable-tcache</option>] 1.1008 + </term> 1.1009 + <listitem><para>Maximum size class (log base 2) to cache in the 1.1010 + thread-specific cache. At a minimum, all small size classes are 1.1011 + cached, and at a maximum all large size classes are cached. The 1.1012 + default maximum is 32 KiB (2^15).</para></listitem> 1.1013 + </varlistentry> 1.1014 + 1.1015 + <varlistentry id="opt.prof"> 1.1016 + <term> 1.1017 + <mallctl>opt.prof</mallctl> 1.1018 + (<type>bool</type>) 1.1019 + <literal>r-</literal> 1.1020 + [<option>--enable-prof</option>] 1.1021 + </term> 1.1022 + <listitem><para>Memory profiling enabled/disabled. If enabled, profile 1.1023 + memory allocation activity. See the <link 1.1024 + linkend="opt.prof_active"><mallctl>opt.prof_active</mallctl></link> 1.1025 + option for on-the-fly activation/deactivation. See the <link 1.1026 + linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link> 1.1027 + option for probabilistic sampling control. See the <link 1.1028 + linkend="opt.prof_accum"><mallctl>opt.prof_accum</mallctl></link> 1.1029 + option for control of cumulative sample reporting. See the <link 1.1030 + linkend="opt.lg_prof_interval"><mallctl>opt.lg_prof_interval</mallctl></link> 1.1031 + option for information on interval-triggered profile dumping, the <link 1.1032 + linkend="opt.prof_gdump"><mallctl>opt.prof_gdump</mallctl></link> 1.1033 + option for information on high-water-triggered profile dumping, and the 1.1034 + <link linkend="opt.prof_final"><mallctl>opt.prof_final</mallctl></link> 1.1035 + option for final profile dumping. Profile output is compatible with 1.1036 + the included <command>pprof</command> Perl script, which originates 1.1037 + from the <ulink url="http://code.google.com/p/gperftools/">gperftools 1.1038 + package</ulink>.</para></listitem> 1.1039 + </varlistentry> 1.1040 + 1.1041 + <varlistentry id="opt.prof_prefix"> 1.1042 + <term> 1.1043 + <mallctl>opt.prof_prefix</mallctl> 1.1044 + (<type>const char *</type>) 1.1045 + <literal>r-</literal> 1.1046 + [<option>--enable-prof</option>] 1.1047 + </term> 1.1048 + <listitem><para>Filename prefix for profile dumps. If the prefix is 1.1049 + set to the empty string, no automatic dumps will occur; this is 1.1050 + primarily useful for disabling the automatic final heap dump (which 1.1051 + also disables leak reporting, if enabled). The default prefix is 1.1052 + <filename>jeprof</filename>.</para></listitem> 1.1053 + </varlistentry> 1.1054 + 1.1055 + <varlistentry id="opt.prof_active"> 1.1056 + <term> 1.1057 + <mallctl>opt.prof_active</mallctl> 1.1058 + (<type>bool</type>) 1.1059 + <literal>r-</literal> 1.1060 + [<option>--enable-prof</option>] 1.1061 + </term> 1.1062 + <listitem><para>Profiling activated/deactivated. This is a secondary 1.1063 + control mechanism that makes it possible to start the application with 1.1064 + profiling enabled (see the <link 1.1065 + linkend="opt.prof"><mallctl>opt.prof</mallctl></link> option) but 1.1066 + inactive, then toggle profiling at any time during program execution 1.1067 + with the <link 1.1068 + linkend="prof.active"><mallctl>prof.active</mallctl></link> mallctl. 1.1069 + This option is enabled by default.</para></listitem> 1.1070 + </varlistentry> 1.1071 + 1.1072 + <varlistentry id="opt.lg_prof_sample"> 1.1073 + <term> 1.1074 + <mallctl>opt.lg_prof_sample</mallctl> 1.1075 + (<type>ssize_t</type>) 1.1076 + <literal>r-</literal> 1.1077 + [<option>--enable-prof</option>] 1.1078 + </term> 1.1079 + <listitem><para>Average interval (log base 2) between allocation 1.1080 + samples, as measured in bytes of allocation activity. Increasing the 1.1081 + sampling interval decreases profile fidelity, but also decreases the 1.1082 + computational overhead. The default sample interval is 512 KiB (2^19 1.1083 + B).</para></listitem> 1.1084 + </varlistentry> 1.1085 + 1.1086 + <varlistentry id="opt.prof_accum"> 1.1087 + <term> 1.1088 + <mallctl>opt.prof_accum</mallctl> 1.1089 + (<type>bool</type>) 1.1090 + <literal>r-</literal> 1.1091 + [<option>--enable-prof</option>] 1.1092 + </term> 1.1093 + <listitem><para>Reporting of cumulative object/byte counts in profile 1.1094 + dumps enabled/disabled. If this option is enabled, every unique 1.1095 + backtrace must be stored for the duration of execution. Depending on 1.1096 + the application, this can impose a large memory overhead, and the 1.1097 + cumulative counts are not always of interest. This option is disabled 1.1098 + by default.</para></listitem> 1.1099 + </varlistentry> 1.1100 + 1.1101 + <varlistentry id="opt.lg_prof_interval"> 1.1102 + <term> 1.1103 + <mallctl>opt.lg_prof_interval</mallctl> 1.1104 + (<type>ssize_t</type>) 1.1105 + <literal>r-</literal> 1.1106 + [<option>--enable-prof</option>] 1.1107 + </term> 1.1108 + <listitem><para>Average interval (log base 2) between memory profile 1.1109 + dumps, as measured in bytes of allocation activity. The actual 1.1110 + interval between dumps may be sporadic because decentralized allocation 1.1111 + counters are used to avoid synchronization bottlenecks. Profiles are 1.1112 + dumped to files named according to the pattern 1.1113 + <filename><prefix>.<pid>.<seq>.i<iseq>.heap</filename>, 1.1114 + where <literal><prefix></literal> is controlled by the 1.1115 + <link 1.1116 + linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> 1.1117 + option. By default, interval-triggered profile dumping is disabled 1.1118 + (encoded as -1). 1.1119 + </para></listitem> 1.1120 + </varlistentry> 1.1121 + 1.1122 + <varlistentry id="opt.prof_gdump"> 1.1123 + <term> 1.1124 + <mallctl>opt.prof_gdump</mallctl> 1.1125 + (<type>bool</type>) 1.1126 + <literal>r-</literal> 1.1127 + [<option>--enable-prof</option>] 1.1128 + </term> 1.1129 + <listitem><para>Trigger a memory profile dump every time the total 1.1130 + virtual memory exceeds the previous maximum. Profiles are dumped to 1.1131 + files named according to the pattern 1.1132 + <filename><prefix>.<pid>.<seq>.u<useq>.heap</filename>, 1.1133 + where <literal><prefix></literal> is controlled by the <link 1.1134 + linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> 1.1135 + option. This option is disabled by default.</para></listitem> 1.1136 + </varlistentry> 1.1137 + 1.1138 + <varlistentry id="opt.prof_final"> 1.1139 + <term> 1.1140 + <mallctl>opt.prof_final</mallctl> 1.1141 + (<type>bool</type>) 1.1142 + <literal>r-</literal> 1.1143 + [<option>--enable-prof</option>] 1.1144 + </term> 1.1145 + <listitem><para>Use an 1.1146 + <citerefentry><refentrytitle>atexit</refentrytitle> 1.1147 + <manvolnum>3</manvolnum></citerefentry> function to dump final memory 1.1148 + usage to a file named according to the pattern 1.1149 + <filename><prefix>.<pid>.<seq>.f.heap</filename>, 1.1150 + where <literal><prefix></literal> is controlled by the <link 1.1151 + linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> 1.1152 + option. This option is enabled by default.</para></listitem> 1.1153 + </varlistentry> 1.1154 + 1.1155 + <varlistentry id="opt.prof_leak"> 1.1156 + <term> 1.1157 + <mallctl>opt.prof_leak</mallctl> 1.1158 + (<type>bool</type>) 1.1159 + <literal>r-</literal> 1.1160 + [<option>--enable-prof</option>] 1.1161 + </term> 1.1162 + <listitem><para>Leak reporting enabled/disabled. If enabled, use an 1.1163 + <citerefentry><refentrytitle>atexit</refentrytitle> 1.1164 + <manvolnum>3</manvolnum></citerefentry> function to report memory leaks 1.1165 + detected by allocation sampling. See the 1.1166 + <link linkend="opt.prof"><mallctl>opt.prof</mallctl></link> option for 1.1167 + information on analyzing heap profile output. This option is disabled 1.1168 + by default.</para></listitem> 1.1169 + </varlistentry> 1.1170 + 1.1171 + <varlistentry> 1.1172 + <term> 1.1173 + <mallctl>thread.arena</mallctl> 1.1174 + (<type>unsigned</type>) 1.1175 + <literal>rw</literal> 1.1176 + </term> 1.1177 + <listitem><para>Get or set the arena associated with the calling 1.1178 + thread. If the specified arena was not initialized beforehand (see the 1.1179 + <link 1.1180 + linkend="arenas.initialized"><mallctl>arenas.initialized</mallctl></link> 1.1181 + mallctl), it will be automatically initialized as a side effect of 1.1182 + calling this interface.</para></listitem> 1.1183 + </varlistentry> 1.1184 + 1.1185 + <varlistentry id="thread.allocated"> 1.1186 + <term> 1.1187 + <mallctl>thread.allocated</mallctl> 1.1188 + (<type>uint64_t</type>) 1.1189 + <literal>r-</literal> 1.1190 + [<option>--enable-stats</option>] 1.1191 + </term> 1.1192 + <listitem><para>Get the total number of bytes ever allocated by the 1.1193 + calling thread. This counter has the potential to wrap around; it is 1.1194 + up to the application to appropriately interpret the counter in such 1.1195 + cases.</para></listitem> 1.1196 + </varlistentry> 1.1197 + 1.1198 + <varlistentry> 1.1199 + <term> 1.1200 + <mallctl>thread.allocatedp</mallctl> 1.1201 + (<type>uint64_t *</type>) 1.1202 + <literal>r-</literal> 1.1203 + [<option>--enable-stats</option>] 1.1204 + </term> 1.1205 + <listitem><para>Get a pointer to the the value that is returned by the 1.1206 + <link 1.1207 + linkend="thread.allocated"><mallctl>thread.allocated</mallctl></link> 1.1208 + mallctl. This is useful for avoiding the overhead of repeated 1.1209 + <function>mallctl*<parameter/></function> calls.</para></listitem> 1.1210 + </varlistentry> 1.1211 + 1.1212 + <varlistentry id="thread.deallocated"> 1.1213 + <term> 1.1214 + <mallctl>thread.deallocated</mallctl> 1.1215 + (<type>uint64_t</type>) 1.1216 + <literal>r-</literal> 1.1217 + [<option>--enable-stats</option>] 1.1218 + </term> 1.1219 + <listitem><para>Get the total number of bytes ever deallocated by the 1.1220 + calling thread. This counter has the potential to wrap around; it is 1.1221 + up to the application to appropriately interpret the counter in such 1.1222 + cases.</para></listitem> 1.1223 + </varlistentry> 1.1224 + 1.1225 + <varlistentry> 1.1226 + <term> 1.1227 + <mallctl>thread.deallocatedp</mallctl> 1.1228 + (<type>uint64_t *</type>) 1.1229 + <literal>r-</literal> 1.1230 + [<option>--enable-stats</option>] 1.1231 + </term> 1.1232 + <listitem><para>Get a pointer to the the value that is returned by the 1.1233 + <link 1.1234 + linkend="thread.deallocated"><mallctl>thread.deallocated</mallctl></link> 1.1235 + mallctl. This is useful for avoiding the overhead of repeated 1.1236 + <function>mallctl*<parameter/></function> calls.</para></listitem> 1.1237 + </varlistentry> 1.1238 + 1.1239 + <varlistentry> 1.1240 + <term> 1.1241 + <mallctl>thread.tcache.enabled</mallctl> 1.1242 + (<type>bool</type>) 1.1243 + <literal>rw</literal> 1.1244 + [<option>--enable-tcache</option>] 1.1245 + </term> 1.1246 + <listitem><para>Enable/disable calling thread's tcache. The tcache is 1.1247 + implicitly flushed as a side effect of becoming 1.1248 + disabled (see <link 1.1249 + lenkend="thread.tcache.flush"><mallctl>thread.tcache.flush</mallctl></link>). 1.1250 + </para></listitem> 1.1251 + </varlistentry> 1.1252 + 1.1253 + <varlistentry> 1.1254 + <term> 1.1255 + <mallctl>thread.tcache.flush</mallctl> 1.1256 + (<type>void</type>) 1.1257 + <literal>--</literal> 1.1258 + [<option>--enable-tcache</option>] 1.1259 + </term> 1.1260 + <listitem><para>Flush calling thread's tcache. This interface releases 1.1261 + all cached objects and internal data structures associated with the 1.1262 + calling thread's thread-specific cache. Ordinarily, this interface 1.1263 + need not be called, since automatic periodic incremental garbage 1.1264 + collection occurs, and the thread cache is automatically discarded when 1.1265 + a thread exits. However, garbage collection is triggered by allocation 1.1266 + activity, so it is possible for a thread that stops 1.1267 + allocating/deallocating to retain its cache indefinitely, in which case 1.1268 + the developer may find manual flushing useful.</para></listitem> 1.1269 + </varlistentry> 1.1270 + 1.1271 + <varlistentry id="arena.i.purge"> 1.1272 + <term> 1.1273 + <mallctl>arena.<i>.purge</mallctl> 1.1274 + (<type>unsigned</type>) 1.1275 + <literal>--</literal> 1.1276 + </term> 1.1277 + <listitem><para>Purge unused dirty pages for arena <i>, or for 1.1278 + all arenas if <i> equals <link 1.1279 + linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link>. 1.1280 + </para></listitem> 1.1281 + </varlistentry> 1.1282 + 1.1283 + <varlistentry id="arena.i.dss"> 1.1284 + <term> 1.1285 + <mallctl>arena.<i>.dss</mallctl> 1.1286 + (<type>const char *</type>) 1.1287 + <literal>rw</literal> 1.1288 + </term> 1.1289 + <listitem><para>Set the precedence of dss allocation as related to mmap 1.1290 + allocation for arena <i>, or for all arenas if <i> equals 1.1291 + <link 1.1292 + linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link>. See 1.1293 + <link linkend="opt.dss"><mallctl>opt.dss</mallctl></link> for supported 1.1294 + settings. 1.1295 + </para></listitem> 1.1296 + </varlistentry> 1.1297 + 1.1298 + <varlistentry id="arenas.narenas"> 1.1299 + <term> 1.1300 + <mallctl>arenas.narenas</mallctl> 1.1301 + (<type>unsigned</type>) 1.1302 + <literal>r-</literal> 1.1303 + </term> 1.1304 + <listitem><para>Current limit on number of arenas.</para></listitem> 1.1305 + </varlistentry> 1.1306 + 1.1307 + <varlistentry id="arenas.initialized"> 1.1308 + <term> 1.1309 + <mallctl>arenas.initialized</mallctl> 1.1310 + (<type>bool *</type>) 1.1311 + <literal>r-</literal> 1.1312 + </term> 1.1313 + <listitem><para>An array of <link 1.1314 + linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link> 1.1315 + booleans. Each boolean indicates whether the corresponding arena is 1.1316 + initialized.</para></listitem> 1.1317 + </varlistentry> 1.1318 + 1.1319 + <varlistentry> 1.1320 + <term> 1.1321 + <mallctl>arenas.quantum</mallctl> 1.1322 + (<type>size_t</type>) 1.1323 + <literal>r-</literal> 1.1324 + </term> 1.1325 + <listitem><para>Quantum size.</para></listitem> 1.1326 + </varlistentry> 1.1327 + 1.1328 + <varlistentry> 1.1329 + <term> 1.1330 + <mallctl>arenas.page</mallctl> 1.1331 + (<type>size_t</type>) 1.1332 + <literal>r-</literal> 1.1333 + </term> 1.1334 + <listitem><para>Page size.</para></listitem> 1.1335 + </varlistentry> 1.1336 + 1.1337 + <varlistentry> 1.1338 + <term> 1.1339 + <mallctl>arenas.tcache_max</mallctl> 1.1340 + (<type>size_t</type>) 1.1341 + <literal>r-</literal> 1.1342 + [<option>--enable-tcache</option>] 1.1343 + </term> 1.1344 + <listitem><para>Maximum thread-cached size class.</para></listitem> 1.1345 + </varlistentry> 1.1346 + 1.1347 + <varlistentry> 1.1348 + <term> 1.1349 + <mallctl>arenas.nbins</mallctl> 1.1350 + (<type>unsigned</type>) 1.1351 + <literal>r-</literal> 1.1352 + </term> 1.1353 + <listitem><para>Number of bin size classes.</para></listitem> 1.1354 + </varlistentry> 1.1355 + 1.1356 + <varlistentry> 1.1357 + <term> 1.1358 + <mallctl>arenas.nhbins</mallctl> 1.1359 + (<type>unsigned</type>) 1.1360 + <literal>r-</literal> 1.1361 + [<option>--enable-tcache</option>] 1.1362 + </term> 1.1363 + <listitem><para>Total number of thread cache bin size 1.1364 + classes.</para></listitem> 1.1365 + </varlistentry> 1.1366 + 1.1367 + <varlistentry id="arenas.bin.i.size"> 1.1368 + <term> 1.1369 + <mallctl>arenas.bin.<i>.size</mallctl> 1.1370 + (<type>size_t</type>) 1.1371 + <literal>r-</literal> 1.1372 + </term> 1.1373 + <listitem><para>Maximum size supported by size class.</para></listitem> 1.1374 + </varlistentry> 1.1375 + 1.1376 + <varlistentry> 1.1377 + <term> 1.1378 + <mallctl>arenas.bin.<i>.nregs</mallctl> 1.1379 + (<type>uint32_t</type>) 1.1380 + <literal>r-</literal> 1.1381 + </term> 1.1382 + <listitem><para>Number of regions per page run.</para></listitem> 1.1383 + </varlistentry> 1.1384 + 1.1385 + <varlistentry> 1.1386 + <term> 1.1387 + <mallctl>arenas.bin.<i>.run_size</mallctl> 1.1388 + (<type>size_t</type>) 1.1389 + <literal>r-</literal> 1.1390 + </term> 1.1391 + <listitem><para>Number of bytes per page run.</para></listitem> 1.1392 + </varlistentry> 1.1393 + 1.1394 + <varlistentry> 1.1395 + <term> 1.1396 + <mallctl>arenas.nlruns</mallctl> 1.1397 + (<type>size_t</type>) 1.1398 + <literal>r-</literal> 1.1399 + </term> 1.1400 + <listitem><para>Total number of large size classes.</para></listitem> 1.1401 + </varlistentry> 1.1402 + 1.1403 + <varlistentry> 1.1404 + <term> 1.1405 + <mallctl>arenas.lrun.<i>.size</mallctl> 1.1406 + (<type>size_t</type>) 1.1407 + <literal>r-</literal> 1.1408 + </term> 1.1409 + <listitem><para>Maximum size supported by this large size 1.1410 + class.</para></listitem> 1.1411 + </varlistentry> 1.1412 + 1.1413 + <varlistentry> 1.1414 + <term> 1.1415 + <mallctl>arenas.purge</mallctl> 1.1416 + (<type>unsigned</type>) 1.1417 + <literal>-w</literal> 1.1418 + </term> 1.1419 + <listitem><para>Purge unused dirty pages for the specified arena, or 1.1420 + for all arenas if none is specified.</para></listitem> 1.1421 + </varlistentry> 1.1422 + 1.1423 + <varlistentry> 1.1424 + <term> 1.1425 + <mallctl>arenas.extend</mallctl> 1.1426 + (<type>unsigned</type>) 1.1427 + <literal>r-</literal> 1.1428 + </term> 1.1429 + <listitem><para>Extend the array of arenas by appending a new arena, 1.1430 + and returning the new arena index.</para></listitem> 1.1431 + </varlistentry> 1.1432 + 1.1433 + <varlistentry id="prof.active"> 1.1434 + <term> 1.1435 + <mallctl>prof.active</mallctl> 1.1436 + (<type>bool</type>) 1.1437 + <literal>rw</literal> 1.1438 + [<option>--enable-prof</option>] 1.1439 + </term> 1.1440 + <listitem><para>Control whether sampling is currently active. See the 1.1441 + <link 1.1442 + linkend="opt.prof_active"><mallctl>opt.prof_active</mallctl></link> 1.1443 + option for additional information. 1.1444 + </para></listitem> 1.1445 + </varlistentry> 1.1446 + 1.1447 + <varlistentry> 1.1448 + <term> 1.1449 + <mallctl>prof.dump</mallctl> 1.1450 + (<type>const char *</type>) 1.1451 + <literal>-w</literal> 1.1452 + [<option>--enable-prof</option>] 1.1453 + </term> 1.1454 + <listitem><para>Dump a memory profile to the specified file, or if NULL 1.1455 + is specified, to a file according to the pattern 1.1456 + <filename><prefix>.<pid>.<seq>.m<mseq>.heap</filename>, 1.1457 + where <literal><prefix></literal> is controlled by the 1.1458 + <link 1.1459 + linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> 1.1460 + option.</para></listitem> 1.1461 + </varlistentry> 1.1462 + 1.1463 + <varlistentry> 1.1464 + <term> 1.1465 + <mallctl>prof.interval</mallctl> 1.1466 + (<type>uint64_t</type>) 1.1467 + <literal>r-</literal> 1.1468 + [<option>--enable-prof</option>] 1.1469 + </term> 1.1470 + <listitem><para>Average number of bytes allocated between 1.1471 + inverval-based profile dumps. See the 1.1472 + <link 1.1473 + linkend="opt.lg_prof_interval"><mallctl>opt.lg_prof_interval</mallctl></link> 1.1474 + option for additional information.</para></listitem> 1.1475 + </varlistentry> 1.1476 + 1.1477 + <varlistentry id="stats.cactive"> 1.1478 + <term> 1.1479 + <mallctl>stats.cactive</mallctl> 1.1480 + (<type>size_t *</type>) 1.1481 + <literal>r-</literal> 1.1482 + [<option>--enable-stats</option>] 1.1483 + </term> 1.1484 + <listitem><para>Pointer to a counter that contains an approximate count 1.1485 + of the current number of bytes in active pages. The estimate may be 1.1486 + high, but never low, because each arena rounds up to the nearest 1.1487 + multiple of the chunk size when computing its contribution to the 1.1488 + counter. Note that the <link 1.1489 + linkend="epoch"><mallctl>epoch</mallctl></link> mallctl has no bearing 1.1490 + on this counter. Furthermore, counter consistency is maintained via 1.1491 + atomic operations, so it is necessary to use an atomic operation in 1.1492 + order to guarantee a consistent read when dereferencing the pointer. 1.1493 + </para></listitem> 1.1494 + </varlistentry> 1.1495 + 1.1496 + <varlistentry id="stats.allocated"> 1.1497 + <term> 1.1498 + <mallctl>stats.allocated</mallctl> 1.1499 + (<type>size_t</type>) 1.1500 + <literal>r-</literal> 1.1501 + [<option>--enable-stats</option>] 1.1502 + </term> 1.1503 + <listitem><para>Total number of bytes allocated by the 1.1504 + application.</para></listitem> 1.1505 + </varlistentry> 1.1506 + 1.1507 + <varlistentry id="stats.active"> 1.1508 + <term> 1.1509 + <mallctl>stats.active</mallctl> 1.1510 + (<type>size_t</type>) 1.1511 + <literal>r-</literal> 1.1512 + [<option>--enable-stats</option>] 1.1513 + </term> 1.1514 + <listitem><para>Total number of bytes in active pages allocated by the 1.1515 + application. This is a multiple of the page size, and greater than or 1.1516 + equal to <link 1.1517 + linkend="stats.allocated"><mallctl>stats.allocated</mallctl></link>. 1.1518 + This does not include <link linkend="stats.arenas.i.pdirty"> 1.1519 + <mallctl>stats.arenas.<i>.pdirty</mallctl></link> and pages 1.1520 + entirely devoted to allocator metadata.</para></listitem> 1.1521 + </varlistentry> 1.1522 + 1.1523 + <varlistentry> 1.1524 + <term> 1.1525 + <mallctl>stats.mapped</mallctl> 1.1526 + (<type>size_t</type>) 1.1527 + <literal>r-</literal> 1.1528 + [<option>--enable-stats</option>] 1.1529 + </term> 1.1530 + <listitem><para>Total number of bytes in chunks mapped on behalf of the 1.1531 + application. This is a multiple of the chunk size, and is at least as 1.1532 + large as <link 1.1533 + linkend="stats.active"><mallctl>stats.active</mallctl></link>. This 1.1534 + does not include inactive chunks.</para></listitem> 1.1535 + </varlistentry> 1.1536 + 1.1537 + <varlistentry> 1.1538 + <term> 1.1539 + <mallctl>stats.chunks.current</mallctl> 1.1540 + (<type>size_t</type>) 1.1541 + <literal>r-</literal> 1.1542 + [<option>--enable-stats</option>] 1.1543 + </term> 1.1544 + <listitem><para>Total number of chunks actively mapped on behalf of the 1.1545 + application. This does not include inactive chunks. 1.1546 + </para></listitem> 1.1547 + </varlistentry> 1.1548 + 1.1549 + <varlistentry> 1.1550 + <term> 1.1551 + <mallctl>stats.chunks.total</mallctl> 1.1552 + (<type>uint64_t</type>) 1.1553 + <literal>r-</literal> 1.1554 + [<option>--enable-stats</option>] 1.1555 + </term> 1.1556 + <listitem><para>Cumulative number of chunks allocated.</para></listitem> 1.1557 + </varlistentry> 1.1558 + 1.1559 + <varlistentry> 1.1560 + <term> 1.1561 + <mallctl>stats.chunks.high</mallctl> 1.1562 + (<type>size_t</type>) 1.1563 + <literal>r-</literal> 1.1564 + [<option>--enable-stats</option>] 1.1565 + </term> 1.1566 + <listitem><para>Maximum number of active chunks at any time thus far. 1.1567 + </para></listitem> 1.1568 + </varlistentry> 1.1569 + 1.1570 + <varlistentry> 1.1571 + <term> 1.1572 + <mallctl>stats.huge.allocated</mallctl> 1.1573 + (<type>size_t</type>) 1.1574 + <literal>r-</literal> 1.1575 + [<option>--enable-stats</option>] 1.1576 + </term> 1.1577 + <listitem><para>Number of bytes currently allocated by huge objects. 1.1578 + </para></listitem> 1.1579 + </varlistentry> 1.1580 + 1.1581 + <varlistentry> 1.1582 + <term> 1.1583 + <mallctl>stats.huge.nmalloc</mallctl> 1.1584 + (<type>uint64_t</type>) 1.1585 + <literal>r-</literal> 1.1586 + [<option>--enable-stats</option>] 1.1587 + </term> 1.1588 + <listitem><para>Cumulative number of huge allocation requests. 1.1589 + </para></listitem> 1.1590 + </varlistentry> 1.1591 + 1.1592 + <varlistentry> 1.1593 + <term> 1.1594 + <mallctl>stats.huge.ndalloc</mallctl> 1.1595 + (<type>uint64_t</type>) 1.1596 + <literal>r-</literal> 1.1597 + [<option>--enable-stats</option>] 1.1598 + </term> 1.1599 + <listitem><para>Cumulative number of huge deallocation requests. 1.1600 + </para></listitem> 1.1601 + </varlistentry> 1.1602 + 1.1603 + <varlistentry> 1.1604 + <term> 1.1605 + <mallctl>stats.arenas.<i>.dss</mallctl> 1.1606 + (<type>const char *</type>) 1.1607 + <literal>r-</literal> 1.1608 + </term> 1.1609 + <listitem><para>dss (<citerefentry><refentrytitle>sbrk</refentrytitle> 1.1610 + <manvolnum>2</manvolnum></citerefentry>) allocation precedence as 1.1611 + related to <citerefentry><refentrytitle>mmap</refentrytitle> 1.1612 + <manvolnum>2</manvolnum></citerefentry> allocation. See <link 1.1613 + linkend="opt.dss"><mallctl>opt.dss</mallctl></link> for details. 1.1614 + </para></listitem> 1.1615 + </varlistentry> 1.1616 + 1.1617 + <varlistentry> 1.1618 + <term> 1.1619 + <mallctl>stats.arenas.<i>.nthreads</mallctl> 1.1620 + (<type>unsigned</type>) 1.1621 + <literal>r-</literal> 1.1622 + </term> 1.1623 + <listitem><para>Number of threads currently assigned to 1.1624 + arena.</para></listitem> 1.1625 + </varlistentry> 1.1626 + 1.1627 + <varlistentry> 1.1628 + <term> 1.1629 + <mallctl>stats.arenas.<i>.pactive</mallctl> 1.1630 + (<type>size_t</type>) 1.1631 + <literal>r-</literal> 1.1632 + </term> 1.1633 + <listitem><para>Number of pages in active runs.</para></listitem> 1.1634 + </varlistentry> 1.1635 + 1.1636 + <varlistentry id="stats.arenas.i.pdirty"> 1.1637 + <term> 1.1638 + <mallctl>stats.arenas.<i>.pdirty</mallctl> 1.1639 + (<type>size_t</type>) 1.1640 + <literal>r-</literal> 1.1641 + </term> 1.1642 + <listitem><para>Number of pages within unused runs that are potentially 1.1643 + dirty, and for which <function>madvise<parameter>...</parameter> 1.1644 + <parameter><constant>MADV_DONTNEED</constant></parameter></function> or 1.1645 + similar has not been called.</para></listitem> 1.1646 + </varlistentry> 1.1647 + 1.1648 + <varlistentry> 1.1649 + <term> 1.1650 + <mallctl>stats.arenas.<i>.mapped</mallctl> 1.1651 + (<type>size_t</type>) 1.1652 + <literal>r-</literal> 1.1653 + [<option>--enable-stats</option>] 1.1654 + </term> 1.1655 + <listitem><para>Number of mapped bytes.</para></listitem> 1.1656 + </varlistentry> 1.1657 + 1.1658 + <varlistentry> 1.1659 + <term> 1.1660 + <mallctl>stats.arenas.<i>.npurge</mallctl> 1.1661 + (<type>uint64_t</type>) 1.1662 + <literal>r-</literal> 1.1663 + [<option>--enable-stats</option>] 1.1664 + </term> 1.1665 + <listitem><para>Number of dirty page purge sweeps performed. 1.1666 + </para></listitem> 1.1667 + </varlistentry> 1.1668 + 1.1669 + <varlistentry> 1.1670 + <term> 1.1671 + <mallctl>stats.arenas.<i>.nmadvise</mallctl> 1.1672 + (<type>uint64_t</type>) 1.1673 + <literal>r-</literal> 1.1674 + [<option>--enable-stats</option>] 1.1675 + </term> 1.1676 + <listitem><para>Number of <function>madvise<parameter>...</parameter> 1.1677 + <parameter><constant>MADV_DONTNEED</constant></parameter></function> or 1.1678 + similar calls made to purge dirty pages.</para></listitem> 1.1679 + </varlistentry> 1.1680 + 1.1681 + <varlistentry> 1.1682 + <term> 1.1683 + <mallctl>stats.arenas.<i>.npurged</mallctl> 1.1684 + (<type>uint64_t</type>) 1.1685 + <literal>r-</literal> 1.1686 + [<option>--enable-stats</option>] 1.1687 + </term> 1.1688 + <listitem><para>Number of pages purged.</para></listitem> 1.1689 + </varlistentry> 1.1690 + 1.1691 + <varlistentry> 1.1692 + <term> 1.1693 + <mallctl>stats.arenas.<i>.small.allocated</mallctl> 1.1694 + (<type>size_t</type>) 1.1695 + <literal>r-</literal> 1.1696 + [<option>--enable-stats</option>] 1.1697 + </term> 1.1698 + <listitem><para>Number of bytes currently allocated by small objects. 1.1699 + </para></listitem> 1.1700 + </varlistentry> 1.1701 + 1.1702 + <varlistentry> 1.1703 + <term> 1.1704 + <mallctl>stats.arenas.<i>.small.nmalloc</mallctl> 1.1705 + (<type>uint64_t</type>) 1.1706 + <literal>r-</literal> 1.1707 + [<option>--enable-stats</option>] 1.1708 + </term> 1.1709 + <listitem><para>Cumulative number of allocation requests served by 1.1710 + small bins.</para></listitem> 1.1711 + </varlistentry> 1.1712 + 1.1713 + <varlistentry> 1.1714 + <term> 1.1715 + <mallctl>stats.arenas.<i>.small.ndalloc</mallctl> 1.1716 + (<type>uint64_t</type>) 1.1717 + <literal>r-</literal> 1.1718 + [<option>--enable-stats</option>] 1.1719 + </term> 1.1720 + <listitem><para>Cumulative number of small objects returned to bins. 1.1721 + </para></listitem> 1.1722 + </varlistentry> 1.1723 + 1.1724 + <varlistentry> 1.1725 + <term> 1.1726 + <mallctl>stats.arenas.<i>.small.nrequests</mallctl> 1.1727 + (<type>uint64_t</type>) 1.1728 + <literal>r-</literal> 1.1729 + [<option>--enable-stats</option>] 1.1730 + </term> 1.1731 + <listitem><para>Cumulative number of small allocation requests. 1.1732 + </para></listitem> 1.1733 + </varlistentry> 1.1734 + 1.1735 + <varlistentry> 1.1736 + <term> 1.1737 + <mallctl>stats.arenas.<i>.large.allocated</mallctl> 1.1738 + (<type>size_t</type>) 1.1739 + <literal>r-</literal> 1.1740 + [<option>--enable-stats</option>] 1.1741 + </term> 1.1742 + <listitem><para>Number of bytes currently allocated by large objects. 1.1743 + </para></listitem> 1.1744 + </varlistentry> 1.1745 + 1.1746 + <varlistentry> 1.1747 + <term> 1.1748 + <mallctl>stats.arenas.<i>.large.nmalloc</mallctl> 1.1749 + (<type>uint64_t</type>) 1.1750 + <literal>r-</literal> 1.1751 + [<option>--enable-stats</option>] 1.1752 + </term> 1.1753 + <listitem><para>Cumulative number of large allocation requests served 1.1754 + directly by the arena.</para></listitem> 1.1755 + </varlistentry> 1.1756 + 1.1757 + <varlistentry> 1.1758 + <term> 1.1759 + <mallctl>stats.arenas.<i>.large.ndalloc</mallctl> 1.1760 + (<type>uint64_t</type>) 1.1761 + <literal>r-</literal> 1.1762 + [<option>--enable-stats</option>] 1.1763 + </term> 1.1764 + <listitem><para>Cumulative number of large deallocation requests served 1.1765 + directly by the arena.</para></listitem> 1.1766 + </varlistentry> 1.1767 + 1.1768 + <varlistentry> 1.1769 + <term> 1.1770 + <mallctl>stats.arenas.<i>.large.nrequests</mallctl> 1.1771 + (<type>uint64_t</type>) 1.1772 + <literal>r-</literal> 1.1773 + [<option>--enable-stats</option>] 1.1774 + </term> 1.1775 + <listitem><para>Cumulative number of large allocation requests. 1.1776 + </para></listitem> 1.1777 + </varlistentry> 1.1778 + 1.1779 + <varlistentry> 1.1780 + <term> 1.1781 + <mallctl>stats.arenas.<i>.bins.<j>.allocated</mallctl> 1.1782 + (<type>size_t</type>) 1.1783 + <literal>r-</literal> 1.1784 + [<option>--enable-stats</option>] 1.1785 + </term> 1.1786 + <listitem><para>Current number of bytes allocated by 1.1787 + bin.</para></listitem> 1.1788 + </varlistentry> 1.1789 + 1.1790 + <varlistentry> 1.1791 + <term> 1.1792 + <mallctl>stats.arenas.<i>.bins.<j>.nmalloc</mallctl> 1.1793 + (<type>uint64_t</type>) 1.1794 + <literal>r-</literal> 1.1795 + [<option>--enable-stats</option>] 1.1796 + </term> 1.1797 + <listitem><para>Cumulative number of allocations served by bin. 1.1798 + </para></listitem> 1.1799 + </varlistentry> 1.1800 + 1.1801 + <varlistentry> 1.1802 + <term> 1.1803 + <mallctl>stats.arenas.<i>.bins.<j>.ndalloc</mallctl> 1.1804 + (<type>uint64_t</type>) 1.1805 + <literal>r-</literal> 1.1806 + [<option>--enable-stats</option>] 1.1807 + </term> 1.1808 + <listitem><para>Cumulative number of allocations returned to bin. 1.1809 + </para></listitem> 1.1810 + </varlistentry> 1.1811 + 1.1812 + <varlistentry> 1.1813 + <term> 1.1814 + <mallctl>stats.arenas.<i>.bins.<j>.nrequests</mallctl> 1.1815 + (<type>uint64_t</type>) 1.1816 + <literal>r-</literal> 1.1817 + [<option>--enable-stats</option>] 1.1818 + </term> 1.1819 + <listitem><para>Cumulative number of allocation 1.1820 + requests.</para></listitem> 1.1821 + </varlistentry> 1.1822 + 1.1823 + <varlistentry> 1.1824 + <term> 1.1825 + <mallctl>stats.arenas.<i>.bins.<j>.nfills</mallctl> 1.1826 + (<type>uint64_t</type>) 1.1827 + <literal>r-</literal> 1.1828 + [<option>--enable-stats</option> <option>--enable-tcache</option>] 1.1829 + </term> 1.1830 + <listitem><para>Cumulative number of tcache fills.</para></listitem> 1.1831 + </varlistentry> 1.1832 + 1.1833 + <varlistentry> 1.1834 + <term> 1.1835 + <mallctl>stats.arenas.<i>.bins.<j>.nflushes</mallctl> 1.1836 + (<type>uint64_t</type>) 1.1837 + <literal>r-</literal> 1.1838 + [<option>--enable-stats</option> <option>--enable-tcache</option>] 1.1839 + </term> 1.1840 + <listitem><para>Cumulative number of tcache flushes.</para></listitem> 1.1841 + </varlistentry> 1.1842 + 1.1843 + <varlistentry> 1.1844 + <term> 1.1845 + <mallctl>stats.arenas.<i>.bins.<j>.nruns</mallctl> 1.1846 + (<type>uint64_t</type>) 1.1847 + <literal>r-</literal> 1.1848 + [<option>--enable-stats</option>] 1.1849 + </term> 1.1850 + <listitem><para>Cumulative number of runs created.</para></listitem> 1.1851 + </varlistentry> 1.1852 + 1.1853 + <varlistentry> 1.1854 + <term> 1.1855 + <mallctl>stats.arenas.<i>.bins.<j>.nreruns</mallctl> 1.1856 + (<type>uint64_t</type>) 1.1857 + <literal>r-</literal> 1.1858 + [<option>--enable-stats</option>] 1.1859 + </term> 1.1860 + <listitem><para>Cumulative number of times the current run from which 1.1861 + to allocate changed.</para></listitem> 1.1862 + </varlistentry> 1.1863 + 1.1864 + <varlistentry> 1.1865 + <term> 1.1866 + <mallctl>stats.arenas.<i>.bins.<j>.curruns</mallctl> 1.1867 + (<type>size_t</type>) 1.1868 + <literal>r-</literal> 1.1869 + [<option>--enable-stats</option>] 1.1870 + </term> 1.1871 + <listitem><para>Current number of runs.</para></listitem> 1.1872 + </varlistentry> 1.1873 + 1.1874 + <varlistentry> 1.1875 + <term> 1.1876 + <mallctl>stats.arenas.<i>.lruns.<j>.nmalloc</mallctl> 1.1877 + (<type>uint64_t</type>) 1.1878 + <literal>r-</literal> 1.1879 + [<option>--enable-stats</option>] 1.1880 + </term> 1.1881 + <listitem><para>Cumulative number of allocation requests for this size 1.1882 + class served directly by the arena.</para></listitem> 1.1883 + </varlistentry> 1.1884 + 1.1885 + <varlistentry> 1.1886 + <term> 1.1887 + <mallctl>stats.arenas.<i>.lruns.<j>.ndalloc</mallctl> 1.1888 + (<type>uint64_t</type>) 1.1889 + <literal>r-</literal> 1.1890 + [<option>--enable-stats</option>] 1.1891 + </term> 1.1892 + <listitem><para>Cumulative number of deallocation requests for this 1.1893 + size class served directly by the arena.</para></listitem> 1.1894 + </varlistentry> 1.1895 + 1.1896 + <varlistentry> 1.1897 + <term> 1.1898 + <mallctl>stats.arenas.<i>.lruns.<j>.nrequests</mallctl> 1.1899 + (<type>uint64_t</type>) 1.1900 + <literal>r-</literal> 1.1901 + [<option>--enable-stats</option>] 1.1902 + </term> 1.1903 + <listitem><para>Cumulative number of allocation requests for this size 1.1904 + class.</para></listitem> 1.1905 + </varlistentry> 1.1906 + 1.1907 + <varlistentry> 1.1908 + <term> 1.1909 + <mallctl>stats.arenas.<i>.lruns.<j>.curruns</mallctl> 1.1910 + (<type>size_t</type>) 1.1911 + <literal>r-</literal> 1.1912 + [<option>--enable-stats</option>] 1.1913 + </term> 1.1914 + <listitem><para>Current number of runs for this size class. 1.1915 + </para></listitem> 1.1916 + </varlistentry> 1.1917 + </variablelist> 1.1918 + </refsect1> 1.1919 + <refsect1 id="debugging_malloc_problems"> 1.1920 + <title>DEBUGGING MALLOC PROBLEMS</title> 1.1921 + <para>When debugging, it is a good idea to configure/build jemalloc with 1.1922 + the <option>--enable-debug</option> and <option>--enable-fill</option> 1.1923 + options, and recompile the program with suitable options and symbols for 1.1924 + debugger support. When so configured, jemalloc incorporates a wide variety 1.1925 + of run-time assertions that catch application errors such as double-free, 1.1926 + write-after-free, etc.</para> 1.1927 + 1.1928 + <para>Programs often accidentally depend on “uninitialized” 1.1929 + memory actually being filled with zero bytes. Junk filling 1.1930 + (see the <link linkend="opt.junk"><mallctl>opt.junk</mallctl></link> 1.1931 + option) tends to expose such bugs in the form of obviously incorrect 1.1932 + results and/or coredumps. Conversely, zero 1.1933 + filling (see the <link 1.1934 + linkend="opt.zero"><mallctl>opt.zero</mallctl></link> option) eliminates 1.1935 + the symptoms of such bugs. Between these two options, it is usually 1.1936 + possible to quickly detect, diagnose, and eliminate such bugs.</para> 1.1937 + 1.1938 + <para>This implementation does not provide much detail about the problems 1.1939 + it detects, because the performance impact for storing such information 1.1940 + would be prohibitive. However, jemalloc does integrate with the most 1.1941 + excellent <ulink url="http://valgrind.org/">Valgrind</ulink> tool if the 1.1942 + <option>--enable-valgrind</option> configuration option is enabled.</para> 1.1943 + </refsect1> 1.1944 + <refsect1 id="diagnostic_messages"> 1.1945 + <title>DIAGNOSTIC MESSAGES</title> 1.1946 + <para>If any of the memory allocation/deallocation functions detect an 1.1947 + error or warning condition, a message will be printed to file descriptor 1.1948 + <constant>STDERR_FILENO</constant>. Errors will result in the process 1.1949 + dumping core. If the <link 1.1950 + linkend="opt.abort"><mallctl>opt.abort</mallctl></link> option is set, most 1.1951 + warnings are treated as errors.</para> 1.1952 + 1.1953 + <para>The <varname>malloc_message</varname> variable allows the programmer 1.1954 + to override the function which emits the text strings forming the errors 1.1955 + and warnings if for some reason the <constant>STDERR_FILENO</constant> file 1.1956 + descriptor is not suitable for this. 1.1957 + <function>malloc_message<parameter/></function> takes the 1.1958 + <parameter>cbopaque</parameter> pointer argument that is 1.1959 + <constant>NULL</constant> unless overridden by the arguments in a call to 1.1960 + <function>malloc_stats_print<parameter/></function>, followed by a string 1.1961 + pointer. Please note that doing anything which tries to allocate memory in 1.1962 + this function is likely to result in a crash or deadlock.</para> 1.1963 + 1.1964 + <para>All messages are prefixed by 1.1965 + “<computeroutput><jemalloc>: </computeroutput>”.</para> 1.1966 + </refsect1> 1.1967 + <refsect1 id="return_values"> 1.1968 + <title>RETURN VALUES</title> 1.1969 + <refsect2> 1.1970 + <title>Standard API</title> 1.1971 + <para>The <function>malloc<parameter/></function> and 1.1972 + <function>calloc<parameter/></function> functions return a pointer to the 1.1973 + allocated memory if successful; otherwise a <constant>NULL</constant> 1.1974 + pointer is returned and <varname>errno</varname> is set to 1.1975 + <errorname>ENOMEM</errorname>.</para> 1.1976 + 1.1977 + <para>The <function>posix_memalign<parameter/></function> function 1.1978 + returns the value 0 if successful; otherwise it returns an error value. 1.1979 + The <function>posix_memalign<parameter/></function> function will fail 1.1980 + if: 1.1981 + <variablelist> 1.1982 + <varlistentry> 1.1983 + <term><errorname>EINVAL</errorname></term> 1.1984 + 1.1985 + <listitem><para>The <parameter>alignment</parameter> parameter is 1.1986 + not a power of 2 at least as large as 1.1987 + <code language="C">sizeof(<type>void *</type>)</code>. 1.1988 + </para></listitem> 1.1989 + </varlistentry> 1.1990 + <varlistentry> 1.1991 + <term><errorname>ENOMEM</errorname></term> 1.1992 + 1.1993 + <listitem><para>Memory allocation error.</para></listitem> 1.1994 + </varlistentry> 1.1995 + </variablelist> 1.1996 + </para> 1.1997 + 1.1998 + <para>The <function>aligned_alloc<parameter/></function> function returns 1.1999 + a pointer to the allocated memory if successful; otherwise a 1.2000 + <constant>NULL</constant> pointer is returned and 1.2001 + <varname>errno</varname> is set. The 1.2002 + <function>aligned_alloc<parameter/></function> function will fail if: 1.2003 + <variablelist> 1.2004 + <varlistentry> 1.2005 + <term><errorname>EINVAL</errorname></term> 1.2006 + 1.2007 + <listitem><para>The <parameter>alignment</parameter> parameter is 1.2008 + not a power of 2. 1.2009 + </para></listitem> 1.2010 + </varlistentry> 1.2011 + <varlistentry> 1.2012 + <term><errorname>ENOMEM</errorname></term> 1.2013 + 1.2014 + <listitem><para>Memory allocation error.</para></listitem> 1.2015 + </varlistentry> 1.2016 + </variablelist> 1.2017 + </para> 1.2018 + 1.2019 + <para>The <function>realloc<parameter/></function> function returns a 1.2020 + pointer, possibly identical to <parameter>ptr</parameter>, to the 1.2021 + allocated memory if successful; otherwise a <constant>NULL</constant> 1.2022 + pointer is returned, and <varname>errno</varname> is set to 1.2023 + <errorname>ENOMEM</errorname> if the error was the result of an 1.2024 + allocation failure. The <function>realloc<parameter/></function> 1.2025 + function always leaves the original buffer intact when an error occurs. 1.2026 + </para> 1.2027 + 1.2028 + <para>The <function>free<parameter/></function> function returns no 1.2029 + value.</para> 1.2030 + </refsect2> 1.2031 + <refsect2> 1.2032 + <title>Non-standard API</title> 1.2033 + <para>The <function>malloc_usable_size<parameter/></function> function 1.2034 + returns the usable size of the allocation pointed to by 1.2035 + <parameter>ptr</parameter>. </para> 1.2036 + 1.2037 + <para>The <function>mallctl<parameter/></function>, 1.2038 + <function>mallctlnametomib<parameter/></function>, and 1.2039 + <function>mallctlbymib<parameter/></function> functions return 0 on 1.2040 + success; otherwise they return an error value. The functions will fail 1.2041 + if: 1.2042 + <variablelist> 1.2043 + <varlistentry> 1.2044 + <term><errorname>EINVAL</errorname></term> 1.2045 + 1.2046 + <listitem><para><parameter>newp</parameter> is not 1.2047 + <constant>NULL</constant>, and <parameter>newlen</parameter> is too 1.2048 + large or too small. Alternatively, <parameter>*oldlenp</parameter> 1.2049 + is too large or too small; in this case as much data as possible 1.2050 + are read despite the error.</para></listitem> 1.2051 + </varlistentry> 1.2052 + <varlistentry> 1.2053 + <term><errorname>ENOMEM</errorname></term> 1.2054 + 1.2055 + <listitem><para><parameter>*oldlenp</parameter> is too short to 1.2056 + hold the requested value.</para></listitem> 1.2057 + </varlistentry> 1.2058 + <varlistentry> 1.2059 + <term><errorname>ENOENT</errorname></term> 1.2060 + 1.2061 + <listitem><para><parameter>name</parameter> or 1.2062 + <parameter>mib</parameter> specifies an unknown/invalid 1.2063 + value.</para></listitem> 1.2064 + </varlistentry> 1.2065 + <varlistentry> 1.2066 + <term><errorname>EPERM</errorname></term> 1.2067 + 1.2068 + <listitem><para>Attempt to read or write void value, or attempt to 1.2069 + write read-only value.</para></listitem> 1.2070 + </varlistentry> 1.2071 + <varlistentry> 1.2072 + <term><errorname>EAGAIN</errorname></term> 1.2073 + 1.2074 + <listitem><para>A memory allocation failure 1.2075 + occurred.</para></listitem> 1.2076 + </varlistentry> 1.2077 + <varlistentry> 1.2078 + <term><errorname>EFAULT</errorname></term> 1.2079 + 1.2080 + <listitem><para>An interface with side effects failed in some way 1.2081 + not directly related to <function>mallctl*<parameter/></function> 1.2082 + read/write processing.</para></listitem> 1.2083 + </varlistentry> 1.2084 + </variablelist> 1.2085 + </para> 1.2086 + </refsect2> 1.2087 + <refsect2> 1.2088 + <title>Experimental API</title> 1.2089 + <para>The <function>allocm<parameter/></function>, 1.2090 + <function>rallocm<parameter/></function>, 1.2091 + <function>sallocm<parameter/></function>, 1.2092 + <function>dallocm<parameter/></function>, and 1.2093 + <function>nallocm<parameter/></function> functions return 1.2094 + <constant>ALLOCM_SUCCESS</constant> on success; otherwise they return an 1.2095 + error value. The <function>allocm<parameter/></function>, 1.2096 + <function>rallocm<parameter/></function>, and 1.2097 + <function>nallocm<parameter/></function> functions will fail if: 1.2098 + <variablelist> 1.2099 + <varlistentry> 1.2100 + <term><errorname>ALLOCM_ERR_OOM</errorname></term> 1.2101 + 1.2102 + <listitem><para>Out of memory. Insufficient contiguous memory was 1.2103 + available to service the allocation request. The 1.2104 + <function>allocm<parameter/></function> function additionally sets 1.2105 + <parameter>*ptr</parameter> to <constant>NULL</constant>, whereas 1.2106 + the <function>rallocm<parameter/></function> function leaves 1.2107 + <constant>*ptr</constant> unmodified.</para></listitem> 1.2108 + </varlistentry> 1.2109 + </variablelist> 1.2110 + The <function>rallocm<parameter/></function> function will also 1.2111 + fail if: 1.2112 + <variablelist> 1.2113 + <varlistentry> 1.2114 + <term><errorname>ALLOCM_ERR_NOT_MOVED</errorname></term> 1.2115 + 1.2116 + <listitem><para><constant>ALLOCM_NO_MOVE</constant> was specified, 1.2117 + but the reallocation request could not be serviced without moving 1.2118 + the object.</para></listitem> 1.2119 + </varlistentry> 1.2120 + </variablelist> 1.2121 + </para> 1.2122 + </refsect2> 1.2123 + </refsect1> 1.2124 + <refsect1 id="environment"> 1.2125 + <title>ENVIRONMENT</title> 1.2126 + <para>The following environment variable affects the execution of the 1.2127 + allocation functions: 1.2128 + <variablelist> 1.2129 + <varlistentry> 1.2130 + <term><envar>MALLOC_CONF</envar></term> 1.2131 + 1.2132 + <listitem><para>If the environment variable 1.2133 + <envar>MALLOC_CONF</envar> is set, the characters it contains 1.2134 + will be interpreted as options.</para></listitem> 1.2135 + </varlistentry> 1.2136 + </variablelist> 1.2137 + </para> 1.2138 + </refsect1> 1.2139 + <refsect1 id="examples"> 1.2140 + <title>EXAMPLES</title> 1.2141 + <para>To dump core whenever a problem occurs: 1.2142 + <screen>ln -s 'abort:true' /etc/malloc.conf</screen> 1.2143 + </para> 1.2144 + <para>To specify in the source a chunk size that is 16 MiB: 1.2145 + <programlisting language="C"><![CDATA[ 1.2146 +malloc_conf = "lg_chunk:24";]]></programlisting></para> 1.2147 + </refsect1> 1.2148 + <refsect1 id="see_also"> 1.2149 + <title>SEE ALSO</title> 1.2150 + <para><citerefentry><refentrytitle>madvise</refentrytitle> 1.2151 + <manvolnum>2</manvolnum></citerefentry>, 1.2152 + <citerefentry><refentrytitle>mmap</refentrytitle> 1.2153 + <manvolnum>2</manvolnum></citerefentry>, 1.2154 + <citerefentry><refentrytitle>sbrk</refentrytitle> 1.2155 + <manvolnum>2</manvolnum></citerefentry>, 1.2156 + <citerefentry><refentrytitle>utrace</refentrytitle> 1.2157 + <manvolnum>2</manvolnum></citerefentry>, 1.2158 + <citerefentry><refentrytitle>alloca</refentrytitle> 1.2159 + <manvolnum>3</manvolnum></citerefentry>, 1.2160 + <citerefentry><refentrytitle>atexit</refentrytitle> 1.2161 + <manvolnum>3</manvolnum></citerefentry>, 1.2162 + <citerefentry><refentrytitle>getpagesize</refentrytitle> 1.2163 + <manvolnum>3</manvolnum></citerefentry></para> 1.2164 + </refsect1> 1.2165 + <refsect1 id="standards"> 1.2166 + <title>STANDARDS</title> 1.2167 + <para>The <function>malloc<parameter/></function>, 1.2168 + <function>calloc<parameter/></function>, 1.2169 + <function>realloc<parameter/></function>, and 1.2170 + <function>free<parameter/></function> functions conform to ISO/IEC 1.2171 + 9899:1990 (“ISO C90”).</para> 1.2172 + 1.2173 + <para>The <function>posix_memalign<parameter/></function> function conforms 1.2174 + to IEEE Std 1003.1-2001 (“POSIX.1”).</para> 1.2175 + </refsect1> 1.2176 +</refentry>