2
0

jemalloc.xml.in 100 KB

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