jemalloc.xml.in 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <?xml-stylesheet type="text/xsl"
  3. href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
  4. <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  5. "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  6. ]>
  7. <refentry>
  8. <refentryinfo>
  9. <title>User Manual</title>
  10. <productname>jemalloc</productname>
  11. <releaseinfo role="version">@jemalloc_version@</releaseinfo>
  12. <authorgroup>
  13. <author>
  14. <firstname>Jason</firstname>
  15. <surname>Evans</surname>
  16. <personblurb>Author</personblurb>
  17. </author>
  18. </authorgroup>
  19. </refentryinfo>
  20. <refmeta>
  21. <refentrytitle>JEMALLOC</refentrytitle>
  22. <manvolnum>3</manvolnum>
  23. </refmeta>
  24. <refnamediv>
  25. <refdescriptor>jemalloc</refdescriptor>
  26. <refname>jemalloc</refname>
  27. <!-- Each refname causes a man page file to be created. Only if this were
  28. the system malloc(3) implementation would these files be appropriate.
  29. <refname>malloc</refname>
  30. <refname>calloc</refname>
  31. <refname>posix_memalign</refname>
  32. <refname>aligned_alloc</refname>
  33. <refname>realloc</refname>
  34. <refname>free</refname>
  35. <refname>malloc_usable_size</refname>
  36. <refname>malloc_stats_print</refname>
  37. <refname>mallctl</refname>
  38. <refname>mallctlnametomib</refname>
  39. <refname>mallctlbymib</refname>
  40. <refname>allocm</refname>
  41. <refname>rallocm</refname>
  42. <refname>sallocm</refname>
  43. <refname>dallocm</refname>
  44. <refname>nallocm</refname>
  45. -->
  46. <refpurpose>general purpose memory allocation functions</refpurpose>
  47. </refnamediv>
  48. <refsect1 id="library">
  49. <title>LIBRARY</title>
  50. <para>This manual describes jemalloc @jemalloc_version@. More information
  51. can be found at the <ulink
  52. url="http://www.canonware.com/jemalloc/">jemalloc website</ulink>.</para>
  53. </refsect1>
  54. <refsynopsisdiv>
  55. <title>SYNOPSIS</title>
  56. <funcsynopsis>
  57. <funcsynopsisinfo>#include &lt;<filename class="headerfile">stdlib.h</filename>&gt;
  58. #include &lt;<filename class="headerfile">jemalloc/jemalloc.h</filename>&gt;</funcsynopsisinfo>
  59. <refsect2>
  60. <title>Standard API</title>
  61. <funcprototype>
  62. <funcdef>void *<function>malloc</function></funcdef>
  63. <paramdef>size_t <parameter>size</parameter></paramdef>
  64. </funcprototype>
  65. <funcprototype>
  66. <funcdef>void *<function>calloc</function></funcdef>
  67. <paramdef>size_t <parameter>number</parameter></paramdef>
  68. <paramdef>size_t <parameter>size</parameter></paramdef>
  69. </funcprototype>
  70. <funcprototype>
  71. <funcdef>int <function>posix_memalign</function></funcdef>
  72. <paramdef>void **<parameter>ptr</parameter></paramdef>
  73. <paramdef>size_t <parameter>alignment</parameter></paramdef>
  74. <paramdef>size_t <parameter>size</parameter></paramdef>
  75. </funcprototype>
  76. <funcprototype>
  77. <funcdef>void *<function>aligned_alloc</function></funcdef>
  78. <paramdef>size_t <parameter>alignment</parameter></paramdef>
  79. <paramdef>size_t <parameter>size</parameter></paramdef>
  80. </funcprototype>
  81. <funcprototype>
  82. <funcdef>void *<function>realloc</function></funcdef>
  83. <paramdef>void *<parameter>ptr</parameter></paramdef>
  84. <paramdef>size_t <parameter>size</parameter></paramdef>
  85. </funcprototype>
  86. <funcprototype>
  87. <funcdef>void <function>free</function></funcdef>
  88. <paramdef>void *<parameter>ptr</parameter></paramdef>
  89. </funcprototype>
  90. </refsect2>
  91. <refsect2>
  92. <title>Non-standard API</title>
  93. <funcprototype>
  94. <funcdef>size_t <function>malloc_usable_size</function></funcdef>
  95. <paramdef>const void *<parameter>ptr</parameter></paramdef>
  96. </funcprototype>
  97. <funcprototype>
  98. <funcdef>void <function>malloc_stats_print</function></funcdef>
  99. <paramdef>void <parameter>(*write_cb)</parameter>
  100. <funcparams>void *, const char *</funcparams>
  101. </paramdef>
  102. <paramdef>void *<parameter>cbopaque</parameter></paramdef>
  103. <paramdef>const char *<parameter>opts</parameter></paramdef>
  104. </funcprototype>
  105. <funcprototype>
  106. <funcdef>int <function>mallctl</function></funcdef>
  107. <paramdef>const char *<parameter>name</parameter></paramdef>
  108. <paramdef>void *<parameter>oldp</parameter></paramdef>
  109. <paramdef>size_t *<parameter>oldlenp</parameter></paramdef>
  110. <paramdef>void *<parameter>newp</parameter></paramdef>
  111. <paramdef>size_t <parameter>newlen</parameter></paramdef>
  112. </funcprototype>
  113. <funcprototype>
  114. <funcdef>int <function>mallctlnametomib</function></funcdef>
  115. <paramdef>const char *<parameter>name</parameter></paramdef>
  116. <paramdef>size_t *<parameter>mibp</parameter></paramdef>
  117. <paramdef>size_t *<parameter>miblenp</parameter></paramdef>
  118. </funcprototype>
  119. <funcprototype>
  120. <funcdef>int <function>mallctlbymib</function></funcdef>
  121. <paramdef>const size_t *<parameter>mib</parameter></paramdef>
  122. <paramdef>size_t <parameter>miblen</parameter></paramdef>
  123. <paramdef>void *<parameter>oldp</parameter></paramdef>
  124. <paramdef>size_t *<parameter>oldlenp</parameter></paramdef>
  125. <paramdef>void *<parameter>newp</parameter></paramdef>
  126. <paramdef>size_t <parameter>newlen</parameter></paramdef>
  127. </funcprototype>
  128. <funcprototype>
  129. <funcdef>void <function>(*malloc_message)</function></funcdef>
  130. <paramdef>void *<parameter>cbopaque</parameter></paramdef>
  131. <paramdef>const char *<parameter>s</parameter></paramdef>
  132. </funcprototype>
  133. <para><type>const char *</type><varname>malloc_conf</varname>;</para>
  134. </refsect2>
  135. <refsect2>
  136. <title>Experimental API</title>
  137. <funcprototype>
  138. <funcdef>int <function>allocm</function></funcdef>
  139. <paramdef>void **<parameter>ptr</parameter></paramdef>
  140. <paramdef>size_t *<parameter>rsize</parameter></paramdef>
  141. <paramdef>size_t <parameter>size</parameter></paramdef>
  142. <paramdef>int <parameter>flags</parameter></paramdef>
  143. </funcprototype>
  144. <funcprototype>
  145. <funcdef>int <function>rallocm</function></funcdef>
  146. <paramdef>void **<parameter>ptr</parameter></paramdef>
  147. <paramdef>size_t *<parameter>rsize</parameter></paramdef>
  148. <paramdef>size_t <parameter>size</parameter></paramdef>
  149. <paramdef>size_t <parameter>extra</parameter></paramdef>
  150. <paramdef>int <parameter>flags</parameter></paramdef>
  151. </funcprototype>
  152. <funcprototype>
  153. <funcdef>int <function>sallocm</function></funcdef>
  154. <paramdef>const void *<parameter>ptr</parameter></paramdef>
  155. <paramdef>size_t *<parameter>rsize</parameter></paramdef>
  156. <paramdef>int <parameter>flags</parameter></paramdef>
  157. </funcprototype>
  158. <funcprototype>
  159. <funcdef>int <function>dallocm</function></funcdef>
  160. <paramdef>void *<parameter>ptr</parameter></paramdef>
  161. <paramdef>int <parameter>flags</parameter></paramdef>
  162. </funcprototype>
  163. <funcprototype>
  164. <funcdef>int <function>nallocm</function></funcdef>
  165. <paramdef>size_t *<parameter>rsize</parameter></paramdef>
  166. <paramdef>size_t <parameter>size</parameter></paramdef>
  167. <paramdef>int <parameter>flags</parameter></paramdef>
  168. </funcprototype>
  169. </refsect2>
  170. </funcsynopsis>
  171. </refsynopsisdiv>
  172. <refsect1 id="description">
  173. <title>DESCRIPTION</title>
  174. <refsect2>
  175. <title>Standard API</title>
  176. <para>The <function>malloc<parameter/></function> function allocates
  177. <parameter>size</parameter> bytes of uninitialized memory. The allocated
  178. space is suitably aligned (after possible pointer coercion) for storage
  179. of any type of object.</para>
  180. <para>The <function>calloc<parameter/></function> function allocates
  181. space for <parameter>number</parameter> objects, each
  182. <parameter>size</parameter> bytes in length. The result is identical to
  183. calling <function>malloc<parameter/></function> with an argument of
  184. <parameter>number</parameter> * <parameter>size</parameter>, with the
  185. exception that the allocated memory is explicitly initialized to zero
  186. bytes.</para>
  187. <para>The <function>posix_memalign<parameter/></function> function
  188. allocates <parameter>size</parameter> bytes of memory such that the
  189. allocation's base address is an even multiple of
  190. <parameter>alignment</parameter>, and returns the allocation in the value
  191. pointed to by <parameter>ptr</parameter>. The requested
  192. <parameter>alignment</parameter> must be a power of 2 at least as large
  193. as <code language="C">sizeof(<type>void *</type>)</code>.</para>
  194. <para>The <function>aligned_alloc<parameter/></function> function
  195. allocates <parameter>size</parameter> bytes of memory such that the
  196. allocation's base address is an even multiple of
  197. <parameter>alignment</parameter>. The requested
  198. <parameter>alignment</parameter> must be a power of 2. Behavior is
  199. undefined if <parameter>size</parameter> is not an integral multiple of
  200. <parameter>alignment</parameter>.</para>
  201. <para>The <function>realloc<parameter/></function> function changes the
  202. size of the previously allocated memory referenced by
  203. <parameter>ptr</parameter> to <parameter>size</parameter> bytes. The
  204. contents of the memory are unchanged up to the lesser of the new and old
  205. sizes. If the new size is larger, the contents of the newly allocated
  206. portion of the memory are undefined. Upon success, the memory referenced
  207. by <parameter>ptr</parameter> is freed and a pointer to the newly
  208. allocated memory is returned. Note that
  209. <function>realloc<parameter/></function> may move the memory allocation,
  210. resulting in a different return value than <parameter>ptr</parameter>.
  211. If <parameter>ptr</parameter> is <constant>NULL</constant>, the
  212. <function>realloc<parameter/></function> function behaves identically to
  213. <function>malloc<parameter/></function> for the specified size.</para>
  214. <para>The <function>free<parameter/></function> function causes the
  215. allocated memory referenced by <parameter>ptr</parameter> to be made
  216. available for future allocations. If <parameter>ptr</parameter> is
  217. <constant>NULL</constant>, no action occurs.</para>
  218. </refsect2>
  219. <refsect2>
  220. <title>Non-standard API</title>
  221. <para>The <function>malloc_usable_size<parameter/></function> function
  222. returns the usable size of the allocation pointed to by
  223. <parameter>ptr</parameter>. The return value may be larger than the size
  224. that was requested during allocation. The
  225. <function>malloc_usable_size<parameter/></function> function is not a
  226. mechanism for in-place <function>realloc<parameter/></function>; rather
  227. it is provided solely as a tool for introspection purposes. Any
  228. discrepancy between the requested allocation size and the size reported
  229. by <function>malloc_usable_size<parameter/></function> should not be
  230. depended on, since such behavior is entirely implementation-dependent.
  231. </para>
  232. <para>The <function>malloc_stats_print<parameter/></function> function
  233. writes human-readable summary statistics via the
  234. <parameter>write_cb</parameter> callback function pointer and
  235. <parameter>cbopaque</parameter> data passed to
  236. <parameter>write_cb</parameter>, or
  237. <function>malloc_message<parameter/></function> if
  238. <parameter>write_cb</parameter> is <constant>NULL</constant>. This
  239. function can be called repeatedly. General information that never
  240. changes during execution can be omitted by specifying "g" as a character
  241. within the <parameter>opts</parameter> string. Note that
  242. <function>malloc_message<parameter/></function> uses the
  243. <function>mallctl*<parameter/></function> functions internally, so
  244. inconsistent statistics can be reported if multiple threads use these
  245. functions simultaneously. If <option>--enable-stats</option> is
  246. specified during configuration, &ldquo;m&rdquo; and &ldquo;a&rdquo; can
  247. be specified to omit merged arena and per arena statistics, respectively;
  248. &ldquo;b&rdquo; and &ldquo;l&rdquo; can be specified to omit per size
  249. class statistics for bins and large objects, respectively. Unrecognized
  250. characters are silently ignored. Note that thread caching may prevent
  251. some statistics from being completely up to date, since extra locking
  252. would be required to merge counters that track thread cache operations.
  253. </para>
  254. <para>The <function>mallctl<parameter/></function> function provides a
  255. general interface for introspecting the memory allocator, as well as
  256. setting modifiable parameters and triggering actions. The
  257. period-separated <parameter>name</parameter> argument specifies a
  258. location in a tree-structured namespace; see the <xref
  259. linkend="mallctl_namespace" xrefstyle="template:%t"/> section for
  260. documentation on the tree contents. To read a value, pass a pointer via
  261. <parameter>oldp</parameter> to adequate space to contain the value, and a
  262. pointer to its length via <parameter>oldlenp</parameter>; otherwise pass
  263. <constant>NULL</constant> and <constant>NULL</constant>. Similarly, to
  264. write a value, pass a pointer to the value via
  265. <parameter>newp</parameter>, and its length via
  266. <parameter>newlen</parameter>; otherwise pass <constant>NULL</constant>
  267. and <constant>0</constant>.</para>
  268. <para>The <function>mallctlnametomib<parameter/></function> function
  269. provides a way to avoid repeated name lookups for applications that
  270. repeatedly query the same portion of the namespace, by translating a name
  271. to a &ldquo;Management Information Base&rdquo; (MIB) that can be passed
  272. repeatedly to <function>mallctlbymib<parameter/></function>. Upon
  273. successful return from <function>mallctlnametomib<parameter/></function>,
  274. <parameter>mibp</parameter> contains an array of
  275. <parameter>*miblenp</parameter> integers, where
  276. <parameter>*miblenp</parameter> is the lesser of the number of components
  277. in <parameter>name</parameter> and the input value of
  278. <parameter>*miblenp</parameter>. Thus it is possible to pass a
  279. <parameter>*miblenp</parameter> that is smaller than the number of
  280. period-separated name components, which results in a partial MIB that can
  281. be used as the basis for constructing a complete MIB. For name
  282. components that are integers (e.g. the 2 in
  283. <link
  284. linkend="arenas.bin.i.size"><mallctl>arenas.bin.2.size</mallctl></link>),
  285. the corresponding MIB component will always be that integer. Therefore,
  286. it is legitimate to construct code like the following: <programlisting
  287. language="C"><![CDATA[
  288. unsigned nbins, i;
  289. int mib[4];
  290. size_t len, miblen;
  291. len = sizeof(nbins);
  292. mallctl("arenas.nbins", &nbins, &len, NULL, 0);
  293. miblen = 4;
  294. mallnametomib("arenas.bin.0.size", mib, &miblen);
  295. for (i = 0; i < nbins; i++) {
  296. size_t bin_size;
  297. mib[2] = i;
  298. len = sizeof(bin_size);
  299. mallctlbymib(mib, miblen, &bin_size, &len, NULL, 0);
  300. /* Do something with bin_size... */
  301. }]]></programlisting></para>
  302. </refsect2>
  303. <refsect2>
  304. <title>Experimental API</title>
  305. <para>The experimental API is subject to change or removal without regard
  306. for backward compatibility. If <option>--disable-experimental</option>
  307. is specified during configuration, the experimental API is
  308. omitted.</para>
  309. <para>The <function>allocm<parameter/></function>,
  310. <function>rallocm<parameter/></function>,
  311. <function>sallocm<parameter/></function>,
  312. <function>dallocm<parameter/></function>, and
  313. <function>nallocm<parameter/></function> functions all have a
  314. <parameter>flags</parameter> argument that can be used to specify
  315. options. The functions only check the options that are contextually
  316. relevant. Use bitwise or (<code language="C">|</code>) operations to
  317. specify one or more of the following:
  318. <variablelist>
  319. <varlistentry>
  320. <term><constant>ALLOCM_LG_ALIGN(<parameter>la</parameter>)
  321. </constant></term>
  322. <listitem><para>Align the memory allocation to start at an address
  323. that is a multiple of <code language="C">(1 &lt;&lt;
  324. <parameter>la</parameter>)</code>. This macro does not validate
  325. that <parameter>la</parameter> is within the valid
  326. range.</para></listitem>
  327. </varlistentry>
  328. <varlistentry>
  329. <term><constant>ALLOCM_ALIGN(<parameter>a</parameter>)
  330. </constant></term>
  331. <listitem><para>Align the memory allocation to start at an address
  332. that is a multiple of <parameter>a</parameter>, where
  333. <parameter>a</parameter> is a power of two. This macro does not
  334. validate that <parameter>a</parameter> is a power of 2.
  335. </para></listitem>
  336. </varlistentry>
  337. <varlistentry>
  338. <term><constant>ALLOCM_ZERO</constant></term>
  339. <listitem><para>Initialize newly allocated memory to contain zero
  340. bytes. In the growing reallocation case, the real size prior to
  341. reallocation defines the boundary between untouched bytes and those
  342. that are initialized to contain zero bytes. If this option is
  343. absent, newly allocated memory is uninitialized.</para></listitem>
  344. </varlistentry>
  345. <varlistentry>
  346. <term><constant>ALLOCM_NO_MOVE</constant></term>
  347. <listitem><para>For reallocation, fail rather than moving the
  348. object. This constraint can apply to both growth and
  349. shrinkage.</para></listitem>
  350. </varlistentry>
  351. <varlistentry>
  352. <term><constant>ALLOCM_ARENA(<parameter>a</parameter>)
  353. </constant></term>
  354. <listitem><para>Use the arena specified by the index
  355. <parameter>a</parameter>. This macro does not validate that
  356. <parameter>a</parameter> specifies an arena in the valid
  357. range.</para></listitem>
  358. </varlistentry>
  359. </variablelist>
  360. </para>
  361. <para>The <function>allocm<parameter/></function> function allocates at
  362. least <parameter>size</parameter> bytes of memory, sets
  363. <parameter>*ptr</parameter> to the base address of the allocation, and
  364. sets <parameter>*rsize</parameter> to the real size of the allocation if
  365. <parameter>rsize</parameter> is not <constant>NULL</constant>. Behavior
  366. is undefined if <parameter>size</parameter> is
  367. <constant>0</constant>.</para>
  368. <para>The <function>rallocm<parameter/></function> function resizes the
  369. allocation at <parameter>*ptr</parameter> to be at least
  370. <parameter>size</parameter> bytes, sets <parameter>*ptr</parameter> to
  371. the base address of the allocation if it moved, and sets
  372. <parameter>*rsize</parameter> to the real size of the allocation if
  373. <parameter>rsize</parameter> is not <constant>NULL</constant>. If
  374. <parameter>extra</parameter> is non-zero, an attempt is made to resize
  375. the allocation to be at least <code
  376. language="C"><parameter>size</parameter> +
  377. <parameter>extra</parameter>)</code> bytes, though inability to allocate
  378. the extra byte(s) will not by itself result in failure. Behavior is
  379. undefined if <parameter>size</parameter> is <constant>0</constant>, or if
  380. <code language="C">(<parameter>size</parameter> +
  381. <parameter>extra</parameter> &gt;
  382. <constant>SIZE_T_MAX</constant>)</code>.</para>
  383. <para>The <function>sallocm<parameter/></function> function sets
  384. <parameter>*rsize</parameter> to the real size of the allocation.</para>
  385. <para>The <function>dallocm<parameter/></function> function causes the
  386. memory referenced by <parameter>ptr</parameter> to be made available for
  387. future allocations.</para>
  388. <para>The <function>nallocm<parameter/></function> function allocates no
  389. memory, but it performs the same size computation as the
  390. <function>allocm<parameter/></function> function, and if
  391. <parameter>rsize</parameter> is not <constant>NULL</constant> it sets
  392. <parameter>*rsize</parameter> to the real size of the allocation that
  393. would result from the equivalent <function>allocm<parameter/></function>
  394. function call. Behavior is undefined if
  395. <parameter>size</parameter> is <constant>0</constant>.</para>
  396. </refsect2>
  397. </refsect1>
  398. <refsect1 id="tuning">
  399. <title>TUNING</title>
  400. <para>Once, when the first call is made to one of the memory allocation
  401. routines, the allocator initializes its internals based in part on various
  402. options that can be specified at compile- or run-time.</para>
  403. <para>The string pointed to by the global variable
  404. <varname>malloc_conf</varname>, the &ldquo;name&rdquo; of the file
  405. referenced by the symbolic link named <filename
  406. class="symlink">/etc/malloc.conf</filename>, and the value of the
  407. environment variable <envar>MALLOC_CONF</envar>, will be interpreted, in
  408. that order, from left to right as options.</para>
  409. <para>An options string is a comma-separated list of option:value pairs.
  410. There is one key corresponding to each <link
  411. linkend="opt.abort"><mallctl>opt.*</mallctl></link> mallctl (see the <xref
  412. linkend="mallctl_namespace" xrefstyle="template:%t"/> section for options
  413. documentation). For example, <literal>abort:true,narenas:1</literal> sets
  414. the <link linkend="opt.abort"><mallctl>opt.abort</mallctl></link> and <link
  415. linkend="opt.narenas"><mallctl>opt.narenas</mallctl></link> options. Some
  416. options have boolean values (true/false), others have integer values (base
  417. 8, 10, or 16, depending on prefix), and yet others have raw string
  418. values.</para>
  419. </refsect1>
  420. <refsect1 id="implementation_notes">
  421. <title>IMPLEMENTATION NOTES</title>
  422. <para>Traditionally, allocators have used
  423. <citerefentry><refentrytitle>sbrk</refentrytitle>
  424. <manvolnum>2</manvolnum></citerefentry> to obtain memory, which is
  425. suboptimal for several reasons, including race conditions, increased
  426. fragmentation, and artificial limitations on maximum usable memory. If
  427. <option>--enable-dss</option> is specified during configuration, this
  428. allocator uses both <citerefentry><refentrytitle>mmap</refentrytitle>
  429. <manvolnum>2</manvolnum></citerefentry> and
  430. <citerefentry><refentrytitle>sbrk</refentrytitle>
  431. <manvolnum>2</manvolnum></citerefentry>, in that order of preference;
  432. otherwise only <citerefentry><refentrytitle>mmap</refentrytitle>
  433. <manvolnum>2</manvolnum></citerefentry> is used.</para>
  434. <para>This allocator uses multiple arenas in order to reduce lock
  435. contention for threaded programs on multi-processor systems. This works
  436. well with regard to threading scalability, but incurs some costs. There is
  437. a small fixed per-arena overhead, and additionally, arenas manage memory
  438. completely independently of each other, which means a small fixed increase
  439. in overall memory fragmentation. These overheads are not generally an
  440. issue, given the number of arenas normally used. Note that using
  441. substantially more arenas than the default is not likely to improve
  442. performance, mainly due to reduced cache performance. However, it may make
  443. sense to reduce the number of arenas if an application does not make much
  444. use of the allocation functions.</para>
  445. <para>In addition to multiple arenas, unless
  446. <option>--disable-tcache</option> is specified during configuration, this
  447. allocator supports thread-specific caching for small and large objects, in
  448. order to make it possible to completely avoid synchronization for most
  449. allocation requests. Such caching allows very fast allocation in the
  450. common case, but it increases memory usage and fragmentation, since a
  451. bounded number of objects can remain allocated in each thread cache.</para>
  452. <para>Memory is conceptually broken into equal-sized chunks, where the
  453. chunk size is a power of two that is greater than the page size. Chunks
  454. are always aligned to multiples of the chunk size. This alignment makes it
  455. possible to find metadata for user objects very quickly.</para>
  456. <para>User objects are broken into three categories according to size:
  457. small, large, and huge. Small objects are smaller than one page. Large
  458. objects are smaller than the chunk size. Huge objects are a multiple of
  459. the chunk size. Small and large objects are managed by arenas; huge
  460. objects are managed separately in a single data structure that is shared by
  461. all threads. Huge objects are used by applications infrequently enough
  462. that this single data structure is not a scalability issue.</para>
  463. <para>Each chunk that is managed by an arena tracks its contents as runs of
  464. contiguous pages (unused, backing a set of small objects, or backing one
  465. large object). The combination of chunk alignment and chunk page maps
  466. makes it possible to determine all metadata regarding small and large
  467. allocations in constant time.</para>
  468. <para>Small objects are managed in groups by page runs. Each run maintains
  469. a frontier and free list to track which regions are in use. Allocation
  470. requests that are no more than half the quantum (8 or 16, depending on
  471. architecture) are rounded up to the nearest power of two that is at least
  472. <code language="C">sizeof(<type>double</type>)</code>. All other small
  473. object size classes are multiples of the quantum, spaced such that internal
  474. fragmentation is limited to approximately 25% for all but the smallest size
  475. classes. Allocation requests that are larger than the maximum small size
  476. class, but small enough to fit in an arena-managed chunk (see the <link
  477. linkend="opt.lg_chunk"><mallctl>opt.lg_chunk</mallctl></link> option), are
  478. rounded up to the nearest run size. Allocation requests that are too large
  479. to fit in an arena-managed chunk are rounded up to the nearest multiple of
  480. the chunk size.</para>
  481. <para>Allocations are packed tightly together, which can be an issue for
  482. multi-threaded applications. If you need to assure that allocations do not
  483. suffer from cacheline sharing, round your allocation requests up to the
  484. nearest multiple of the cacheline size, or specify cacheline alignment when
  485. allocating.</para>
  486. <para>Assuming 4 MiB chunks, 4 KiB pages, and a 16-byte quantum on a 64-bit
  487. system, the size classes in each category are as shown in <xref
  488. linkend="size_classes" xrefstyle="template:Table %n"/>.</para>
  489. <table xml:id="size_classes" frame="all">
  490. <title>Size classes</title>
  491. <tgroup cols="3" colsep="1" rowsep="1">
  492. <colspec colname="c1" align="left"/>
  493. <colspec colname="c2" align="right"/>
  494. <colspec colname="c3" align="left"/>
  495. <thead>
  496. <row>
  497. <entry>Category</entry>
  498. <entry>Spacing</entry>
  499. <entry>Size</entry>
  500. </row>
  501. </thead>
  502. <tbody>
  503. <row>
  504. <entry morerows="6">Small</entry>
  505. <entry>lg</entry>
  506. <entry>[8]</entry>
  507. </row>
  508. <row>
  509. <entry>16</entry>
  510. <entry>[16, 32, 48, ..., 128]</entry>
  511. </row>
  512. <row>
  513. <entry>32</entry>
  514. <entry>[160, 192, 224, 256]</entry>
  515. </row>
  516. <row>
  517. <entry>64</entry>
  518. <entry>[320, 384, 448, 512]</entry>
  519. </row>
  520. <row>
  521. <entry>128</entry>
  522. <entry>[640, 768, 896, 1024]</entry>
  523. </row>
  524. <row>
  525. <entry>256</entry>
  526. <entry>[1280, 1536, 1792, 2048]</entry>
  527. </row>
  528. <row>
  529. <entry>512</entry>
  530. <entry>[2560, 3072, 3584]</entry>
  531. </row>
  532. <row>
  533. <entry>Large</entry>
  534. <entry>4 KiB</entry>
  535. <entry>[4 KiB, 8 KiB, 12 KiB, ..., 4072 KiB]</entry>
  536. </row>
  537. <row>
  538. <entry>Huge</entry>
  539. <entry>4 MiB</entry>
  540. <entry>[4 MiB, 8 MiB, 12 MiB, ...]</entry>
  541. </row>
  542. </tbody>
  543. </tgroup>
  544. </table>
  545. </refsect1>
  546. <refsect1 id="mallctl_namespace">
  547. <title>MALLCTL NAMESPACE</title>
  548. <para>The following names are defined in the namespace accessible via the
  549. <function>mallctl*<parameter/></function> functions. Value types are
  550. specified in parentheses, their readable/writable statuses are encoded as
  551. <literal>rw</literal>, <literal>r-</literal>, <literal>-w</literal>, or
  552. <literal>--</literal>, and required build configuration flags follow, if
  553. any. A name element encoded as <literal>&lt;i&gt;</literal> or
  554. <literal>&lt;j&gt;</literal> indicates an integer component, where the
  555. integer varies from 0 to some upper value that must be determined via
  556. introspection. In the case of <mallctl>stats.arenas.&lt;i&gt;.*</mallctl>,
  557. <literal>&lt;i&gt;</literal> equal to <link
  558. linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link> can be
  559. used to access the summation of statistics from all arenas. Take special
  560. note of the <link linkend="epoch"><mallctl>epoch</mallctl></link> mallctl,
  561. which controls refreshing of cached dynamic statistics.</para>
  562. <variablelist>
  563. <varlistentry>
  564. <term>
  565. <mallctl>version</mallctl>
  566. (<type>const char *</type>)
  567. <literal>r-</literal>
  568. </term>
  569. <listitem><para>Return the jemalloc version string.</para></listitem>
  570. </varlistentry>
  571. <varlistentry id="epoch">
  572. <term>
  573. <mallctl>epoch</mallctl>
  574. (<type>uint64_t</type>)
  575. <literal>rw</literal>
  576. </term>
  577. <listitem><para>If a value is passed in, refresh the data from which
  578. the <function>mallctl*<parameter/></function> functions report values,
  579. and increment the epoch. Return the current epoch. This is useful for
  580. detecting whether another thread caused a refresh.</para></listitem>
  581. </varlistentry>
  582. <varlistentry>
  583. <term>
  584. <mallctl>config.debug</mallctl>
  585. (<type>bool</type>)
  586. <literal>r-</literal>
  587. </term>
  588. <listitem><para><option>--enable-debug</option> was specified during
  589. build configuration.</para></listitem>
  590. </varlistentry>
  591. <varlistentry>
  592. <term>
  593. <mallctl>config.dss</mallctl>
  594. (<type>bool</type>)
  595. <literal>r-</literal>
  596. </term>
  597. <listitem><para><option>--enable-dss</option> was specified during
  598. build configuration.</para></listitem>
  599. </varlistentry>
  600. <varlistentry>
  601. <term>
  602. <mallctl>config.fill</mallctl>
  603. (<type>bool</type>)
  604. <literal>r-</literal>
  605. </term>
  606. <listitem><para><option>--enable-fill</option> was specified during
  607. build configuration.</para></listitem>
  608. </varlistentry>
  609. <varlistentry>
  610. <term>
  611. <mallctl>config.lazy_lock</mallctl>
  612. (<type>bool</type>)
  613. <literal>r-</literal>
  614. </term>
  615. <listitem><para><option>--enable-lazy-lock</option> was specified
  616. during build configuration.</para></listitem>
  617. </varlistentry>
  618. <varlistentry>
  619. <term>
  620. <mallctl>config.mremap</mallctl>
  621. (<type>bool</type>)
  622. <literal>r-</literal>
  623. </term>
  624. <listitem><para><option>--enable-mremap</option> was specified during
  625. build configuration.</para></listitem>
  626. </varlistentry>
  627. <varlistentry>
  628. <term>
  629. <mallctl>config.munmap</mallctl>
  630. (<type>bool</type>)
  631. <literal>r-</literal>
  632. </term>
  633. <listitem><para><option>--enable-munmap</option> was specified during
  634. build configuration.</para></listitem>
  635. </varlistentry>
  636. <varlistentry>
  637. <term>
  638. <mallctl>config.prof</mallctl>
  639. (<type>bool</type>)
  640. <literal>r-</literal>
  641. </term>
  642. <listitem><para><option>--enable-prof</option> was specified during
  643. build configuration.</para></listitem>
  644. </varlistentry>
  645. <varlistentry>
  646. <term>
  647. <mallctl>config.prof_libgcc</mallctl>
  648. (<type>bool</type>)
  649. <literal>r-</literal>
  650. </term>
  651. <listitem><para><option>--disable-prof-libgcc</option> was not
  652. specified during build configuration.</para></listitem>
  653. </varlistentry>
  654. <varlistentry>
  655. <term>
  656. <mallctl>config.prof_libunwind</mallctl>
  657. (<type>bool</type>)
  658. <literal>r-</literal>
  659. </term>
  660. <listitem><para><option>--enable-prof-libunwind</option> was specified
  661. during build configuration.</para></listitem>
  662. </varlistentry>
  663. <varlistentry>
  664. <term>
  665. <mallctl>config.stats</mallctl>
  666. (<type>bool</type>)
  667. <literal>r-</literal>
  668. </term>
  669. <listitem><para><option>--enable-stats</option> was specified during
  670. build configuration.</para></listitem>
  671. </varlistentry>
  672. <varlistentry>
  673. <term>
  674. <mallctl>config.tcache</mallctl>
  675. (<type>bool</type>)
  676. <literal>r-</literal>
  677. </term>
  678. <listitem><para><option>--disable-tcache</option> was not specified
  679. during build configuration.</para></listitem>
  680. </varlistentry>
  681. <varlistentry>
  682. <term>
  683. <mallctl>config.tls</mallctl>
  684. (<type>bool</type>)
  685. <literal>r-</literal>
  686. </term>
  687. <listitem><para><option>--disable-tls</option> was not specified during
  688. build configuration.</para></listitem>
  689. </varlistentry>
  690. <varlistentry>
  691. <term>
  692. <mallctl>config.utrace</mallctl>
  693. (<type>bool</type>)
  694. <literal>r-</literal>
  695. </term>
  696. <listitem><para><option>--enable-utrace</option> was specified during
  697. build configuration.</para></listitem>
  698. </varlistentry>
  699. <varlistentry>
  700. <term>
  701. <mallctl>config.valgrind</mallctl>
  702. (<type>bool</type>)
  703. <literal>r-</literal>
  704. </term>
  705. <listitem><para><option>--enable-valgrind</option> was specified during
  706. build configuration.</para></listitem>
  707. </varlistentry>
  708. <varlistentry>
  709. <term>
  710. <mallctl>config.xmalloc</mallctl>
  711. (<type>bool</type>)
  712. <literal>r-</literal>
  713. </term>
  714. <listitem><para><option>--enable-xmalloc</option> was specified during
  715. build configuration.</para></listitem>
  716. </varlistentry>
  717. <varlistentry id="opt.abort">
  718. <term>
  719. <mallctl>opt.abort</mallctl>
  720. (<type>bool</type>)
  721. <literal>r-</literal>
  722. </term>
  723. <listitem><para>Abort-on-warning enabled/disabled. If true, most
  724. warnings are fatal. The process will call
  725. <citerefentry><refentrytitle>abort</refentrytitle>
  726. <manvolnum>3</manvolnum></citerefentry> in these cases. This option is
  727. disabled by default unless <option>--enable-debug</option> is
  728. specified during configuration, in which case it is enabled by default.
  729. </para></listitem>
  730. </varlistentry>
  731. <varlistentry id="opt.lg_chunk">
  732. <term>
  733. <mallctl>opt.lg_chunk</mallctl>
  734. (<type>size_t</type>)
  735. <literal>r-</literal>
  736. </term>
  737. <listitem><para>Virtual memory chunk size (log base 2). The default
  738. chunk size is 4 MiB (2^22).</para></listitem>
  739. </varlistentry>
  740. <varlistentry id="opt.dss">
  741. <term>
  742. <mallctl>opt.dss</mallctl>
  743. (<type>const char *</type>)
  744. <literal>r-</literal>
  745. </term>
  746. <listitem><para>dss (<citerefentry><refentrytitle>sbrk</refentrytitle>
  747. <manvolnum>2</manvolnum></citerefentry>) allocation precedence as
  748. related to <citerefentry><refentrytitle>mmap</refentrytitle>
  749. <manvolnum>2</manvolnum></citerefentry> allocation. The following
  750. settings are supported: &ldquo;disabled&rdquo;, &ldquo;primary&rdquo;,
  751. and &ldquo;secondary&rdquo; (default).</para></listitem>
  752. </varlistentry>
  753. <varlistentry id="opt.narenas">
  754. <term>
  755. <mallctl>opt.narenas</mallctl>
  756. (<type>size_t</type>)
  757. <literal>r-</literal>
  758. </term>
  759. <listitem><para>Maximum number of arenas to use for automatic
  760. multiplexing of threads and arenas. The default is four times the
  761. number of CPUs, or one if there is a single CPU.</para></listitem>
  762. </varlistentry>
  763. <varlistentry id="opt.lg_dirty_mult">
  764. <term>
  765. <mallctl>opt.lg_dirty_mult</mallctl>
  766. (<type>ssize_t</type>)
  767. <literal>r-</literal>
  768. </term>
  769. <listitem><para>Per-arena minimum ratio (log base 2) of active to dirty
  770. pages. Some dirty unused pages may be allowed to accumulate, within
  771. the limit set by the ratio (or one chunk worth of dirty pages,
  772. whichever is greater), before informing the kernel about some of those
  773. pages via <citerefentry><refentrytitle>madvise</refentrytitle>
  774. <manvolnum>2</manvolnum></citerefentry> or a similar system call. This
  775. provides the kernel with sufficient information to recycle dirty pages
  776. if physical memory becomes scarce and the pages remain unused. The
  777. default minimum ratio is 8:1 (2^3:1); an option value of -1 will
  778. disable dirty page purging.</para></listitem>
  779. </varlistentry>
  780. <varlistentry id="opt.stats_print">
  781. <term>
  782. <mallctl>opt.stats_print</mallctl>
  783. (<type>bool</type>)
  784. <literal>r-</literal>
  785. </term>
  786. <listitem><para>Enable/disable statistics printing at exit. If
  787. enabled, the <function>malloc_stats_print<parameter/></function>
  788. function is called at program exit via an
  789. <citerefentry><refentrytitle>atexit</refentrytitle>
  790. <manvolnum>3</manvolnum></citerefentry> function. If
  791. <option>--enable-stats</option> is specified during configuration, this
  792. has the potential to cause deadlock for a multi-threaded process that
  793. exits while one or more threads are executing in the memory allocation
  794. functions. Therefore, this option should only be used with care; it is
  795. primarily intended as a performance tuning aid during application
  796. development. This option is disabled by default.</para></listitem>
  797. </varlistentry>
  798. <varlistentry id="opt.junk">
  799. <term>
  800. <mallctl>opt.junk</mallctl>
  801. (<type>bool</type>)
  802. <literal>r-</literal>
  803. [<option>--enable-fill</option>]
  804. </term>
  805. <listitem><para>Junk filling enabled/disabled. If enabled, each byte
  806. of uninitialized allocated memory will be initialized to
  807. <literal>0xa5</literal>. All deallocated memory will be initialized to
  808. <literal>0x5a</literal>. This is intended for debugging and will
  809. impact performance negatively. This option is disabled by default
  810. unless <option>--enable-debug</option> is specified during
  811. configuration, in which case it is enabled by default unless running
  812. inside <ulink
  813. url="http://valgrind.org/">Valgrind</ulink>.</para></listitem>
  814. </varlistentry>
  815. <varlistentry id="opt.quarantine">
  816. <term>
  817. <mallctl>opt.quarantine</mallctl>
  818. (<type>size_t</type>)
  819. <literal>r-</literal>
  820. [<option>--enable-fill</option>]
  821. </term>
  822. <listitem><para>Per thread quarantine size in bytes. If non-zero, each
  823. thread maintains a FIFO object quarantine that stores up to the
  824. specified number of bytes of memory. The quarantined memory is not
  825. freed until it is released from quarantine, though it is immediately
  826. junk-filled if the <link
  827. linkend="opt.junk"><mallctl>opt.junk</mallctl></link> option is
  828. enabled. This feature is of particular use in combination with <ulink
  829. url="http://valgrind.org/">Valgrind</ulink>, which can detect attempts
  830. to access quarantined objects. This is intended for debugging and will
  831. impact performance negatively. The default quarantine size is 0 unless
  832. running inside Valgrind, in which case the default is 16
  833. MiB.</para></listitem>
  834. </varlistentry>
  835. <varlistentry id="opt.redzone">
  836. <term>
  837. <mallctl>opt.redzone</mallctl>
  838. (<type>bool</type>)
  839. <literal>r-</literal>
  840. [<option>--enable-fill</option>]
  841. </term>
  842. <listitem><para>Redzones enabled/disabled. If enabled, small
  843. allocations have redzones before and after them. Furthermore, if the
  844. <link linkend="opt.junk"><mallctl>opt.junk</mallctl></link> option is
  845. enabled, the redzones are checked for corruption during deallocation.
  846. However, the primary intended purpose of this feature is to be used in
  847. combination with <ulink url="http://valgrind.org/">Valgrind</ulink>,
  848. which needs redzones in order to do effective buffer overflow/underflow
  849. detection. This option is intended for debugging and will impact
  850. performance negatively. This option is disabled by
  851. default unless running inside Valgrind.</para></listitem>
  852. </varlistentry>
  853. <varlistentry id="opt.zero">
  854. <term>
  855. <mallctl>opt.zero</mallctl>
  856. (<type>bool</type>)
  857. <literal>r-</literal>
  858. [<option>--enable-fill</option>]
  859. </term>
  860. <listitem><para>Zero filling enabled/disabled. If enabled, each byte
  861. of uninitialized allocated memory will be initialized to 0. Note that
  862. this initialization only happens once for each byte, so
  863. <function>realloc<parameter/></function> and
  864. <function>rallocm<parameter/></function> calls do not zero memory that
  865. was previously allocated. This is intended for debugging and will
  866. impact performance negatively. This option is disabled by default.
  867. </para></listitem>
  868. </varlistentry>
  869. <varlistentry id="opt.utrace">
  870. <term>
  871. <mallctl>opt.utrace</mallctl>
  872. (<type>bool</type>)
  873. <literal>r-</literal>
  874. [<option>--enable-utrace</option>]
  875. </term>
  876. <listitem><para>Allocation tracing based on
  877. <citerefentry><refentrytitle>utrace</refentrytitle>
  878. <manvolnum>2</manvolnum></citerefentry> enabled/disabled. This option
  879. is disabled by default.</para></listitem>
  880. </varlistentry>
  881. <varlistentry id="opt.valgrind">
  882. <term>
  883. <mallctl>opt.valgrind</mallctl>
  884. (<type>bool</type>)
  885. <literal>r-</literal>
  886. [<option>--enable-valgrind</option>]
  887. </term>
  888. <listitem><para><ulink url="http://valgrind.org/">Valgrind</ulink>
  889. support enabled/disabled. This option is vestigal because jemalloc
  890. auto-detects whether it is running inside Valgrind. This option is
  891. disabled by default, unless running inside Valgrind.</para></listitem>
  892. </varlistentry>
  893. <varlistentry id="opt.xmalloc">
  894. <term>
  895. <mallctl>opt.xmalloc</mallctl>
  896. (<type>bool</type>)
  897. <literal>r-</literal>
  898. [<option>--enable-xmalloc</option>]
  899. </term>
  900. <listitem><para>Abort-on-out-of-memory enabled/disabled. If enabled,
  901. rather than returning failure for any allocation function, display a
  902. diagnostic message on <constant>STDERR_FILENO</constant> and cause the
  903. program to drop core (using
  904. <citerefentry><refentrytitle>abort</refentrytitle>
  905. <manvolnum>3</manvolnum></citerefentry>). If an application is
  906. designed to depend on this behavior, set the option at compile time by
  907. including the following in the source code:
  908. <programlisting language="C"><![CDATA[
  909. malloc_conf = "xmalloc:true";]]></programlisting>
  910. This option is disabled by default.</para></listitem>
  911. </varlistentry>
  912. <varlistentry id="opt.tcache">
  913. <term>
  914. <mallctl>opt.tcache</mallctl>
  915. (<type>bool</type>)
  916. <literal>r-</literal>
  917. [<option>--enable-tcache</option>]
  918. </term>
  919. <listitem><para>Thread-specific caching enabled/disabled. When there
  920. are multiple threads, each thread uses a thread-specific cache for
  921. objects up to a certain size. Thread-specific caching allows many
  922. allocations to be satisfied without performing any thread
  923. synchronization, at the cost of increased memory use. See the
  924. <link
  925. linkend="opt.lg_tcache_max"><mallctl>opt.lg_tcache_max</mallctl></link>
  926. option for related tuning information. This option is enabled by
  927. default unless running inside <ulink
  928. url="http://valgrind.org/">Valgrind</ulink>.</para></listitem>
  929. </varlistentry>
  930. <varlistentry id="opt.lg_tcache_max">
  931. <term>
  932. <mallctl>opt.lg_tcache_max</mallctl>
  933. (<type>size_t</type>)
  934. <literal>r-</literal>
  935. [<option>--enable-tcache</option>]
  936. </term>
  937. <listitem><para>Maximum size class (log base 2) to cache in the
  938. thread-specific cache. At a minimum, all small size classes are
  939. cached, and at a maximum all large size classes are cached. The
  940. default maximum is 32 KiB (2^15).</para></listitem>
  941. </varlistentry>
  942. <varlistentry id="opt.prof">
  943. <term>
  944. <mallctl>opt.prof</mallctl>
  945. (<type>bool</type>)
  946. <literal>r-</literal>
  947. [<option>--enable-prof</option>]
  948. </term>
  949. <listitem><para>Memory profiling enabled/disabled. If enabled, profile
  950. memory allocation activity. See the <link
  951. linkend="opt.prof_active"><mallctl>opt.prof_active</mallctl></link>
  952. option for on-the-fly activation/deactivation. See the <link
  953. linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link>
  954. option for probabilistic sampling control. See the <link
  955. linkend="opt.prof_accum"><mallctl>opt.prof_accum</mallctl></link>
  956. option for control of cumulative sample reporting. See the <link
  957. linkend="opt.lg_prof_interval"><mallctl>opt.lg_prof_interval</mallctl></link>
  958. option for information on interval-triggered profile dumping, the <link
  959. linkend="opt.prof_gdump"><mallctl>opt.prof_gdump</mallctl></link>
  960. option for information on high-water-triggered profile dumping, and the
  961. <link linkend="opt.prof_final"><mallctl>opt.prof_final</mallctl></link>
  962. option for final profile dumping. Profile output is compatible with
  963. the included <command>pprof</command> Perl script, which originates
  964. from the <ulink url="http://code.google.com/p/gperftools/">gperftools
  965. package</ulink>.</para></listitem>
  966. </varlistentry>
  967. <varlistentry id="opt.prof_prefix">
  968. <term>
  969. <mallctl>opt.prof_prefix</mallctl>
  970. (<type>const char *</type>)
  971. <literal>r-</literal>
  972. [<option>--enable-prof</option>]
  973. </term>
  974. <listitem><para>Filename prefix for profile dumps. If the prefix is
  975. set to the empty string, no automatic dumps will occur; this is
  976. primarily useful for disabling the automatic final heap dump (which
  977. also disables leak reporting, if enabled). The default prefix is
  978. <filename>jeprof</filename>.</para></listitem>
  979. </varlistentry>
  980. <varlistentry id="opt.prof_active">
  981. <term>
  982. <mallctl>opt.prof_active</mallctl>
  983. (<type>bool</type>)
  984. <literal>r-</literal>
  985. [<option>--enable-prof</option>]
  986. </term>
  987. <listitem><para>Profiling activated/deactivated. This is a secondary
  988. control mechanism that makes it possible to start the application with
  989. profiling enabled (see the <link
  990. linkend="opt.prof"><mallctl>opt.prof</mallctl></link> option) but
  991. inactive, then toggle profiling at any time during program execution
  992. with the <link
  993. linkend="prof.active"><mallctl>prof.active</mallctl></link> mallctl.
  994. This option is enabled by default.</para></listitem>
  995. </varlistentry>
  996. <varlistentry id="opt.lg_prof_sample">
  997. <term>
  998. <mallctl>opt.lg_prof_sample</mallctl>
  999. (<type>ssize_t</type>)
  1000. <literal>r-</literal>
  1001. [<option>--enable-prof</option>]
  1002. </term>
  1003. <listitem><para>Average interval (log base 2) between allocation
  1004. samples, as measured in bytes of allocation activity. Increasing the
  1005. sampling interval decreases profile fidelity, but also decreases the
  1006. computational overhead. The default sample interval is 512 KiB (2^19
  1007. B).</para></listitem>
  1008. </varlistentry>
  1009. <varlistentry id="opt.prof_accum">
  1010. <term>
  1011. <mallctl>opt.prof_accum</mallctl>
  1012. (<type>bool</type>)
  1013. <literal>r-</literal>
  1014. [<option>--enable-prof</option>]
  1015. </term>
  1016. <listitem><para>Reporting of cumulative object/byte counts in profile
  1017. dumps enabled/disabled. If this option is enabled, every unique
  1018. backtrace must be stored for the duration of execution. Depending on
  1019. the application, this can impose a large memory overhead, and the
  1020. cumulative counts are not always of interest. This option is disabled
  1021. by default.</para></listitem>
  1022. </varlistentry>
  1023. <varlistentry id="opt.lg_prof_interval">
  1024. <term>
  1025. <mallctl>opt.lg_prof_interval</mallctl>
  1026. (<type>ssize_t</type>)
  1027. <literal>r-</literal>
  1028. [<option>--enable-prof</option>]
  1029. </term>
  1030. <listitem><para>Average interval (log base 2) between memory profile
  1031. dumps, as measured in bytes of allocation activity. The actual
  1032. interval between dumps may be sporadic because decentralized allocation
  1033. counters are used to avoid synchronization bottlenecks. Profiles are
  1034. dumped to files named according to the pattern
  1035. <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.i&lt;iseq&gt;.heap</filename>,
  1036. where <literal>&lt;prefix&gt;</literal> is controlled by the
  1037. <link
  1038. linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
  1039. option. By default, interval-triggered profile dumping is disabled
  1040. (encoded as -1).
  1041. </para></listitem>
  1042. </varlistentry>
  1043. <varlistentry id="opt.prof_gdump">
  1044. <term>
  1045. <mallctl>opt.prof_gdump</mallctl>
  1046. (<type>bool</type>)
  1047. <literal>r-</literal>
  1048. [<option>--enable-prof</option>]
  1049. </term>
  1050. <listitem><para>Trigger a memory profile dump every time the total
  1051. virtual memory exceeds the previous maximum. Profiles are dumped to
  1052. files named according to the pattern
  1053. <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.u&lt;useq&gt;.heap</filename>,
  1054. where <literal>&lt;prefix&gt;</literal> is controlled by the <link
  1055. linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
  1056. option. This option is disabled by default.</para></listitem>
  1057. </varlistentry>
  1058. <varlistentry id="opt.prof_final">
  1059. <term>
  1060. <mallctl>opt.prof_final</mallctl>
  1061. (<type>bool</type>)
  1062. <literal>r-</literal>
  1063. [<option>--enable-prof</option>]
  1064. </term>
  1065. <listitem><para>Use an
  1066. <citerefentry><refentrytitle>atexit</refentrytitle>
  1067. <manvolnum>3</manvolnum></citerefentry> function to dump final memory
  1068. usage to a file named according to the pattern
  1069. <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.f.heap</filename>,
  1070. where <literal>&lt;prefix&gt;</literal> is controlled by the <link
  1071. linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
  1072. option. This option is enabled by default.</para></listitem>
  1073. </varlistentry>
  1074. <varlistentry id="opt.prof_leak">
  1075. <term>
  1076. <mallctl>opt.prof_leak</mallctl>
  1077. (<type>bool</type>)
  1078. <literal>r-</literal>
  1079. [<option>--enable-prof</option>]
  1080. </term>
  1081. <listitem><para>Leak reporting enabled/disabled. If enabled, use an
  1082. <citerefentry><refentrytitle>atexit</refentrytitle>
  1083. <manvolnum>3</manvolnum></citerefentry> function to report memory leaks
  1084. detected by allocation sampling. See the
  1085. <link linkend="opt.prof"><mallctl>opt.prof</mallctl></link> option for
  1086. information on analyzing heap profile output. This option is disabled
  1087. by default.</para></listitem>
  1088. </varlistentry>
  1089. <varlistentry>
  1090. <term>
  1091. <mallctl>thread.arena</mallctl>
  1092. (<type>unsigned</type>)
  1093. <literal>rw</literal>
  1094. </term>
  1095. <listitem><para>Get or set the arena associated with the calling
  1096. thread. If the specified arena was not initialized beforehand (see the
  1097. <link
  1098. linkend="arenas.initialized"><mallctl>arenas.initialized</mallctl></link>
  1099. mallctl), it will be automatically initialized as a side effect of
  1100. calling this interface.</para></listitem>
  1101. </varlistentry>
  1102. <varlistentry id="thread.allocated">
  1103. <term>
  1104. <mallctl>thread.allocated</mallctl>
  1105. (<type>uint64_t</type>)
  1106. <literal>r-</literal>
  1107. [<option>--enable-stats</option>]
  1108. </term>
  1109. <listitem><para>Get the total number of bytes ever allocated by the
  1110. calling thread. This counter has the potential to wrap around; it is
  1111. up to the application to appropriately interpret the counter in such
  1112. cases.</para></listitem>
  1113. </varlistentry>
  1114. <varlistentry>
  1115. <term>
  1116. <mallctl>thread.allocatedp</mallctl>
  1117. (<type>uint64_t *</type>)
  1118. <literal>r-</literal>
  1119. [<option>--enable-stats</option>]
  1120. </term>
  1121. <listitem><para>Get a pointer to the the value that is returned by the
  1122. <link
  1123. linkend="thread.allocated"><mallctl>thread.allocated</mallctl></link>
  1124. mallctl. This is useful for avoiding the overhead of repeated
  1125. <function>mallctl*<parameter/></function> calls.</para></listitem>
  1126. </varlistentry>
  1127. <varlistentry id="thread.deallocated">
  1128. <term>
  1129. <mallctl>thread.deallocated</mallctl>
  1130. (<type>uint64_t</type>)
  1131. <literal>r-</literal>
  1132. [<option>--enable-stats</option>]
  1133. </term>
  1134. <listitem><para>Get the total number of bytes ever deallocated by the
  1135. calling thread. This counter has the potential to wrap around; it is
  1136. up to the application to appropriately interpret the counter in such
  1137. cases.</para></listitem>
  1138. </varlistentry>
  1139. <varlistentry>
  1140. <term>
  1141. <mallctl>thread.deallocatedp</mallctl>
  1142. (<type>uint64_t *</type>)
  1143. <literal>r-</literal>
  1144. [<option>--enable-stats</option>]
  1145. </term>
  1146. <listitem><para>Get a pointer to the the value that is returned by the
  1147. <link
  1148. linkend="thread.deallocated"><mallctl>thread.deallocated</mallctl></link>
  1149. mallctl. This is useful for avoiding the overhead of repeated
  1150. <function>mallctl*<parameter/></function> calls.</para></listitem>
  1151. </varlistentry>
  1152. <varlistentry>
  1153. <term>
  1154. <mallctl>thread.tcache.enabled</mallctl>
  1155. (<type>bool</type>)
  1156. <literal>rw</literal>
  1157. [<option>--enable-tcache</option>]
  1158. </term>
  1159. <listitem><para>Enable/disable calling thread's tcache. The tcache is
  1160. implicitly flushed as a side effect of becoming
  1161. disabled (see <link
  1162. lenkend="thread.tcache.flush"><mallctl>thread.tcache.flush</mallctl></link>).
  1163. </para></listitem>
  1164. </varlistentry>
  1165. <varlistentry>
  1166. <term>
  1167. <mallctl>thread.tcache.flush</mallctl>
  1168. (<type>void</type>)
  1169. <literal>--</literal>
  1170. [<option>--enable-tcache</option>]
  1171. </term>
  1172. <listitem><para>Flush calling thread's tcache. This interface releases
  1173. all cached objects and internal data structures associated with the
  1174. calling thread's thread-specific cache. Ordinarily, this interface
  1175. need not be called, since automatic periodic incremental garbage
  1176. collection occurs, and the thread cache is automatically discarded when
  1177. a thread exits. However, garbage collection is triggered by allocation
  1178. activity, so it is possible for a thread that stops
  1179. allocating/deallocating to retain its cache indefinitely, in which case
  1180. the developer may find manual flushing useful.</para></listitem>
  1181. </varlistentry>
  1182. <varlistentry id="arena.i.purge">
  1183. <term>
  1184. <mallctl>arena.&lt;i&gt;.purge</mallctl>
  1185. (<type>unsigned</type>)
  1186. <literal>--</literal>
  1187. </term>
  1188. <listitem><para>Purge unused dirty pages for arena &lt;i&gt;, or for
  1189. all arenas if &lt;i&gt; equals <link
  1190. linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link>.
  1191. </para></listitem>
  1192. </varlistentry>
  1193. <varlistentry id="arena.i.dss">
  1194. <term>
  1195. <mallctl>arena.&lt;i&gt;.dss</mallctl>
  1196. (<type>const char *</type>)
  1197. <literal>rw</literal>
  1198. </term>
  1199. <listitem><para>Set the precedence of dss allocation as related to mmap
  1200. allocation for arena &lt;i&gt;, or for all arenas if &lt;i&gt; equals
  1201. <link
  1202. linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link>. See
  1203. <link linkend="opt.dss"><mallctl>opt.dss</mallctl></link> for supported
  1204. settings.
  1205. </para></listitem>
  1206. </varlistentry>
  1207. <varlistentry id="arenas.narenas">
  1208. <term>
  1209. <mallctl>arenas.narenas</mallctl>
  1210. (<type>unsigned</type>)
  1211. <literal>r-</literal>
  1212. </term>
  1213. <listitem><para>Current limit on number of arenas.</para></listitem>
  1214. </varlistentry>
  1215. <varlistentry id="arenas.initialized">
  1216. <term>
  1217. <mallctl>arenas.initialized</mallctl>
  1218. (<type>bool *</type>)
  1219. <literal>r-</literal>
  1220. </term>
  1221. <listitem><para>An array of <link
  1222. linkend="arenas.narenas"><mallctl>arenas.narenas</mallctl></link>
  1223. booleans. Each boolean indicates whether the corresponding arena is
  1224. initialized.</para></listitem>
  1225. </varlistentry>
  1226. <varlistentry>
  1227. <term>
  1228. <mallctl>arenas.quantum</mallctl>
  1229. (<type>size_t</type>)
  1230. <literal>r-</literal>
  1231. </term>
  1232. <listitem><para>Quantum size.</para></listitem>
  1233. </varlistentry>
  1234. <varlistentry>
  1235. <term>
  1236. <mallctl>arenas.page</mallctl>
  1237. (<type>size_t</type>)
  1238. <literal>r-</literal>
  1239. </term>
  1240. <listitem><para>Page size.</para></listitem>
  1241. </varlistentry>
  1242. <varlistentry>
  1243. <term>
  1244. <mallctl>arenas.tcache_max</mallctl>
  1245. (<type>size_t</type>)
  1246. <literal>r-</literal>
  1247. [<option>--enable-tcache</option>]
  1248. </term>
  1249. <listitem><para>Maximum thread-cached size class.</para></listitem>
  1250. </varlistentry>
  1251. <varlistentry>
  1252. <term>
  1253. <mallctl>arenas.nbins</mallctl>
  1254. (<type>unsigned</type>)
  1255. <literal>r-</literal>
  1256. </term>
  1257. <listitem><para>Number of bin size classes.</para></listitem>
  1258. </varlistentry>
  1259. <varlistentry>
  1260. <term>
  1261. <mallctl>arenas.nhbins</mallctl>
  1262. (<type>unsigned</type>)
  1263. <literal>r-</literal>
  1264. [<option>--enable-tcache</option>]
  1265. </term>
  1266. <listitem><para>Total number of thread cache bin size
  1267. classes.</para></listitem>
  1268. </varlistentry>
  1269. <varlistentry id="arenas.bin.i.size">
  1270. <term>
  1271. <mallctl>arenas.bin.&lt;i&gt;.size</mallctl>
  1272. (<type>size_t</type>)
  1273. <literal>r-</literal>
  1274. </term>
  1275. <listitem><para>Maximum size supported by size class.</para></listitem>
  1276. </varlistentry>
  1277. <varlistentry>
  1278. <term>
  1279. <mallctl>arenas.bin.&lt;i&gt;.nregs</mallctl>
  1280. (<type>uint32_t</type>)
  1281. <literal>r-</literal>
  1282. </term>
  1283. <listitem><para>Number of regions per page run.</para></listitem>
  1284. </varlistentry>
  1285. <varlistentry>
  1286. <term>
  1287. <mallctl>arenas.bin.&lt;i&gt;.run_size</mallctl>
  1288. (<type>size_t</type>)
  1289. <literal>r-</literal>
  1290. </term>
  1291. <listitem><para>Number of bytes per page run.</para></listitem>
  1292. </varlistentry>
  1293. <varlistentry>
  1294. <term>
  1295. <mallctl>arenas.nlruns</mallctl>
  1296. (<type>size_t</type>)
  1297. <literal>r-</literal>
  1298. </term>
  1299. <listitem><para>Total number of large size classes.</para></listitem>
  1300. </varlistentry>
  1301. <varlistentry>
  1302. <term>
  1303. <mallctl>arenas.lrun.&lt;i&gt;.size</mallctl>
  1304. (<type>size_t</type>)
  1305. <literal>r-</literal>
  1306. </term>
  1307. <listitem><para>Maximum size supported by this large size
  1308. class.</para></listitem>
  1309. </varlistentry>
  1310. <varlistentry>
  1311. <term>
  1312. <mallctl>arenas.purge</mallctl>
  1313. (<type>unsigned</type>)
  1314. <literal>-w</literal>
  1315. </term>
  1316. <listitem><para>Purge unused dirty pages for the specified arena, or
  1317. for all arenas if none is specified.</para></listitem>
  1318. </varlistentry>
  1319. <varlistentry>
  1320. <term>
  1321. <mallctl>arenas.extend</mallctl>
  1322. (<type>unsigned</type>)
  1323. <literal>r-</literal>
  1324. </term>
  1325. <listitem><para>Extend the array of arenas by appending a new arena,
  1326. and returning the new arena index.</para></listitem>
  1327. </varlistentry>
  1328. <varlistentry id="prof.active">
  1329. <term>
  1330. <mallctl>prof.active</mallctl>
  1331. (<type>bool</type>)
  1332. <literal>rw</literal>
  1333. [<option>--enable-prof</option>]
  1334. </term>
  1335. <listitem><para>Control whether sampling is currently active. See the
  1336. <link
  1337. linkend="opt.prof_active"><mallctl>opt.prof_active</mallctl></link>
  1338. option for additional information.
  1339. </para></listitem>
  1340. </varlistentry>
  1341. <varlistentry>
  1342. <term>
  1343. <mallctl>prof.dump</mallctl>
  1344. (<type>const char *</type>)
  1345. <literal>-w</literal>
  1346. [<option>--enable-prof</option>]
  1347. </term>
  1348. <listitem><para>Dump a memory profile to the specified file, or if NULL
  1349. is specified, to a file according to the pattern
  1350. <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.m&lt;mseq&gt;.heap</filename>,
  1351. where <literal>&lt;prefix&gt;</literal> is controlled by the
  1352. <link
  1353. linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
  1354. option.</para></listitem>
  1355. </varlistentry>
  1356. <varlistentry>
  1357. <term>
  1358. <mallctl>prof.interval</mallctl>
  1359. (<type>uint64_t</type>)
  1360. <literal>r-</literal>
  1361. [<option>--enable-prof</option>]
  1362. </term>
  1363. <listitem><para>Average number of bytes allocated between
  1364. inverval-based profile dumps. See the
  1365. <link
  1366. linkend="opt.lg_prof_interval"><mallctl>opt.lg_prof_interval</mallctl></link>
  1367. option for additional information.</para></listitem>
  1368. </varlistentry>
  1369. <varlistentry id="stats.cactive">
  1370. <term>
  1371. <mallctl>stats.cactive</mallctl>
  1372. (<type>size_t *</type>)
  1373. <literal>r-</literal>
  1374. [<option>--enable-stats</option>]
  1375. </term>
  1376. <listitem><para>Pointer to a counter that contains an approximate count
  1377. of the current number of bytes in active pages. The estimate may be
  1378. high, but never low, because each arena rounds up to the nearest
  1379. multiple of the chunk size when computing its contribution to the
  1380. counter. Note that the <link
  1381. linkend="epoch"><mallctl>epoch</mallctl></link> mallctl has no bearing
  1382. on this counter. Furthermore, counter consistency is maintained via
  1383. atomic operations, so it is necessary to use an atomic operation in
  1384. order to guarantee a consistent read when dereferencing the pointer.
  1385. </para></listitem>
  1386. </varlistentry>
  1387. <varlistentry id="stats.allocated">
  1388. <term>
  1389. <mallctl>stats.allocated</mallctl>
  1390. (<type>size_t</type>)
  1391. <literal>r-</literal>
  1392. [<option>--enable-stats</option>]
  1393. </term>
  1394. <listitem><para>Total number of bytes allocated by the
  1395. application.</para></listitem>
  1396. </varlistentry>
  1397. <varlistentry id="stats.active">
  1398. <term>
  1399. <mallctl>stats.active</mallctl>
  1400. (<type>size_t</type>)
  1401. <literal>r-</literal>
  1402. [<option>--enable-stats</option>]
  1403. </term>
  1404. <listitem><para>Total number of bytes in active pages allocated by the
  1405. application. This is a multiple of the page size, and greater than or
  1406. equal to <link
  1407. linkend="stats.allocated"><mallctl>stats.allocated</mallctl></link>.
  1408. This does not include <link linkend="stats.arenas.i.pdirty">
  1409. <mallctl>stats.arenas.&lt;i&gt;.pdirty</mallctl></link> and pages
  1410. entirely devoted to allocator metadata.</para></listitem>
  1411. </varlistentry>
  1412. <varlistentry>
  1413. <term>
  1414. <mallctl>stats.mapped</mallctl>
  1415. (<type>size_t</type>)
  1416. <literal>r-</literal>
  1417. [<option>--enable-stats</option>]
  1418. </term>
  1419. <listitem><para>Total number of bytes in chunks mapped on behalf of the
  1420. application. This is a multiple of the chunk size, and is at least as
  1421. large as <link
  1422. linkend="stats.active"><mallctl>stats.active</mallctl></link>. This
  1423. does not include inactive chunks.</para></listitem>
  1424. </varlistentry>
  1425. <varlistentry>
  1426. <term>
  1427. <mallctl>stats.chunks.current</mallctl>
  1428. (<type>size_t</type>)
  1429. <literal>r-</literal>
  1430. [<option>--enable-stats</option>]
  1431. </term>
  1432. <listitem><para>Total number of chunks actively mapped on behalf of the
  1433. application. This does not include inactive chunks.
  1434. </para></listitem>
  1435. </varlistentry>
  1436. <varlistentry>
  1437. <term>
  1438. <mallctl>stats.chunks.total</mallctl>
  1439. (<type>uint64_t</type>)
  1440. <literal>r-</literal>
  1441. [<option>--enable-stats</option>]
  1442. </term>
  1443. <listitem><para>Cumulative number of chunks allocated.</para></listitem>
  1444. </varlistentry>
  1445. <varlistentry>
  1446. <term>
  1447. <mallctl>stats.chunks.high</mallctl>
  1448. (<type>size_t</type>)
  1449. <literal>r-</literal>
  1450. [<option>--enable-stats</option>]
  1451. </term>
  1452. <listitem><para>Maximum number of active chunks at any time thus far.
  1453. </para></listitem>
  1454. </varlistentry>
  1455. <varlistentry>
  1456. <term>
  1457. <mallctl>stats.huge.allocated</mallctl>
  1458. (<type>size_t</type>)
  1459. <literal>r-</literal>
  1460. [<option>--enable-stats</option>]
  1461. </term>
  1462. <listitem><para>Number of bytes currently allocated by huge objects.
  1463. </para></listitem>
  1464. </varlistentry>
  1465. <varlistentry>
  1466. <term>
  1467. <mallctl>stats.huge.nmalloc</mallctl>
  1468. (<type>uint64_t</type>)
  1469. <literal>r-</literal>
  1470. [<option>--enable-stats</option>]
  1471. </term>
  1472. <listitem><para>Cumulative number of huge allocation requests.
  1473. </para></listitem>
  1474. </varlistentry>
  1475. <varlistentry>
  1476. <term>
  1477. <mallctl>stats.huge.ndalloc</mallctl>
  1478. (<type>uint64_t</type>)
  1479. <literal>r-</literal>
  1480. [<option>--enable-stats</option>]
  1481. </term>
  1482. <listitem><para>Cumulative number of huge deallocation requests.
  1483. </para></listitem>
  1484. </varlistentry>
  1485. <varlistentry>
  1486. <term>
  1487. <mallctl>stats.arenas.&lt;i&gt;.dss</mallctl>
  1488. (<type>const char *</type>)
  1489. <literal>r-</literal>
  1490. </term>
  1491. <listitem><para>dss (<citerefentry><refentrytitle>sbrk</refentrytitle>
  1492. <manvolnum>2</manvolnum></citerefentry>) allocation precedence as
  1493. related to <citerefentry><refentrytitle>mmap</refentrytitle>
  1494. <manvolnum>2</manvolnum></citerefentry> allocation. See <link
  1495. linkend="opt.dss"><mallctl>opt.dss</mallctl></link> for details.
  1496. </para></listitem>
  1497. </varlistentry>
  1498. <varlistentry>
  1499. <term>
  1500. <mallctl>stats.arenas.&lt;i&gt;.nthreads</mallctl>
  1501. (<type>unsigned</type>)
  1502. <literal>r-</literal>
  1503. </term>
  1504. <listitem><para>Number of threads currently assigned to
  1505. arena.</para></listitem>
  1506. </varlistentry>
  1507. <varlistentry>
  1508. <term>
  1509. <mallctl>stats.arenas.&lt;i&gt;.pactive</mallctl>
  1510. (<type>size_t</type>)
  1511. <literal>r-</literal>
  1512. </term>
  1513. <listitem><para>Number of pages in active runs.</para></listitem>
  1514. </varlistentry>
  1515. <varlistentry id="stats.arenas.i.pdirty">
  1516. <term>
  1517. <mallctl>stats.arenas.&lt;i&gt;.pdirty</mallctl>
  1518. (<type>size_t</type>)
  1519. <literal>r-</literal>
  1520. </term>
  1521. <listitem><para>Number of pages within unused runs that are potentially
  1522. dirty, and for which <function>madvise<parameter>...</parameter>
  1523. <parameter><constant>MADV_DONTNEED</constant></parameter></function> or
  1524. similar has not been called.</para></listitem>
  1525. </varlistentry>
  1526. <varlistentry>
  1527. <term>
  1528. <mallctl>stats.arenas.&lt;i&gt;.mapped</mallctl>
  1529. (<type>size_t</type>)
  1530. <literal>r-</literal>
  1531. [<option>--enable-stats</option>]
  1532. </term>
  1533. <listitem><para>Number of mapped bytes.</para></listitem>
  1534. </varlistentry>
  1535. <varlistentry>
  1536. <term>
  1537. <mallctl>stats.arenas.&lt;i&gt;.npurge</mallctl>
  1538. (<type>uint64_t</type>)
  1539. <literal>r-</literal>
  1540. [<option>--enable-stats</option>]
  1541. </term>
  1542. <listitem><para>Number of dirty page purge sweeps performed.
  1543. </para></listitem>
  1544. </varlistentry>
  1545. <varlistentry>
  1546. <term>
  1547. <mallctl>stats.arenas.&lt;i&gt;.nmadvise</mallctl>
  1548. (<type>uint64_t</type>)
  1549. <literal>r-</literal>
  1550. [<option>--enable-stats</option>]
  1551. </term>
  1552. <listitem><para>Number of <function>madvise<parameter>...</parameter>
  1553. <parameter><constant>MADV_DONTNEED</constant></parameter></function> or
  1554. similar calls made to purge dirty pages.</para></listitem>
  1555. </varlistentry>
  1556. <varlistentry>
  1557. <term>
  1558. <mallctl>stats.arenas.&lt;i&gt;.npurged</mallctl>
  1559. (<type>uint64_t</type>)
  1560. <literal>r-</literal>
  1561. [<option>--enable-stats</option>]
  1562. </term>
  1563. <listitem><para>Number of pages purged.</para></listitem>
  1564. </varlistentry>
  1565. <varlistentry>
  1566. <term>
  1567. <mallctl>stats.arenas.&lt;i&gt;.small.allocated</mallctl>
  1568. (<type>size_t</type>)
  1569. <literal>r-</literal>
  1570. [<option>--enable-stats</option>]
  1571. </term>
  1572. <listitem><para>Number of bytes currently allocated by small objects.
  1573. </para></listitem>
  1574. </varlistentry>
  1575. <varlistentry>
  1576. <term>
  1577. <mallctl>stats.arenas.&lt;i&gt;.small.nmalloc</mallctl>
  1578. (<type>uint64_t</type>)
  1579. <literal>r-</literal>
  1580. [<option>--enable-stats</option>]
  1581. </term>
  1582. <listitem><para>Cumulative number of allocation requests served by
  1583. small bins.</para></listitem>
  1584. </varlistentry>
  1585. <varlistentry>
  1586. <term>
  1587. <mallctl>stats.arenas.&lt;i&gt;.small.ndalloc</mallctl>
  1588. (<type>uint64_t</type>)
  1589. <literal>r-</literal>
  1590. [<option>--enable-stats</option>]
  1591. </term>
  1592. <listitem><para>Cumulative number of small objects returned to bins.
  1593. </para></listitem>
  1594. </varlistentry>
  1595. <varlistentry>
  1596. <term>
  1597. <mallctl>stats.arenas.&lt;i&gt;.small.nrequests</mallctl>
  1598. (<type>uint64_t</type>)
  1599. <literal>r-</literal>
  1600. [<option>--enable-stats</option>]
  1601. </term>
  1602. <listitem><para>Cumulative number of small allocation requests.
  1603. </para></listitem>
  1604. </varlistentry>
  1605. <varlistentry>
  1606. <term>
  1607. <mallctl>stats.arenas.&lt;i&gt;.large.allocated</mallctl>
  1608. (<type>size_t</type>)
  1609. <literal>r-</literal>
  1610. [<option>--enable-stats</option>]
  1611. </term>
  1612. <listitem><para>Number of bytes currently allocated by large objects.
  1613. </para></listitem>
  1614. </varlistentry>
  1615. <varlistentry>
  1616. <term>
  1617. <mallctl>stats.arenas.&lt;i&gt;.large.nmalloc</mallctl>
  1618. (<type>uint64_t</type>)
  1619. <literal>r-</literal>
  1620. [<option>--enable-stats</option>]
  1621. </term>
  1622. <listitem><para>Cumulative number of large allocation requests served
  1623. directly by the arena.</para></listitem>
  1624. </varlistentry>
  1625. <varlistentry>
  1626. <term>
  1627. <mallctl>stats.arenas.&lt;i&gt;.large.ndalloc</mallctl>
  1628. (<type>uint64_t</type>)
  1629. <literal>r-</literal>
  1630. [<option>--enable-stats</option>]
  1631. </term>
  1632. <listitem><para>Cumulative number of large deallocation requests served
  1633. directly by the arena.</para></listitem>
  1634. </varlistentry>
  1635. <varlistentry>
  1636. <term>
  1637. <mallctl>stats.arenas.&lt;i&gt;.large.nrequests</mallctl>
  1638. (<type>uint64_t</type>)
  1639. <literal>r-</literal>
  1640. [<option>--enable-stats</option>]
  1641. </term>
  1642. <listitem><para>Cumulative number of large allocation requests.
  1643. </para></listitem>
  1644. </varlistentry>
  1645. <varlistentry>
  1646. <term>
  1647. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.allocated</mallctl>
  1648. (<type>size_t</type>)
  1649. <literal>r-</literal>
  1650. [<option>--enable-stats</option>]
  1651. </term>
  1652. <listitem><para>Current number of bytes allocated by
  1653. bin.</para></listitem>
  1654. </varlistentry>
  1655. <varlistentry>
  1656. <term>
  1657. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nmalloc</mallctl>
  1658. (<type>uint64_t</type>)
  1659. <literal>r-</literal>
  1660. [<option>--enable-stats</option>]
  1661. </term>
  1662. <listitem><para>Cumulative number of allocations served by bin.
  1663. </para></listitem>
  1664. </varlistentry>
  1665. <varlistentry>
  1666. <term>
  1667. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.ndalloc</mallctl>
  1668. (<type>uint64_t</type>)
  1669. <literal>r-</literal>
  1670. [<option>--enable-stats</option>]
  1671. </term>
  1672. <listitem><para>Cumulative number of allocations returned to bin.
  1673. </para></listitem>
  1674. </varlistentry>
  1675. <varlistentry>
  1676. <term>
  1677. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nrequests</mallctl>
  1678. (<type>uint64_t</type>)
  1679. <literal>r-</literal>
  1680. [<option>--enable-stats</option>]
  1681. </term>
  1682. <listitem><para>Cumulative number of allocation
  1683. requests.</para></listitem>
  1684. </varlistentry>
  1685. <varlistentry>
  1686. <term>
  1687. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nfills</mallctl>
  1688. (<type>uint64_t</type>)
  1689. <literal>r-</literal>
  1690. [<option>--enable-stats</option> <option>--enable-tcache</option>]
  1691. </term>
  1692. <listitem><para>Cumulative number of tcache fills.</para></listitem>
  1693. </varlistentry>
  1694. <varlistentry>
  1695. <term>
  1696. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nflushes</mallctl>
  1697. (<type>uint64_t</type>)
  1698. <literal>r-</literal>
  1699. [<option>--enable-stats</option> <option>--enable-tcache</option>]
  1700. </term>
  1701. <listitem><para>Cumulative number of tcache flushes.</para></listitem>
  1702. </varlistentry>
  1703. <varlistentry>
  1704. <term>
  1705. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nruns</mallctl>
  1706. (<type>uint64_t</type>)
  1707. <literal>r-</literal>
  1708. [<option>--enable-stats</option>]
  1709. </term>
  1710. <listitem><para>Cumulative number of runs created.</para></listitem>
  1711. </varlistentry>
  1712. <varlistentry>
  1713. <term>
  1714. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nreruns</mallctl>
  1715. (<type>uint64_t</type>)
  1716. <literal>r-</literal>
  1717. [<option>--enable-stats</option>]
  1718. </term>
  1719. <listitem><para>Cumulative number of times the current run from which
  1720. to allocate changed.</para></listitem>
  1721. </varlistentry>
  1722. <varlistentry>
  1723. <term>
  1724. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.curruns</mallctl>
  1725. (<type>size_t</type>)
  1726. <literal>r-</literal>
  1727. [<option>--enable-stats</option>]
  1728. </term>
  1729. <listitem><para>Current number of runs.</para></listitem>
  1730. </varlistentry>
  1731. <varlistentry>
  1732. <term>
  1733. <mallctl>stats.arenas.&lt;i&gt;.lruns.&lt;j&gt;.nmalloc</mallctl>
  1734. (<type>uint64_t</type>)
  1735. <literal>r-</literal>
  1736. [<option>--enable-stats</option>]
  1737. </term>
  1738. <listitem><para>Cumulative number of allocation requests for this size
  1739. class served directly by the arena.</para></listitem>
  1740. </varlistentry>
  1741. <varlistentry>
  1742. <term>
  1743. <mallctl>stats.arenas.&lt;i&gt;.lruns.&lt;j&gt;.ndalloc</mallctl>
  1744. (<type>uint64_t</type>)
  1745. <literal>r-</literal>
  1746. [<option>--enable-stats</option>]
  1747. </term>
  1748. <listitem><para>Cumulative number of deallocation requests for this
  1749. size class served directly by the arena.</para></listitem>
  1750. </varlistentry>
  1751. <varlistentry>
  1752. <term>
  1753. <mallctl>stats.arenas.&lt;i&gt;.lruns.&lt;j&gt;.nrequests</mallctl>
  1754. (<type>uint64_t</type>)
  1755. <literal>r-</literal>
  1756. [<option>--enable-stats</option>]
  1757. </term>
  1758. <listitem><para>Cumulative number of allocation requests for this size
  1759. class.</para></listitem>
  1760. </varlistentry>
  1761. <varlistentry>
  1762. <term>
  1763. <mallctl>stats.arenas.&lt;i&gt;.lruns.&lt;j&gt;.curruns</mallctl>
  1764. (<type>size_t</type>)
  1765. <literal>r-</literal>
  1766. [<option>--enable-stats</option>]
  1767. </term>
  1768. <listitem><para>Current number of runs for this size class.
  1769. </para></listitem>
  1770. </varlistentry>
  1771. </variablelist>
  1772. </refsect1>
  1773. <refsect1 id="debugging_malloc_problems">
  1774. <title>DEBUGGING MALLOC PROBLEMS</title>
  1775. <para>When debugging, it is a good idea to configure/build jemalloc with
  1776. the <option>--enable-debug</option> and <option>--enable-fill</option>
  1777. options, and recompile the program with suitable options and symbols for
  1778. debugger support. When so configured, jemalloc incorporates a wide variety
  1779. of run-time assertions that catch application errors such as double-free,
  1780. write-after-free, etc.</para>
  1781. <para>Programs often accidentally depend on &ldquo;uninitialized&rdquo;
  1782. memory actually being filled with zero bytes. Junk filling
  1783. (see the <link linkend="opt.junk"><mallctl>opt.junk</mallctl></link>
  1784. option) tends to expose such bugs in the form of obviously incorrect
  1785. results and/or coredumps. Conversely, zero
  1786. filling (see the <link
  1787. linkend="opt.zero"><mallctl>opt.zero</mallctl></link> option) eliminates
  1788. the symptoms of such bugs. Between these two options, it is usually
  1789. possible to quickly detect, diagnose, and eliminate such bugs.</para>
  1790. <para>This implementation does not provide much detail about the problems
  1791. it detects, because the performance impact for storing such information
  1792. would be prohibitive. However, jemalloc does integrate with the most
  1793. excellent <ulink url="http://valgrind.org/">Valgrind</ulink> tool if the
  1794. <option>--enable-valgrind</option> configuration option is enabled.</para>
  1795. </refsect1>
  1796. <refsect1 id="diagnostic_messages">
  1797. <title>DIAGNOSTIC MESSAGES</title>
  1798. <para>If any of the memory allocation/deallocation functions detect an
  1799. error or warning condition, a message will be printed to file descriptor
  1800. <constant>STDERR_FILENO</constant>. Errors will result in the process
  1801. dumping core. If the <link
  1802. linkend="opt.abort"><mallctl>opt.abort</mallctl></link> option is set, most
  1803. warnings are treated as errors.</para>
  1804. <para>The <varname>malloc_message</varname> variable allows the programmer
  1805. to override the function which emits the text strings forming the errors
  1806. and warnings if for some reason the <constant>STDERR_FILENO</constant> file
  1807. descriptor is not suitable for this.
  1808. <function>malloc_message<parameter/></function> takes the
  1809. <parameter>cbopaque</parameter> pointer argument that is
  1810. <constant>NULL</constant> unless overridden by the arguments in a call to
  1811. <function>malloc_stats_print<parameter/></function>, followed by a string
  1812. pointer. Please note that doing anything which tries to allocate memory in
  1813. this function is likely to result in a crash or deadlock.</para>
  1814. <para>All messages are prefixed by
  1815. &ldquo;<computeroutput>&lt;jemalloc&gt;: </computeroutput>&rdquo;.</para>
  1816. </refsect1>
  1817. <refsect1 id="return_values">
  1818. <title>RETURN VALUES</title>
  1819. <refsect2>
  1820. <title>Standard API</title>
  1821. <para>The <function>malloc<parameter/></function> and
  1822. <function>calloc<parameter/></function> functions return a pointer to the
  1823. allocated memory if successful; otherwise a <constant>NULL</constant>
  1824. pointer is returned and <varname>errno</varname> is set to
  1825. <errorname>ENOMEM</errorname>.</para>
  1826. <para>The <function>posix_memalign<parameter/></function> function
  1827. returns the value 0 if successful; otherwise it returns an error value.
  1828. The <function>posix_memalign<parameter/></function> function will fail
  1829. if:
  1830. <variablelist>
  1831. <varlistentry>
  1832. <term><errorname>EINVAL</errorname></term>
  1833. <listitem><para>The <parameter>alignment</parameter> parameter is
  1834. not a power of 2 at least as large as
  1835. <code language="C">sizeof(<type>void *</type>)</code>.
  1836. </para></listitem>
  1837. </varlistentry>
  1838. <varlistentry>
  1839. <term><errorname>ENOMEM</errorname></term>
  1840. <listitem><para>Memory allocation error.</para></listitem>
  1841. </varlistentry>
  1842. </variablelist>
  1843. </para>
  1844. <para>The <function>aligned_alloc<parameter/></function> function returns
  1845. a pointer to the allocated memory if successful; otherwise a
  1846. <constant>NULL</constant> pointer is returned and
  1847. <varname>errno</varname> is set. The
  1848. <function>aligned_alloc<parameter/></function> function will fail if:
  1849. <variablelist>
  1850. <varlistentry>
  1851. <term><errorname>EINVAL</errorname></term>
  1852. <listitem><para>The <parameter>alignment</parameter> parameter is
  1853. not a power of 2.
  1854. </para></listitem>
  1855. </varlistentry>
  1856. <varlistentry>
  1857. <term><errorname>ENOMEM</errorname></term>
  1858. <listitem><para>Memory allocation error.</para></listitem>
  1859. </varlistentry>
  1860. </variablelist>
  1861. </para>
  1862. <para>The <function>realloc<parameter/></function> function returns a
  1863. pointer, possibly identical to <parameter>ptr</parameter>, to the
  1864. allocated memory if successful; otherwise a <constant>NULL</constant>
  1865. pointer is returned, and <varname>errno</varname> is set to
  1866. <errorname>ENOMEM</errorname> if the error was the result of an
  1867. allocation failure. The <function>realloc<parameter/></function>
  1868. function always leaves the original buffer intact when an error occurs.
  1869. </para>
  1870. <para>The <function>free<parameter/></function> function returns no
  1871. value.</para>
  1872. </refsect2>
  1873. <refsect2>
  1874. <title>Non-standard API</title>
  1875. <para>The <function>malloc_usable_size<parameter/></function> function
  1876. returns the usable size of the allocation pointed to by
  1877. <parameter>ptr</parameter>. </para>
  1878. <para>The <function>mallctl<parameter/></function>,
  1879. <function>mallctlnametomib<parameter/></function>, and
  1880. <function>mallctlbymib<parameter/></function> functions return 0 on
  1881. success; otherwise they return an error value. The functions will fail
  1882. if:
  1883. <variablelist>
  1884. <varlistentry>
  1885. <term><errorname>EINVAL</errorname></term>
  1886. <listitem><para><parameter>newp</parameter> is not
  1887. <constant>NULL</constant>, and <parameter>newlen</parameter> is too
  1888. large or too small. Alternatively, <parameter>*oldlenp</parameter>
  1889. is too large or too small; in this case as much data as possible
  1890. are read despite the error.</para></listitem>
  1891. </varlistentry>
  1892. <varlistentry>
  1893. <term><errorname>ENOMEM</errorname></term>
  1894. <listitem><para><parameter>*oldlenp</parameter> is too short to
  1895. hold the requested value.</para></listitem>
  1896. </varlistentry>
  1897. <varlistentry>
  1898. <term><errorname>ENOENT</errorname></term>
  1899. <listitem><para><parameter>name</parameter> or
  1900. <parameter>mib</parameter> specifies an unknown/invalid
  1901. value.</para></listitem>
  1902. </varlistentry>
  1903. <varlistentry>
  1904. <term><errorname>EPERM</errorname></term>
  1905. <listitem><para>Attempt to read or write void value, or attempt to
  1906. write read-only value.</para></listitem>
  1907. </varlistentry>
  1908. <varlistentry>
  1909. <term><errorname>EAGAIN</errorname></term>
  1910. <listitem><para>A memory allocation failure
  1911. occurred.</para></listitem>
  1912. </varlistentry>
  1913. <varlistentry>
  1914. <term><errorname>EFAULT</errorname></term>
  1915. <listitem><para>An interface with side effects failed in some way
  1916. not directly related to <function>mallctl*<parameter/></function>
  1917. read/write processing.</para></listitem>
  1918. </varlistentry>
  1919. </variablelist>
  1920. </para>
  1921. </refsect2>
  1922. <refsect2>
  1923. <title>Experimental API</title>
  1924. <para>The <function>allocm<parameter/></function>,
  1925. <function>rallocm<parameter/></function>,
  1926. <function>sallocm<parameter/></function>,
  1927. <function>dallocm<parameter/></function>, and
  1928. <function>nallocm<parameter/></function> functions return
  1929. <constant>ALLOCM_SUCCESS</constant> on success; otherwise they return an
  1930. error value. The <function>allocm<parameter/></function>,
  1931. <function>rallocm<parameter/></function>, and
  1932. <function>nallocm<parameter/></function> functions will fail if:
  1933. <variablelist>
  1934. <varlistentry>
  1935. <term><errorname>ALLOCM_ERR_OOM</errorname></term>
  1936. <listitem><para>Out of memory. Insufficient contiguous memory was
  1937. available to service the allocation request. The
  1938. <function>allocm<parameter/></function> function additionally sets
  1939. <parameter>*ptr</parameter> to <constant>NULL</constant>, whereas
  1940. the <function>rallocm<parameter/></function> function leaves
  1941. <constant>*ptr</constant> unmodified.</para></listitem>
  1942. </varlistentry>
  1943. </variablelist>
  1944. The <function>rallocm<parameter/></function> function will also
  1945. fail if:
  1946. <variablelist>
  1947. <varlistentry>
  1948. <term><errorname>ALLOCM_ERR_NOT_MOVED</errorname></term>
  1949. <listitem><para><constant>ALLOCM_NO_MOVE</constant> was specified,
  1950. but the reallocation request could not be serviced without moving
  1951. the object.</para></listitem>
  1952. </varlistentry>
  1953. </variablelist>
  1954. </para>
  1955. </refsect2>
  1956. </refsect1>
  1957. <refsect1 id="environment">
  1958. <title>ENVIRONMENT</title>
  1959. <para>The following environment variable affects the execution of the
  1960. allocation functions:
  1961. <variablelist>
  1962. <varlistentry>
  1963. <term><envar>MALLOC_CONF</envar></term>
  1964. <listitem><para>If the environment variable
  1965. <envar>MALLOC_CONF</envar> is set, the characters it contains
  1966. will be interpreted as options.</para></listitem>
  1967. </varlistentry>
  1968. </variablelist>
  1969. </para>
  1970. </refsect1>
  1971. <refsect1 id="examples">
  1972. <title>EXAMPLES</title>
  1973. <para>To dump core whenever a problem occurs:
  1974. <screen>ln -s 'abort:true' /etc/malloc.conf</screen>
  1975. </para>
  1976. <para>To specify in the source a chunk size that is 16 MiB:
  1977. <programlisting language="C"><![CDATA[
  1978. malloc_conf = "lg_chunk:24";]]></programlisting></para>
  1979. </refsect1>
  1980. <refsect1 id="see_also">
  1981. <title>SEE ALSO</title>
  1982. <para><citerefentry><refentrytitle>madvise</refentrytitle>
  1983. <manvolnum>2</manvolnum></citerefentry>,
  1984. <citerefentry><refentrytitle>mmap</refentrytitle>
  1985. <manvolnum>2</manvolnum></citerefentry>,
  1986. <citerefentry><refentrytitle>sbrk</refentrytitle>
  1987. <manvolnum>2</manvolnum></citerefentry>,
  1988. <citerefentry><refentrytitle>utrace</refentrytitle>
  1989. <manvolnum>2</manvolnum></citerefentry>,
  1990. <citerefentry><refentrytitle>alloca</refentrytitle>
  1991. <manvolnum>3</manvolnum></citerefentry>,
  1992. <citerefentry><refentrytitle>atexit</refentrytitle>
  1993. <manvolnum>3</manvolnum></citerefentry>,
  1994. <citerefentry><refentrytitle>getpagesize</refentrytitle>
  1995. <manvolnum>3</manvolnum></citerefentry></para>
  1996. </refsect1>
  1997. <refsect1 id="standards">
  1998. <title>STANDARDS</title>
  1999. <para>The <function>malloc<parameter/></function>,
  2000. <function>calloc<parameter/></function>,
  2001. <function>realloc<parameter/></function>, and
  2002. <function>free<parameter/></function> functions conform to ISO/IEC
  2003. 9899:1990 (&ldquo;ISO C90&rdquo;).</para>
  2004. <para>The <function>posix_memalign<parameter/></function> function conforms
  2005. to IEEE Std 1003.1-2001 (&ldquo;POSIX.1&rdquo;).</para>
  2006. </refsect1>
  2007. </refentry>