jemalloc.xml.in 121 KB

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