2
0

jemalloc.xml.in 151 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379
  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://jemalloc.net/">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()</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()</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()</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()</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()</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()</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()</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()</function> function behaves identically to
  218. <function>malloc()</function> for the specified size.</para>
  219. <para>The <function>free()</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()</function>,
  227. <function>rallocx()</function>,
  228. <function>xallocx()</function>,
  229. <function>sallocx()</function>,
  230. <function>dallocx()</function>,
  231. <function>sdallocx()</function>, and
  232. <function>nallocx()</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()</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>.</para>
  300. <para>The <function>rallocx()</function> function resizes the
  301. allocation at <parameter>ptr</parameter> to be at least
  302. <parameter>size</parameter> bytes, and returns a pointer to the base
  303. address of the resulting allocation, which may or may not have moved from
  304. its original location. Behavior is undefined if
  305. <parameter>size</parameter> is <constant>0</constant>.</para>
  306. <para>The <function>xallocx()</function> function resizes the
  307. allocation at <parameter>ptr</parameter> in place to be at least
  308. <parameter>size</parameter> bytes, and returns the real size of the
  309. allocation. If <parameter>extra</parameter> is non-zero, an attempt is
  310. made to resize the allocation to be at least <code
  311. language="C">(<parameter>size</parameter> +
  312. <parameter>extra</parameter>)</code> bytes, though inability to allocate
  313. the extra byte(s) will not by itself result in failure to resize.
  314. Behavior is undefined if <parameter>size</parameter> is
  315. <constant>0</constant>, or if <code
  316. language="C">(<parameter>size</parameter> + <parameter>extra</parameter>
  317. &gt; <constant>SIZE_T_MAX</constant>)</code>.</para>
  318. <para>The <function>sallocx()</function> function returns the
  319. real size of the allocation at <parameter>ptr</parameter>.</para>
  320. <para>The <function>dallocx()</function> function causes the
  321. memory referenced by <parameter>ptr</parameter> to be made available for
  322. future allocations.</para>
  323. <para>The <function>sdallocx()</function> function is an
  324. extension of <function>dallocx()</function> with a
  325. <parameter>size</parameter> parameter to allow the caller to pass in the
  326. allocation size as an optimization. The minimum valid input size is the
  327. original requested size of the allocation, and the maximum valid input
  328. size is the corresponding value returned by
  329. <function>nallocx()</function> or
  330. <function>sallocx()</function>.</para>
  331. <para>The <function>nallocx()</function> function allocates no
  332. memory, but it performs the same size computation as the
  333. <function>mallocx()</function> function, and returns the real
  334. size of the allocation that would result from the equivalent
  335. <function>mallocx()</function> function call, or
  336. <constant>0</constant> if the inputs exceed the maximum supported size
  337. class and/or alignment. Behavior is undefined if
  338. <parameter>size</parameter> is <constant>0</constant>.</para>
  339. <para>The <function>mallctl()</function> function provides a
  340. general interface for introspecting the memory allocator, as well as
  341. setting modifiable parameters and triggering actions. The
  342. period-separated <parameter>name</parameter> argument specifies a
  343. location in a tree-structured namespace; see the <xref
  344. linkend="mallctl_namespace" xrefstyle="template:%t"/> section for
  345. documentation on the tree contents. To read a value, pass a pointer via
  346. <parameter>oldp</parameter> to adequate space to contain the value, and a
  347. pointer to its length via <parameter>oldlenp</parameter>; otherwise pass
  348. <constant>NULL</constant> and <constant>NULL</constant>. Similarly, to
  349. write a value, pass a pointer to the value via
  350. <parameter>newp</parameter>, and its length via
  351. <parameter>newlen</parameter>; otherwise pass <constant>NULL</constant>
  352. and <constant>0</constant>.</para>
  353. <para>The <function>mallctlnametomib()</function> function
  354. provides a way to avoid repeated name lookups for applications that
  355. repeatedly query the same portion of the namespace, by translating a name
  356. to a <quote>Management Information Base</quote> (MIB) that can be passed
  357. repeatedly to <function>mallctlbymib()</function>. Upon
  358. successful return from <function>mallctlnametomib()</function>,
  359. <parameter>mibp</parameter> contains an array of
  360. <parameter>*miblenp</parameter> integers, where
  361. <parameter>*miblenp</parameter> is the lesser of the number of components
  362. in <parameter>name</parameter> and the input value of
  363. <parameter>*miblenp</parameter>. Thus it is possible to pass a
  364. <parameter>*miblenp</parameter> that is smaller than the number of
  365. period-separated name components, which results in a partial MIB that can
  366. be used as the basis for constructing a complete MIB. For name
  367. components that are integers (e.g. the 2 in
  368. <link
  369. linkend="arenas.bin.i.size"><mallctl>arenas.bin.2.size</mallctl></link>),
  370. the corresponding MIB component will always be that integer. Therefore,
  371. it is legitimate to construct code like the following: <programlisting
  372. language="C"><![CDATA[
  373. unsigned nbins, i;
  374. size_t mib[4];
  375. size_t len, miblen;
  376. len = sizeof(nbins);
  377. mallctl("arenas.nbins", &nbins, &len, NULL, 0);
  378. miblen = 4;
  379. mallctlnametomib("arenas.bin.0.size", mib, &miblen);
  380. for (i = 0; i < nbins; i++) {
  381. size_t bin_size;
  382. mib[2] = i;
  383. len = sizeof(bin_size);
  384. mallctlbymib(mib, miblen, (void *)&bin_size, &len, NULL, 0);
  385. /* Do something with bin_size... */
  386. }]]></programlisting></para>
  387. <varlistentry id="malloc_stats_print_opts">
  388. </varlistentry>
  389. <para>The <function>malloc_stats_print()</function> function writes
  390. summary statistics via the <parameter>write_cb</parameter> callback
  391. function pointer and <parameter>cbopaque</parameter> data passed to
  392. <parameter>write_cb</parameter>, or <function>malloc_message()</function>
  393. if <parameter>write_cb</parameter> is <constant>NULL</constant>. The
  394. statistics are presented in human-readable form unless <quote>J</quote> is
  395. specified as a character within the <parameter>opts</parameter> string, in
  396. which case the statistics are presented in <ulink
  397. url="http://www.json.org/">JSON format</ulink>. This function can be
  398. called repeatedly. General information that never changes during
  399. execution can be omitted by specifying <quote>g</quote> as a character
  400. within the <parameter>opts</parameter> string. Note that
  401. <function>malloc_message()</function> uses the
  402. <function>mallctl*()</function> functions internally, so inconsistent
  403. statistics can be reported if multiple threads use these functions
  404. simultaneously. If <option>--enable-stats</option> is specified during
  405. configuration, <quote>m</quote>, <quote>d</quote>, and <quote>a</quote>
  406. can be specified to omit merged arena, destroyed merged arena, and per
  407. arena statistics, respectively; <quote>b</quote> and <quote>l</quote> can
  408. be specified to omit per size class statistics for bins and large objects,
  409. respectively; <quote>x</quote> can be specified to omit all mutex
  410. statistics. Unrecognized characters are silently ignored. Note that
  411. thread caching may prevent some statistics from being completely up to
  412. date, since extra locking would be required to merge counters that track
  413. thread cache operations.</para>
  414. <para>The <function>malloc_usable_size()</function> function
  415. returns the usable size of the allocation pointed to by
  416. <parameter>ptr</parameter>. The return value may be larger than the size
  417. that was requested during allocation. The
  418. <function>malloc_usable_size()</function> function is not a
  419. mechanism for in-place <function>realloc()</function>; rather
  420. it is provided solely as a tool for introspection purposes. Any
  421. discrepancy between the requested allocation size and the size reported
  422. by <function>malloc_usable_size()</function> should not be
  423. depended on, since such behavior is entirely implementation-dependent.
  424. </para>
  425. </refsect2>
  426. </refsect1>
  427. <refsect1 id="tuning">
  428. <title>TUNING</title>
  429. <para>Once, when the first call is made to one of the memory allocation
  430. routines, the allocator initializes its internals based in part on various
  431. options that can be specified at compile- or run-time.</para>
  432. <para>The string specified via <option>--with-malloc-conf</option>, the
  433. string pointed to by the global variable <varname>malloc_conf</varname>, the
  434. <quote>name</quote> of the file referenced by the symbolic link named
  435. <filename class="symlink">/etc/malloc.conf</filename>, and the value of the
  436. environment variable <envar>MALLOC_CONF</envar>, will be interpreted, in
  437. that order, from left to right as options. Note that
  438. <varname>malloc_conf</varname> may be read before
  439. <function>main()</function> is entered, so the declaration of
  440. <varname>malloc_conf</varname> should specify an initializer that contains
  441. the final value to be read by jemalloc. <option>--with-malloc-conf</option>
  442. and <varname>malloc_conf</varname> are compile-time mechanisms, whereas
  443. <filename class="symlink">/etc/malloc.conf</filename> and
  444. <envar>MALLOC_CONF</envar> can be safely set any time prior to program
  445. invocation.</para>
  446. <para>An options string is a comma-separated list of option:value pairs.
  447. There is one key corresponding to each <link
  448. linkend="opt.abort"><mallctl>opt.*</mallctl></link> mallctl (see the <xref
  449. linkend="mallctl_namespace" xrefstyle="template:%t"/> section for options
  450. documentation). For example, <literal>abort:true,narenas:1</literal> sets
  451. the <link linkend="opt.abort"><mallctl>opt.abort</mallctl></link> and <link
  452. linkend="opt.narenas"><mallctl>opt.narenas</mallctl></link> options. Some
  453. options have boolean values (true/false), others have integer values (base
  454. 8, 10, or 16, depending on prefix), and yet others have raw string
  455. values.</para>
  456. </refsect1>
  457. <refsect1 id="implementation_notes">
  458. <title>IMPLEMENTATION NOTES</title>
  459. <para>Traditionally, allocators have used
  460. <citerefentry><refentrytitle>sbrk</refentrytitle>
  461. <manvolnum>2</manvolnum></citerefentry> to obtain memory, which is
  462. suboptimal for several reasons, including race conditions, increased
  463. fragmentation, and artificial limitations on maximum usable memory. If
  464. <citerefentry><refentrytitle>sbrk</refentrytitle>
  465. <manvolnum>2</manvolnum></citerefentry> is supported by the operating
  466. system, this allocator uses both
  467. <citerefentry><refentrytitle>mmap</refentrytitle>
  468. <manvolnum>2</manvolnum></citerefentry> and
  469. <citerefentry><refentrytitle>sbrk</refentrytitle>
  470. <manvolnum>2</manvolnum></citerefentry>, in that order of preference;
  471. otherwise only <citerefentry><refentrytitle>mmap</refentrytitle>
  472. <manvolnum>2</manvolnum></citerefentry> is used.</para>
  473. <para>This allocator uses multiple arenas in order to reduce lock
  474. contention for threaded programs on multi-processor systems. This works
  475. well with regard to threading scalability, but incurs some costs. There is
  476. a small fixed per-arena overhead, and additionally, arenas manage memory
  477. completely independently of each other, which means a small fixed increase
  478. in overall memory fragmentation. These overheads are not generally an
  479. issue, given the number of arenas normally used. Note that using
  480. substantially more arenas than the default is not likely to improve
  481. performance, mainly due to reduced cache performance. However, it may make
  482. sense to reduce the number of arenas if an application does not make much
  483. use of the allocation functions.</para>
  484. <para>In addition to multiple arenas, this allocator supports
  485. thread-specific caching, in order to make it possible to completely avoid
  486. synchronization for most allocation requests. Such caching allows very fast
  487. allocation in the common case, but it increases memory usage and
  488. fragmentation, since a bounded number of objects can remain allocated in
  489. each thread cache.</para>
  490. <para>Memory is conceptually broken into extents. Extents are always
  491. aligned to multiples of the page size. This alignment makes it possible to
  492. find metadata for user objects quickly. User objects are broken into two
  493. categories according to size: small and large. Contiguous small objects
  494. comprise a slab, which resides within a single extent, whereas large objects
  495. each have their own extents backing them.</para>
  496. <para>Small objects are managed in groups by slabs. Each slab maintains
  497. a bitmap to track which regions are in use. Allocation requests that are no
  498. more than half the quantum (8 or 16, depending on architecture) are rounded
  499. up to the nearest power of two that is at least <code
  500. language="C">sizeof(<type>double</type>)</code>. All other object size
  501. classes are multiples of the quantum, spaced such that there are four size
  502. classes for each doubling in size, which limits internal fragmentation to
  503. approximately 20% for all but the smallest size classes. Small size classes
  504. are smaller than four times the page size, and large size classes extend
  505. from four times the page size up to the largest size class that does not
  506. exceed <constant>PTRDIFF_MAX</constant>.</para>
  507. <para>Allocations are packed tightly together, which can be an issue for
  508. multi-threaded applications. If you need to assure that allocations do not
  509. suffer from cacheline sharing, round your allocation requests up to the
  510. nearest multiple of the cacheline size, or specify cacheline alignment when
  511. allocating.</para>
  512. <para>The <function>realloc()</function>,
  513. <function>rallocx()</function>, and
  514. <function>xallocx()</function> functions may resize allocations
  515. without moving them under limited circumstances. Unlike the
  516. <function>*allocx()</function> API, the standard API does not
  517. officially round up the usable size of an allocation to the nearest size
  518. class, so technically it is necessary to call
  519. <function>realloc()</function> to grow e.g. a 9-byte allocation to
  520. 16 bytes, or shrink a 16-byte allocation to 9 bytes. Growth and shrinkage
  521. trivially succeeds in place as long as the pre-size and post-size both round
  522. up to the same size class. No other API guarantees are made regarding
  523. in-place resizing, but the current implementation also tries to resize large
  524. allocations in place, as long as the pre-size and post-size are both large.
  525. For shrinkage to succeed, the extent allocator must support splitting (see
  526. <link
  527. linkend="arena.i.extent_hooks"><mallctl>arena.&lt;i&gt;.extent_hooks</mallctl></link>).
  528. Growth only succeeds if the trailing memory is currently available, and the
  529. extent allocator supports merging.</para>
  530. <para>Assuming 4 KiB pages and a 16-byte quantum on a 64-bit system, the
  531. size classes in each category are as shown in <xref linkend="size_classes"
  532. xrefstyle="template:Table %n"/>.</para>
  533. <table xml:id="size_classes" frame="all">
  534. <title>Size classes</title>
  535. <tgroup cols="3" colsep="1" rowsep="1">
  536. <colspec colname="c1" align="left"/>
  537. <colspec colname="c2" align="right"/>
  538. <colspec colname="c3" align="left"/>
  539. <thead>
  540. <row>
  541. <entry>Category</entry>
  542. <entry>Spacing</entry>
  543. <entry>Size</entry>
  544. </row>
  545. </thead>
  546. <tbody>
  547. <row>
  548. <entry morerows="8">Small</entry>
  549. <entry>lg</entry>
  550. <entry>[8]</entry>
  551. </row>
  552. <row>
  553. <entry>16</entry>
  554. <entry>[16, 32, 48, 64, 80, 96, 112, 128]</entry>
  555. </row>
  556. <row>
  557. <entry>32</entry>
  558. <entry>[160, 192, 224, 256]</entry>
  559. </row>
  560. <row>
  561. <entry>64</entry>
  562. <entry>[320, 384, 448, 512]</entry>
  563. </row>
  564. <row>
  565. <entry>128</entry>
  566. <entry>[640, 768, 896, 1024]</entry>
  567. </row>
  568. <row>
  569. <entry>256</entry>
  570. <entry>[1280, 1536, 1792, 2048]</entry>
  571. </row>
  572. <row>
  573. <entry>512</entry>
  574. <entry>[2560, 3072, 3584, 4096]</entry>
  575. </row>
  576. <row>
  577. <entry>1 KiB</entry>
  578. <entry>[5 KiB, 6 KiB, 7 KiB, 8 KiB]</entry>
  579. </row>
  580. <row>
  581. <entry>2 KiB</entry>
  582. <entry>[10 KiB, 12 KiB, 14 KiB]</entry>
  583. </row>
  584. <row>
  585. <entry morerows="15">Large</entry>
  586. <entry>2 KiB</entry>
  587. <entry>[16 KiB]</entry>
  588. </row>
  589. <row>
  590. <entry>4 KiB</entry>
  591. <entry>[20 KiB, 24 KiB, 28 KiB, 32 KiB]</entry>
  592. </row>
  593. <row>
  594. <entry>8 KiB</entry>
  595. <entry>[40 KiB, 48 KiB, 54 KiB, 64 KiB]</entry>
  596. </row>
  597. <row>
  598. <entry>16 KiB</entry>
  599. <entry>[80 KiB, 96 KiB, 112 KiB, 128 KiB]</entry>
  600. </row>
  601. <row>
  602. <entry>32 KiB</entry>
  603. <entry>[160 KiB, 192 KiB, 224 KiB, 256 KiB]</entry>
  604. </row>
  605. <row>
  606. <entry>64 KiB</entry>
  607. <entry>[320 KiB, 384 KiB, 448 KiB, 512 KiB]</entry>
  608. </row>
  609. <row>
  610. <entry>128 KiB</entry>
  611. <entry>[640 KiB, 768 KiB, 896 KiB, 1 MiB]</entry>
  612. </row>
  613. <row>
  614. <entry>256 KiB</entry>
  615. <entry>[1280 KiB, 1536 KiB, 1792 KiB, 2 MiB]</entry>
  616. </row>
  617. <row>
  618. <entry>512 KiB</entry>
  619. <entry>[2560 KiB, 3 MiB, 3584 KiB, 4 MiB]</entry>
  620. </row>
  621. <row>
  622. <entry>1 MiB</entry>
  623. <entry>[5 MiB, 6 MiB, 7 MiB, 8 MiB]</entry>
  624. </row>
  625. <row>
  626. <entry>2 MiB</entry>
  627. <entry>[10 MiB, 12 MiB, 14 MiB, 16 MiB]</entry>
  628. </row>
  629. <row>
  630. <entry>4 MiB</entry>
  631. <entry>[20 MiB, 24 MiB, 28 MiB, 32 MiB]</entry>
  632. </row>
  633. <row>
  634. <entry>8 MiB</entry>
  635. <entry>[40 MiB, 48 MiB, 56 MiB, 64 MiB]</entry>
  636. </row>
  637. <row>
  638. <entry>...</entry>
  639. <entry>...</entry>
  640. </row>
  641. <row>
  642. <entry>512 PiB</entry>
  643. <entry>[2560 PiB, 3 EiB, 3584 PiB, 4 EiB]</entry>
  644. </row>
  645. <row>
  646. <entry>1 EiB</entry>
  647. <entry>[5 EiB, 6 EiB, 7 EiB]</entry>
  648. </row>
  649. </tbody>
  650. </tgroup>
  651. </table>
  652. </refsect1>
  653. <refsect1 id="mallctl_namespace">
  654. <title>MALLCTL NAMESPACE</title>
  655. <para>The following names are defined in the namespace accessible via the
  656. <function>mallctl*()</function> functions. Value types are specified in
  657. parentheses, their readable/writable statuses are encoded as
  658. <literal>rw</literal>, <literal>r-</literal>, <literal>-w</literal>, or
  659. <literal>--</literal>, and required build configuration flags follow, if
  660. any. A name element encoded as <literal>&lt;i&gt;</literal> or
  661. <literal>&lt;j&gt;</literal> indicates an integer component, where the
  662. integer varies from 0 to some upper value that must be determined via
  663. introspection. In the case of <mallctl>stats.arenas.&lt;i&gt;.*</mallctl>
  664. and <mallctl>arena.&lt;i&gt;.{initialized,purge,decay,dss}</mallctl>,
  665. <literal>&lt;i&gt;</literal> equal to
  666. <constant>MALLCTL_ARENAS_ALL</constant> can be used to operate on all arenas
  667. or access the summation of statistics from all arenas; similarly
  668. <literal>&lt;i&gt;</literal> equal to
  669. <constant>MALLCTL_ARENAS_DESTROYED</constant> can be used to access the
  670. summation of statistics from all destroyed arenas. These constants can be
  671. utilized either via <function>mallctlnametomib()</function> followed by
  672. <function>mallctlbymib()</function>, or via code such as the following:
  673. <programlisting language="C"><![CDATA[
  674. #define STRINGIFY_HELPER(x) #x
  675. #define STRINGIFY(x) STRINGIFY_HELPER(x)
  676. mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".decay",
  677. NULL, NULL, NULL, 0);]]></programlisting>
  678. Take special note of the <link
  679. linkend="epoch"><mallctl>epoch</mallctl></link> mallctl, which controls
  680. refreshing of cached dynamic statistics.</para>
  681. <variablelist>
  682. <varlistentry id="version">
  683. <term>
  684. <mallctl>version</mallctl>
  685. (<type>const char *</type>)
  686. <literal>r-</literal>
  687. </term>
  688. <listitem><para>Return the jemalloc version string.</para></listitem>
  689. </varlistentry>
  690. <varlistentry id="epoch">
  691. <term>
  692. <mallctl>epoch</mallctl>
  693. (<type>uint64_t</type>)
  694. <literal>rw</literal>
  695. </term>
  696. <listitem><para>If a value is passed in, refresh the data from which
  697. the <function>mallctl*()</function> functions report values,
  698. and increment the epoch. Return the current epoch. This is useful for
  699. detecting whether another thread caused a refresh.</para></listitem>
  700. </varlistentry>
  701. <varlistentry id="background_thread">
  702. <term>
  703. <mallctl>background_thread</mallctl>
  704. (<type>bool</type>)
  705. <literal>rw</literal>
  706. </term>
  707. <listitem><para>Enable/disable internal background worker threads. When
  708. set to true, background threads are created on demand (the number of
  709. background threads will be no more than the number of CPUs or active
  710. arenas). Threads run periodically, and handle <link
  711. linkend="arena.i.decay">purging</link> asynchronously. When switching
  712. off, background threads are terminated synchronously. Note that after
  713. <citerefentry><refentrytitle>fork</refentrytitle><manvolnum>2</manvolnum></citerefentry>
  714. function, the state in the child process will be disabled regardless
  715. the state in parent process. See <link
  716. linkend="stats.background_thread.num_threads"><mallctl>stats.background_thread</mallctl></link>
  717. for related stats. <link
  718. linkend="opt.background_thread"><mallctl>opt.background_thread</mallctl></link>
  719. can be used to set the default option. This option is only available on
  720. selected pthread-based platforms.</para></listitem>
  721. </varlistentry>
  722. <varlistentry id="max_background_threads">
  723. <term>
  724. <mallctl>max_background_threads</mallctl>
  725. (<type>size_t</type>)
  726. <literal>rw</literal>
  727. </term>
  728. <listitem><para>Maximum number of background worker threads that will
  729. be created. This value is capped at <link
  730. linkend="opt.max_background_threads"><mallctl>opt.max_background_threads</mallctl></link> at
  731. startup.</para></listitem>
  732. </varlistentry>
  733. <varlistentry id="config.cache_oblivious">
  734. <term>
  735. <mallctl>config.cache_oblivious</mallctl>
  736. (<type>bool</type>)
  737. <literal>r-</literal>
  738. </term>
  739. <listitem><para><option>--enable-cache-oblivious</option> was specified
  740. during build configuration.</para></listitem>
  741. </varlistentry>
  742. <varlistentry id="config.debug">
  743. <term>
  744. <mallctl>config.debug</mallctl>
  745. (<type>bool</type>)
  746. <literal>r-</literal>
  747. </term>
  748. <listitem><para><option>--enable-debug</option> was specified during
  749. build configuration.</para></listitem>
  750. </varlistentry>
  751. <varlistentry id="config.fill">
  752. <term>
  753. <mallctl>config.fill</mallctl>
  754. (<type>bool</type>)
  755. <literal>r-</literal>
  756. </term>
  757. <listitem><para><option>--enable-fill</option> was specified during
  758. build configuration.</para></listitem>
  759. </varlistentry>
  760. <varlistentry id="config.lazy_lock">
  761. <term>
  762. <mallctl>config.lazy_lock</mallctl>
  763. (<type>bool</type>)
  764. <literal>r-</literal>
  765. </term>
  766. <listitem><para><option>--enable-lazy-lock</option> was specified
  767. during build configuration.</para></listitem>
  768. </varlistentry>
  769. <varlistentry id="config.malloc_conf">
  770. <term>
  771. <mallctl>config.malloc_conf</mallctl>
  772. (<type>const char *</type>)
  773. <literal>r-</literal>
  774. </term>
  775. <listitem><para>Embedded configure-time-specified run-time options
  776. string, empty unless <option>--with-malloc-conf</option> was specified
  777. during build configuration.</para></listitem>
  778. </varlistentry>
  779. <varlistentry id="config.prof">
  780. <term>
  781. <mallctl>config.prof</mallctl>
  782. (<type>bool</type>)
  783. <literal>r-</literal>
  784. </term>
  785. <listitem><para><option>--enable-prof</option> was specified during
  786. build configuration.</para></listitem>
  787. </varlistentry>
  788. <varlistentry id="config.prof_libgcc">
  789. <term>
  790. <mallctl>config.prof_libgcc</mallctl>
  791. (<type>bool</type>)
  792. <literal>r-</literal>
  793. </term>
  794. <listitem><para><option>--disable-prof-libgcc</option> was not
  795. specified during build configuration.</para></listitem>
  796. </varlistentry>
  797. <varlistentry id="config.prof_libunwind">
  798. <term>
  799. <mallctl>config.prof_libunwind</mallctl>
  800. (<type>bool</type>)
  801. <literal>r-</literal>
  802. </term>
  803. <listitem><para><option>--enable-prof-libunwind</option> was specified
  804. during build configuration.</para></listitem>
  805. </varlistentry>
  806. <varlistentry id="config.stats">
  807. <term>
  808. <mallctl>config.stats</mallctl>
  809. (<type>bool</type>)
  810. <literal>r-</literal>
  811. </term>
  812. <listitem><para><option>--enable-stats</option> was specified during
  813. build configuration.</para></listitem>
  814. </varlistentry>
  815. <varlistentry id="config.utrace">
  816. <term>
  817. <mallctl>config.utrace</mallctl>
  818. (<type>bool</type>)
  819. <literal>r-</literal>
  820. </term>
  821. <listitem><para><option>--enable-utrace</option> was specified during
  822. build configuration.</para></listitem>
  823. </varlistentry>
  824. <varlistentry id="config.xmalloc">
  825. <term>
  826. <mallctl>config.xmalloc</mallctl>
  827. (<type>bool</type>)
  828. <literal>r-</literal>
  829. </term>
  830. <listitem><para><option>--enable-xmalloc</option> was specified during
  831. build configuration.</para></listitem>
  832. </varlistentry>
  833. <varlistentry id="opt.abort">
  834. <term>
  835. <mallctl>opt.abort</mallctl>
  836. (<type>bool</type>)
  837. <literal>r-</literal>
  838. </term>
  839. <listitem><para>Abort-on-warning enabled/disabled. If true, most
  840. warnings are fatal. Note that runtime option warnings are not included
  841. (see <link
  842. linkend="opt.abort_conf"><mallctl>opt.abort_conf</mallctl></link> for
  843. that). The process will call
  844. <citerefentry><refentrytitle>abort</refentrytitle>
  845. <manvolnum>3</manvolnum></citerefentry> in these cases. This option is
  846. disabled by default unless <option>--enable-debug</option> is
  847. specified during configuration, in which case it is enabled by default.
  848. </para></listitem>
  849. </varlistentry>
  850. <varlistentry id="opt.abort_conf">
  851. <term>
  852. <mallctl>opt.abort_conf</mallctl>
  853. (<type>bool</type>)
  854. <literal>r-</literal>
  855. </term>
  856. <listitem><para>Abort-on-invalid-configuration enabled/disabled. If
  857. true, invalid runtime options are fatal. The process will call
  858. <citerefentry><refentrytitle>abort</refentrytitle>
  859. <manvolnum>3</manvolnum></citerefentry> in these cases. This option is
  860. disabled by default unless <option>--enable-debug</option> is
  861. specified during configuration, in which case it is enabled by default.
  862. </para></listitem>
  863. </varlistentry>
  864. <varlistentry id="opt.metadata_thp">
  865. <term>
  866. <mallctl>opt.metadata_thp</mallctl>
  867. (<type>const char *</type>)
  868. <literal>r-</literal>
  869. </term>
  870. <listitem><para>Controls whether to allow jemalloc to use transparent
  871. huge page (THP) for internal metadata (see <link
  872. linkend="stats.metadata">stats.metadata</link>). <quote>always</quote>
  873. allows such usage. <quote>auto</quote> uses no THP initially, but may
  874. begin to do so when metadata usage reaches certain level. The default
  875. is <quote>disabled</quote>.</para></listitem>
  876. </varlistentry>
  877. <varlistentry id="opt.retain">
  878. <term>
  879. <mallctl>opt.retain</mallctl>
  880. (<type>bool</type>)
  881. <literal>r-</literal>
  882. </term>
  883. <listitem><para>If true, retain unused virtual memory for later reuse
  884. rather than discarding it by calling
  885. <citerefentry><refentrytitle>munmap</refentrytitle>
  886. <manvolnum>2</manvolnum></citerefentry> or equivalent (see <link
  887. linkend="stats.retained">stats.retained</link> for related details).
  888. This option is disabled by default unless discarding virtual memory is
  889. known to trigger
  890. platform-specific performance problems, e.g. for [64-bit] Linux, which
  891. has a quirk in its virtual memory allocation algorithm that causes
  892. semi-permanent VM map holes under normal jemalloc operation. Although
  893. <citerefentry><refentrytitle>munmap</refentrytitle>
  894. <manvolnum>2</manvolnum></citerefentry> causes issues on 32-bit Linux as
  895. well, retaining virtual memory for 32-bit Linux is disabled by default
  896. due to the practical possibility of address space exhaustion.
  897. </para></listitem>
  898. </varlistentry>
  899. <varlistentry id="opt.dss">
  900. <term>
  901. <mallctl>opt.dss</mallctl>
  902. (<type>const char *</type>)
  903. <literal>r-</literal>
  904. </term>
  905. <listitem><para>dss (<citerefentry><refentrytitle>sbrk</refentrytitle>
  906. <manvolnum>2</manvolnum></citerefentry>) allocation precedence as
  907. related to <citerefentry><refentrytitle>mmap</refentrytitle>
  908. <manvolnum>2</manvolnum></citerefentry> allocation. The following
  909. settings are supported if
  910. <citerefentry><refentrytitle>sbrk</refentrytitle>
  911. <manvolnum>2</manvolnum></citerefentry> is supported by the operating
  912. system: <quote>disabled</quote>, <quote>primary</quote>, and
  913. <quote>secondary</quote>; otherwise only <quote>disabled</quote> is
  914. supported. The default is <quote>secondary</quote> if
  915. <citerefentry><refentrytitle>sbrk</refentrytitle>
  916. <manvolnum>2</manvolnum></citerefentry> is supported by the operating
  917. system; <quote>disabled</quote> otherwise.
  918. </para></listitem>
  919. </varlistentry>
  920. <varlistentry id="opt.narenas">
  921. <term>
  922. <mallctl>opt.narenas</mallctl>
  923. (<type>unsigned</type>)
  924. <literal>r-</literal>
  925. </term>
  926. <listitem><para>Maximum number of arenas to use for automatic
  927. multiplexing of threads and arenas. The default is four times the
  928. number of CPUs, or one if there is a single CPU.</para></listitem>
  929. </varlistentry>
  930. <varlistentry id="opt.percpu_arena">
  931. <term>
  932. <mallctl>opt.percpu_arena</mallctl>
  933. (<type>const char *</type>)
  934. <literal>r-</literal>
  935. </term>
  936. <listitem><para>Per CPU arena mode. Use the <quote>percpu</quote>
  937. setting to enable this feature, which uses number of CPUs to determine
  938. number of arenas, and bind threads to arenas dynamically based on the
  939. CPU the thread runs on currently. <quote>phycpu</quote> setting uses
  940. one arena per physical CPU, which means the two hyper threads on the
  941. same CPU share one arena. Note that no runtime checking regarding the
  942. availability of hyper threading is done at the moment. When set to
  943. <quote>disabled</quote>, narenas and thread to arena association will
  944. not be impacted by this option. The default is <quote>disabled</quote>.
  945. </para></listitem>
  946. </varlistentry>
  947. <varlistentry id="opt.background_thread">
  948. <term>
  949. <mallctl>opt.background_thread</mallctl>
  950. (<type>const bool</type>)
  951. <literal>r-</literal>
  952. </term>
  953. <listitem><para>Internal background worker threads enabled/disabled.
  954. Because of potential circular dependencies, enabling background thread
  955. using this option may cause crash or deadlock during initialization. For
  956. a reliable way to use this feature, see <link
  957. linkend="background_thread">background_thread</link> for dynamic control
  958. options and details. This option is disabled by
  959. default.</para></listitem>
  960. </varlistentry>
  961. <varlistentry id="opt.max_background_threads">
  962. <term>
  963. <mallctl>opt.max_background_threads</mallctl>
  964. (<type>const size_t</type>)
  965. <literal>r-</literal>
  966. </term>
  967. <listitem><para>Maximum number of background threads that will be created
  968. if <link linkend="background_thread">background_thread</link> is set.
  969. Defaults to number of cpus.</para></listitem>
  970. </varlistentry>
  971. <varlistentry id="opt.dirty_decay_ms">
  972. <term>
  973. <mallctl>opt.dirty_decay_ms</mallctl>
  974. (<type>ssize_t</type>)
  975. <literal>r-</literal>
  976. </term>
  977. <listitem><para>Approximate time in milliseconds from the creation of a
  978. set of unused dirty pages until an equivalent set of unused dirty pages
  979. is purged (i.e. converted to muzzy via e.g.
  980. <function>madvise(<parameter>...</parameter><parameter><constant>MADV_FREE</constant></parameter>)</function>
  981. if supported by the operating system, or converted to clean otherwise)
  982. and/or reused. Dirty pages are defined as previously having been
  983. potentially written to by the application, and therefore consuming
  984. physical memory, yet having no current use. The pages are incrementally
  985. purged according to a sigmoidal decay curve that starts and ends with
  986. zero purge rate. A decay time of 0 causes all unused dirty pages to be
  987. purged immediately upon creation. A decay time of -1 disables purging.
  988. The default decay time is 10 seconds. See <link
  989. linkend="arenas.dirty_decay_ms"><mallctl>arenas.dirty_decay_ms</mallctl></link>
  990. and <link
  991. linkend="arena.i.dirty_decay_ms"><mallctl>arena.&lt;i&gt;.dirty_decay_ms</mallctl></link>
  992. for related dynamic control options. See <link
  993. linkend="opt.muzzy_decay_ms"><mallctl>opt.muzzy_decay_ms</mallctl></link>
  994. for a description of muzzy pages.</para></listitem>
  995. </varlistentry>
  996. <varlistentry id="opt.muzzy_decay_ms">
  997. <term>
  998. <mallctl>opt.muzzy_decay_ms</mallctl>
  999. (<type>ssize_t</type>)
  1000. <literal>r-</literal>
  1001. </term>
  1002. <listitem><para>Approximate time in milliseconds from the creation of a
  1003. set of unused muzzy pages until an equivalent set of unused muzzy pages
  1004. is purged (i.e. converted to clean) and/or reused. Muzzy pages are
  1005. defined as previously having been unused dirty pages that were
  1006. subsequently purged in a manner that left them subject to the
  1007. reclamation whims of the operating system (e.g.
  1008. <function>madvise(<parameter>...</parameter><parameter><constant>MADV_FREE</constant></parameter>)</function>),
  1009. and therefore in an indeterminate state. The pages are incrementally
  1010. purged according to a sigmoidal decay curve that starts and ends with
  1011. zero purge rate. A decay time of 0 causes all unused muzzy pages to be
  1012. purged immediately upon creation. A decay time of -1 disables purging.
  1013. The default decay time is 10 seconds. See <link
  1014. linkend="arenas.muzzy_decay_ms"><mallctl>arenas.muzzy_decay_ms</mallctl></link>
  1015. and <link
  1016. linkend="arena.i.muzzy_decay_ms"><mallctl>arena.&lt;i&gt;.muzzy_decay_ms</mallctl></link>
  1017. for related dynamic control options.</para></listitem>
  1018. </varlistentry>
  1019. <varlistentry id="opt.lg_extent_max_active_fit">
  1020. <term>
  1021. <mallctl>opt.lg_extent_max_active_fit</mallctl>
  1022. (<type>size_t</type>)
  1023. <literal>r-</literal>
  1024. </term>
  1025. <listitem><para>When reusing dirty extents, this determines the (log
  1026. base 2 of the) maximum ratio between the size of the active extent
  1027. selected (to split off from) and the size of the requested allocation.
  1028. This prevents the splitting of large active extents for smaller
  1029. allocations, which can reduce fragmentation over the long run
  1030. (especially for non-active extents). Lower value may reduce
  1031. fragmentation, at the cost of extra active extents. The default value
  1032. is 6, which gives a maximum ratio of 64 (2^6).</para></listitem>
  1033. </varlistentry>
  1034. <varlistentry id="opt.stats_print">
  1035. <term>
  1036. <mallctl>opt.stats_print</mallctl>
  1037. (<type>bool</type>)
  1038. <literal>r-</literal>
  1039. </term>
  1040. <listitem><para>Enable/disable statistics printing at exit. If
  1041. enabled, the <function>malloc_stats_print()</function>
  1042. function is called at program exit via an
  1043. <citerefentry><refentrytitle>atexit</refentrytitle>
  1044. <manvolnum>3</manvolnum></citerefentry> function. <link
  1045. linkend="opt.stats_print_opts"><mallctl>opt.stats_print_opts</mallctl></link>
  1046. can be combined to specify output options. If
  1047. <option>--enable-stats</option> is specified during configuration, this
  1048. has the potential to cause deadlock for a multi-threaded process that
  1049. exits while one or more threads are executing in the memory allocation
  1050. functions. Furthermore, <function>atexit()</function> may
  1051. allocate memory during application initialization and then deadlock
  1052. internally when jemalloc in turn calls
  1053. <function>atexit()</function>, so this option is not
  1054. universally usable (though the application can register its own
  1055. <function>atexit()</function> function with equivalent
  1056. functionality). Therefore, this option should only be used with care;
  1057. it is primarily intended as a performance tuning aid during application
  1058. development. This option is disabled by default.</para></listitem>
  1059. </varlistentry>
  1060. <varlistentry id="opt.stats_print_opts">
  1061. <term>
  1062. <mallctl>opt.stats_print_opts</mallctl>
  1063. (<type>const char *</type>)
  1064. <literal>r-</literal>
  1065. </term>
  1066. <listitem><para>Options (the <parameter>opts</parameter> string) to pass
  1067. to the <function>malloc_stats_print()</function> at exit (enabled
  1068. through <link
  1069. linkend="opt.stats_print"><mallctl>opt.stats_print</mallctl></link>). See
  1070. available options in <link
  1071. linkend="malloc_stats_print_opts"><function>malloc_stats_print()</function></link>.
  1072. Has no effect unless <link
  1073. linkend="opt.stats_print"><mallctl>opt.stats_print</mallctl></link> is
  1074. enabled. The default is <quote></quote>.</para></listitem>
  1075. </varlistentry>
  1076. <varlistentry id="opt.junk">
  1077. <term>
  1078. <mallctl>opt.junk</mallctl>
  1079. (<type>const char *</type>)
  1080. <literal>r-</literal>
  1081. [<option>--enable-fill</option>]
  1082. </term>
  1083. <listitem><para>Junk filling. If set to <quote>alloc</quote>, each byte
  1084. of uninitialized allocated memory will be initialized to
  1085. <literal>0xa5</literal>. If set to <quote>free</quote>, all deallocated
  1086. memory will be initialized to <literal>0x5a</literal>. If set to
  1087. <quote>true</quote>, both allocated and deallocated memory will be
  1088. initialized, and if set to <quote>false</quote>, junk filling be
  1089. disabled entirely. This is intended for debugging and will impact
  1090. performance negatively. This option is <quote>false</quote> by default
  1091. unless <option>--enable-debug</option> is specified during
  1092. configuration, in which case it is <quote>true</quote> by
  1093. default.</para></listitem>
  1094. </varlistentry>
  1095. <varlistentry id="opt.zero">
  1096. <term>
  1097. <mallctl>opt.zero</mallctl>
  1098. (<type>bool</type>)
  1099. <literal>r-</literal>
  1100. [<option>--enable-fill</option>]
  1101. </term>
  1102. <listitem><para>Zero filling enabled/disabled. If enabled, each byte
  1103. of uninitialized allocated memory will be initialized to 0. Note that
  1104. this initialization only happens once for each byte, so
  1105. <function>realloc()</function> and
  1106. <function>rallocx()</function> calls do not zero memory that
  1107. was previously allocated. This is intended for debugging and will
  1108. impact performance negatively. This option is disabled by default.
  1109. </para></listitem>
  1110. </varlistentry>
  1111. <varlistentry id="opt.utrace">
  1112. <term>
  1113. <mallctl>opt.utrace</mallctl>
  1114. (<type>bool</type>)
  1115. <literal>r-</literal>
  1116. [<option>--enable-utrace</option>]
  1117. </term>
  1118. <listitem><para>Allocation tracing based on
  1119. <citerefentry><refentrytitle>utrace</refentrytitle>
  1120. <manvolnum>2</manvolnum></citerefentry> enabled/disabled. This option
  1121. is disabled by default.</para></listitem>
  1122. </varlistentry>
  1123. <varlistentry id="opt.xmalloc">
  1124. <term>
  1125. <mallctl>opt.xmalloc</mallctl>
  1126. (<type>bool</type>)
  1127. <literal>r-</literal>
  1128. [<option>--enable-xmalloc</option>]
  1129. </term>
  1130. <listitem><para>Abort-on-out-of-memory enabled/disabled. If enabled,
  1131. rather than returning failure for any allocation function, display a
  1132. diagnostic message on <constant>STDERR_FILENO</constant> and cause the
  1133. program to drop core (using
  1134. <citerefentry><refentrytitle>abort</refentrytitle>
  1135. <manvolnum>3</manvolnum></citerefentry>). If an application is
  1136. designed to depend on this behavior, set the option at compile time by
  1137. including the following in the source code:
  1138. <programlisting language="C"><![CDATA[
  1139. malloc_conf = "xmalloc:true";]]></programlisting>
  1140. This option is disabled by default.</para></listitem>
  1141. </varlistentry>
  1142. <varlistentry id="opt.tcache">
  1143. <term>
  1144. <mallctl>opt.tcache</mallctl>
  1145. (<type>bool</type>)
  1146. <literal>r-</literal>
  1147. </term>
  1148. <listitem><para>Thread-specific caching (tcache) enabled/disabled. When
  1149. there are multiple threads, each thread uses a tcache for objects up to
  1150. a certain size. Thread-specific caching allows many allocations to be
  1151. satisfied without performing any thread synchronization, at the cost of
  1152. increased memory use. See the <link
  1153. linkend="opt.lg_tcache_max"><mallctl>opt.lg_tcache_max</mallctl></link>
  1154. option for related tuning information. This option is enabled by
  1155. default.</para></listitem>
  1156. </varlistentry>
  1157. <varlistentry id="opt.lg_tcache_max">
  1158. <term>
  1159. <mallctl>opt.lg_tcache_max</mallctl>
  1160. (<type>size_t</type>)
  1161. <literal>r-</literal>
  1162. </term>
  1163. <listitem><para>Maximum size class (log base 2) to cache in the
  1164. thread-specific cache (tcache). At a minimum, all small size classes
  1165. are cached, and at a maximum all large size classes are cached. The
  1166. default maximum is 32 KiB (2^15).</para></listitem>
  1167. </varlistentry>
  1168. <varlistentry id="opt.thp">
  1169. <term>
  1170. <mallctl>opt.thp</mallctl>
  1171. (<type>const char *</type>)
  1172. <literal>r-</literal>
  1173. </term>
  1174. <listitem><para>Transparent hugepage (THP) mode. Settings "always",
  1175. "never" and "default" are available if THP is supported by the operating
  1176. system. The "always" setting enables transparent hugepage for all user
  1177. memory mappings with
  1178. <parameter><constant>MADV_HUGEPAGE</constant></parameter>; "never"
  1179. ensures no transparent hugepage with
  1180. <parameter><constant>MADV_NOHUGEPAGE</constant></parameter>; the default
  1181. setting "default" makes no changes. Note that: this option does not
  1182. affect THP for jemalloc internal metadata (see <link
  1183. linkend="opt.metadata_thp"><mallctl>opt.metadata_thp</mallctl></link>);
  1184. in addition, for arenas with customized <link
  1185. linkend="arena.i.extent_hooks"><mallctl>extent_hooks</mallctl></link>,
  1186. this option is bypassed as it is implemented as part of the default
  1187. extent hooks.</para></listitem>
  1188. </varlistentry>
  1189. <varlistentry id="opt.prof">
  1190. <term>
  1191. <mallctl>opt.prof</mallctl>
  1192. (<type>bool</type>)
  1193. <literal>r-</literal>
  1194. [<option>--enable-prof</option>]
  1195. </term>
  1196. <listitem><para>Memory profiling enabled/disabled. If enabled, profile
  1197. memory allocation activity. See the <link
  1198. linkend="opt.prof_active"><mallctl>opt.prof_active</mallctl></link>
  1199. option for on-the-fly activation/deactivation. See the <link
  1200. linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link>
  1201. option for probabilistic sampling control. See the <link
  1202. linkend="opt.prof_accum"><mallctl>opt.prof_accum</mallctl></link>
  1203. option for control of cumulative sample reporting. See the <link
  1204. linkend="opt.lg_prof_interval"><mallctl>opt.lg_prof_interval</mallctl></link>
  1205. option for information on interval-triggered profile dumping, the <link
  1206. linkend="opt.prof_gdump"><mallctl>opt.prof_gdump</mallctl></link>
  1207. option for information on high-water-triggered profile dumping, and the
  1208. <link linkend="opt.prof_final"><mallctl>opt.prof_final</mallctl></link>
  1209. option for final profile dumping. Profile output is compatible with
  1210. the <command>jeprof</command> command, which is based on the
  1211. <command>pprof</command> that is developed as part of the <ulink
  1212. url="http://code.google.com/p/gperftools/">gperftools
  1213. package</ulink>. See <link linkend="heap_profile_format">HEAP PROFILE
  1214. FORMAT</link> for heap profile format documentation.</para></listitem>
  1215. </varlistentry>
  1216. <varlistentry id="opt.prof_prefix">
  1217. <term>
  1218. <mallctl>opt.prof_prefix</mallctl>
  1219. (<type>const char *</type>)
  1220. <literal>r-</literal>
  1221. [<option>--enable-prof</option>]
  1222. </term>
  1223. <listitem><para>Filename prefix for profile dumps. If the prefix is
  1224. set to the empty string, no automatic dumps will occur; this is
  1225. primarily useful for disabling the automatic final heap dump (which
  1226. also disables leak reporting, if enabled). The default prefix is
  1227. <filename>jeprof</filename>.</para></listitem>
  1228. </varlistentry>
  1229. <varlistentry id="opt.prof_active">
  1230. <term>
  1231. <mallctl>opt.prof_active</mallctl>
  1232. (<type>bool</type>)
  1233. <literal>r-</literal>
  1234. [<option>--enable-prof</option>]
  1235. </term>
  1236. <listitem><para>Profiling activated/deactivated. This is a secondary
  1237. control mechanism that makes it possible to start the application with
  1238. profiling enabled (see the <link
  1239. linkend="opt.prof"><mallctl>opt.prof</mallctl></link> option) but
  1240. inactive, then toggle profiling at any time during program execution
  1241. with the <link
  1242. linkend="prof.active"><mallctl>prof.active</mallctl></link> mallctl.
  1243. This option is enabled by default.</para></listitem>
  1244. </varlistentry>
  1245. <varlistentry id="opt.prof_thread_active_init">
  1246. <term>
  1247. <mallctl>opt.prof_thread_active_init</mallctl>
  1248. (<type>bool</type>)
  1249. <literal>r-</literal>
  1250. [<option>--enable-prof</option>]
  1251. </term>
  1252. <listitem><para>Initial setting for <link
  1253. linkend="thread.prof.active"><mallctl>thread.prof.active</mallctl></link>
  1254. in newly created threads. The initial setting for newly created threads
  1255. can also be changed during execution via the <link
  1256. linkend="prof.thread_active_init"><mallctl>prof.thread_active_init</mallctl></link>
  1257. mallctl. This option is enabled by default.</para></listitem>
  1258. </varlistentry>
  1259. <varlistentry id="opt.lg_prof_sample">
  1260. <term>
  1261. <mallctl>opt.lg_prof_sample</mallctl>
  1262. (<type>size_t</type>)
  1263. <literal>r-</literal>
  1264. [<option>--enable-prof</option>]
  1265. </term>
  1266. <listitem><para>Average interval (log base 2) between allocation
  1267. samples, as measured in bytes of allocation activity. Increasing the
  1268. sampling interval decreases profile fidelity, but also decreases the
  1269. computational overhead. The default sample interval is 512 KiB (2^19
  1270. B).</para></listitem>
  1271. </varlistentry>
  1272. <varlistentry id="opt.prof_accum">
  1273. <term>
  1274. <mallctl>opt.prof_accum</mallctl>
  1275. (<type>bool</type>)
  1276. <literal>r-</literal>
  1277. [<option>--enable-prof</option>]
  1278. </term>
  1279. <listitem><para>Reporting of cumulative object/byte counts in profile
  1280. dumps enabled/disabled. If this option is enabled, every unique
  1281. backtrace must be stored for the duration of execution. Depending on
  1282. the application, this can impose a large memory overhead, and the
  1283. cumulative counts are not always of interest. This option is disabled
  1284. by default.</para></listitem>
  1285. </varlistentry>
  1286. <varlistentry id="opt.lg_prof_interval">
  1287. <term>
  1288. <mallctl>opt.lg_prof_interval</mallctl>
  1289. (<type>ssize_t</type>)
  1290. <literal>r-</literal>
  1291. [<option>--enable-prof</option>]
  1292. </term>
  1293. <listitem><para>Average interval (log base 2) between memory profile
  1294. dumps, as measured in bytes of allocation activity. The actual
  1295. interval between dumps may be sporadic because decentralized allocation
  1296. counters are used to avoid synchronization bottlenecks. Profiles are
  1297. dumped to files named according to the pattern
  1298. <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.i&lt;iseq&gt;.heap</filename>,
  1299. where <literal>&lt;prefix&gt;</literal> is controlled by the
  1300. <link
  1301. linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
  1302. option. By default, interval-triggered profile dumping is disabled
  1303. (encoded as -1).
  1304. </para></listitem>
  1305. </varlistentry>
  1306. <varlistentry id="opt.prof_gdump">
  1307. <term>
  1308. <mallctl>opt.prof_gdump</mallctl>
  1309. (<type>bool</type>)
  1310. <literal>r-</literal>
  1311. [<option>--enable-prof</option>]
  1312. </term>
  1313. <listitem><para>Set the initial state of <link
  1314. linkend="prof.gdump"><mallctl>prof.gdump</mallctl></link>, which when
  1315. enabled triggers a memory profile dump every time the total virtual
  1316. memory exceeds the previous maximum. This option is disabled by
  1317. default.</para></listitem>
  1318. </varlistentry>
  1319. <varlistentry id="opt.prof_final">
  1320. <term>
  1321. <mallctl>opt.prof_final</mallctl>
  1322. (<type>bool</type>)
  1323. <literal>r-</literal>
  1324. [<option>--enable-prof</option>]
  1325. </term>
  1326. <listitem><para>Use an
  1327. <citerefentry><refentrytitle>atexit</refentrytitle>
  1328. <manvolnum>3</manvolnum></citerefentry> function to dump final memory
  1329. usage to a file named according to the pattern
  1330. <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.f.heap</filename>,
  1331. where <literal>&lt;prefix&gt;</literal> is controlled by the <link
  1332. linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
  1333. option. Note that <function>atexit()</function> may allocate
  1334. memory during application initialization and then deadlock internally
  1335. when jemalloc in turn calls <function>atexit()</function>, so
  1336. this option is not universally usable (though the application can
  1337. register its own <function>atexit()</function> function with
  1338. equivalent functionality). This option is disabled by
  1339. default.</para></listitem>
  1340. </varlistentry>
  1341. <varlistentry id="opt.prof_leak">
  1342. <term>
  1343. <mallctl>opt.prof_leak</mallctl>
  1344. (<type>bool</type>)
  1345. <literal>r-</literal>
  1346. [<option>--enable-prof</option>]
  1347. </term>
  1348. <listitem><para>Leak reporting enabled/disabled. If enabled, use an
  1349. <citerefentry><refentrytitle>atexit</refentrytitle>
  1350. <manvolnum>3</manvolnum></citerefentry> function to report memory leaks
  1351. detected by allocation sampling. See the
  1352. <link linkend="opt.prof"><mallctl>opt.prof</mallctl></link> option for
  1353. information on analyzing heap profile output. This option is disabled
  1354. by default.</para></listitem>
  1355. </varlistentry>
  1356. <varlistentry id="thread.arena">
  1357. <term>
  1358. <mallctl>thread.arena</mallctl>
  1359. (<type>unsigned</type>)
  1360. <literal>rw</literal>
  1361. </term>
  1362. <listitem><para>Get or set the arena associated with the calling
  1363. thread. If the specified arena was not initialized beforehand (see the
  1364. <link
  1365. linkend="arena.i.initialized"><mallctl>arena.i.initialized</mallctl></link>
  1366. mallctl), it will be automatically initialized as a side effect of
  1367. calling this interface.</para></listitem>
  1368. </varlistentry>
  1369. <varlistentry id="thread.allocated">
  1370. <term>
  1371. <mallctl>thread.allocated</mallctl>
  1372. (<type>uint64_t</type>)
  1373. <literal>r-</literal>
  1374. [<option>--enable-stats</option>]
  1375. </term>
  1376. <listitem><para>Get the total number of bytes ever allocated by the
  1377. calling thread. This counter has the potential to wrap around; it is
  1378. up to the application to appropriately interpret the counter in such
  1379. cases.</para></listitem>
  1380. </varlistentry>
  1381. <varlistentry id="thread.allocatedp">
  1382. <term>
  1383. <mallctl>thread.allocatedp</mallctl>
  1384. (<type>uint64_t *</type>)
  1385. <literal>r-</literal>
  1386. [<option>--enable-stats</option>]
  1387. </term>
  1388. <listitem><para>Get a pointer to the the value that is returned by the
  1389. <link
  1390. linkend="thread.allocated"><mallctl>thread.allocated</mallctl></link>
  1391. mallctl. This is useful for avoiding the overhead of repeated
  1392. <function>mallctl*()</function> calls.</para></listitem>
  1393. </varlistentry>
  1394. <varlistentry id="thread.deallocated">
  1395. <term>
  1396. <mallctl>thread.deallocated</mallctl>
  1397. (<type>uint64_t</type>)
  1398. <literal>r-</literal>
  1399. [<option>--enable-stats</option>]
  1400. </term>
  1401. <listitem><para>Get the total number of bytes ever deallocated by the
  1402. calling thread. This counter has the potential to wrap around; it is
  1403. up to the application to appropriately interpret the counter in such
  1404. cases.</para></listitem>
  1405. </varlistentry>
  1406. <varlistentry id="thread.deallocatedp">
  1407. <term>
  1408. <mallctl>thread.deallocatedp</mallctl>
  1409. (<type>uint64_t *</type>)
  1410. <literal>r-</literal>
  1411. [<option>--enable-stats</option>]
  1412. </term>
  1413. <listitem><para>Get a pointer to the the value that is returned by the
  1414. <link
  1415. linkend="thread.deallocated"><mallctl>thread.deallocated</mallctl></link>
  1416. mallctl. This is useful for avoiding the overhead of repeated
  1417. <function>mallctl*()</function> calls.</para></listitem>
  1418. </varlistentry>
  1419. <varlistentry id="thread.tcache.enabled">
  1420. <term>
  1421. <mallctl>thread.tcache.enabled</mallctl>
  1422. (<type>bool</type>)
  1423. <literal>rw</literal>
  1424. </term>
  1425. <listitem><para>Enable/disable calling thread's tcache. The tcache is
  1426. implicitly flushed as a side effect of becoming
  1427. disabled (see <link
  1428. linkend="thread.tcache.flush"><mallctl>thread.tcache.flush</mallctl></link>).
  1429. </para></listitem>
  1430. </varlistentry>
  1431. <varlistentry id="thread.tcache.flush">
  1432. <term>
  1433. <mallctl>thread.tcache.flush</mallctl>
  1434. (<type>void</type>)
  1435. <literal>--</literal>
  1436. </term>
  1437. <listitem><para>Flush calling thread's thread-specific cache (tcache).
  1438. This interface releases all cached objects and internal data structures
  1439. associated with the calling thread's tcache. Ordinarily, this interface
  1440. need not be called, since automatic periodic incremental garbage
  1441. collection occurs, and the thread cache is automatically discarded when
  1442. a thread exits. However, garbage collection is triggered by allocation
  1443. activity, so it is possible for a thread that stops
  1444. allocating/deallocating to retain its cache indefinitely, in which case
  1445. the developer may find manual flushing useful.</para></listitem>
  1446. </varlistentry>
  1447. <varlistentry id="thread.prof.name">
  1448. <term>
  1449. <mallctl>thread.prof.name</mallctl>
  1450. (<type>const char *</type>)
  1451. <literal>r-</literal> or
  1452. <literal>-w</literal>
  1453. [<option>--enable-prof</option>]
  1454. </term>
  1455. <listitem><para>Get/set the descriptive name associated with the calling
  1456. thread in memory profile dumps. An internal copy of the name string is
  1457. created, so the input string need not be maintained after this interface
  1458. completes execution. The output string of this interface should be
  1459. copied for non-ephemeral uses, because multiple implementation details
  1460. can cause asynchronous string deallocation. Furthermore, each
  1461. invocation of this interface can only read or write; simultaneous
  1462. read/write is not supported due to string lifetime limitations. The
  1463. name string must be nil-terminated and comprised only of characters in
  1464. the sets recognized
  1465. by <citerefentry><refentrytitle>isgraph</refentrytitle>
  1466. <manvolnum>3</manvolnum></citerefentry> and
  1467. <citerefentry><refentrytitle>isblank</refentrytitle>
  1468. <manvolnum>3</manvolnum></citerefentry>.</para></listitem>
  1469. </varlistentry>
  1470. <varlistentry id="thread.prof.active">
  1471. <term>
  1472. <mallctl>thread.prof.active</mallctl>
  1473. (<type>bool</type>)
  1474. <literal>rw</literal>
  1475. [<option>--enable-prof</option>]
  1476. </term>
  1477. <listitem><para>Control whether sampling is currently active for the
  1478. calling thread. This is an activation mechanism in addition to <link
  1479. linkend="prof.active"><mallctl>prof.active</mallctl></link>; both must
  1480. be active for the calling thread to sample. This flag is enabled by
  1481. default.</para></listitem>
  1482. </varlistentry>
  1483. <varlistentry id="tcache.create">
  1484. <term>
  1485. <mallctl>tcache.create</mallctl>
  1486. (<type>unsigned</type>)
  1487. <literal>r-</literal>
  1488. </term>
  1489. <listitem><para>Create an explicit thread-specific cache (tcache) and
  1490. return an identifier that can be passed to the <link
  1491. linkend="MALLOCX_TCACHE"><constant>MALLOCX_TCACHE(<parameter>tc</parameter>)</constant></link>
  1492. macro to explicitly use the specified cache rather than the
  1493. automatically managed one that is used by default. Each explicit cache
  1494. can be used by only one thread at a time; the application must assure
  1495. that this constraint holds.
  1496. </para></listitem>
  1497. </varlistentry>
  1498. <varlistentry id="tcache.flush">
  1499. <term>
  1500. <mallctl>tcache.flush</mallctl>
  1501. (<type>unsigned</type>)
  1502. <literal>-w</literal>
  1503. </term>
  1504. <listitem><para>Flush the specified thread-specific cache (tcache). The
  1505. same considerations apply to this interface as to <link
  1506. linkend="thread.tcache.flush"><mallctl>thread.tcache.flush</mallctl></link>,
  1507. except that the tcache will never be automatically discarded.
  1508. </para></listitem>
  1509. </varlistentry>
  1510. <varlistentry id="tcache.destroy">
  1511. <term>
  1512. <mallctl>tcache.destroy</mallctl>
  1513. (<type>unsigned</type>)
  1514. <literal>-w</literal>
  1515. </term>
  1516. <listitem><para>Flush the specified thread-specific cache (tcache) and
  1517. make the identifier available for use during a future tcache creation.
  1518. </para></listitem>
  1519. </varlistentry>
  1520. <varlistentry id="arena.i.initialized">
  1521. <term>
  1522. <mallctl>arena.&lt;i&gt;.initialized</mallctl>
  1523. (<type>bool</type>)
  1524. <literal>r-</literal>
  1525. </term>
  1526. <listitem><para>Get whether the specified arena's statistics are
  1527. initialized (i.e. the arena was initialized prior to the current epoch).
  1528. This interface can also be nominally used to query whether the merged
  1529. statistics corresponding to <constant>MALLCTL_ARENAS_ALL</constant> are
  1530. initialized (always true).</para></listitem>
  1531. </varlistentry>
  1532. <varlistentry id="arena.i.decay">
  1533. <term>
  1534. <mallctl>arena.&lt;i&gt;.decay</mallctl>
  1535. (<type>void</type>)
  1536. <literal>--</literal>
  1537. </term>
  1538. <listitem><para>Trigger decay-based purging of unused dirty/muzzy pages
  1539. for arena &lt;i&gt;, or for all arenas if &lt;i&gt; equals
  1540. <constant>MALLCTL_ARENAS_ALL</constant>. The proportion of unused
  1541. dirty/muzzy pages to be purged depends on the current time; see <link
  1542. linkend="opt.dirty_decay_ms"><mallctl>opt.dirty_decay_ms</mallctl></link>
  1543. and <link
  1544. linkend="opt.muzzy_decay_ms"><mallctl>opt.muzy_decay_ms</mallctl></link>
  1545. for details.</para></listitem>
  1546. </varlistentry>
  1547. <varlistentry id="arena.i.purge">
  1548. <term>
  1549. <mallctl>arena.&lt;i&gt;.purge</mallctl>
  1550. (<type>void</type>)
  1551. <literal>--</literal>
  1552. </term>
  1553. <listitem><para>Purge all unused dirty pages for arena &lt;i&gt;, or for
  1554. all arenas if &lt;i&gt; equals <constant>MALLCTL_ARENAS_ALL</constant>.
  1555. </para></listitem>
  1556. </varlistentry>
  1557. <varlistentry id="arena.i.reset">
  1558. <term>
  1559. <mallctl>arena.&lt;i&gt;.reset</mallctl>
  1560. (<type>void</type>)
  1561. <literal>--</literal>
  1562. </term>
  1563. <listitem><para>Discard all of the arena's extant allocations. This
  1564. interface can only be used with arenas explicitly created via <link
  1565. linkend="arenas.create"><mallctl>arenas.create</mallctl></link>. None
  1566. of the arena's discarded/cached allocations may accessed afterward. As
  1567. part of this requirement, all thread caches which were used to
  1568. allocate/deallocate in conjunction with the arena must be flushed
  1569. beforehand.</para></listitem>
  1570. </varlistentry>
  1571. <varlistentry id="arena.i.destroy">
  1572. <term>
  1573. <mallctl>arena.&lt;i&gt;.destroy</mallctl>
  1574. (<type>void</type>)
  1575. <literal>--</literal>
  1576. </term>
  1577. <listitem><para>Destroy the arena. Discard all of the arena's extant
  1578. allocations using the same mechanism as for <link
  1579. linkend="arena.i.reset"><mallctl>arena.&lt;i&gt;.reset</mallctl></link>
  1580. (with all the same constraints and side effects), merge the arena stats
  1581. into those accessible at arena index
  1582. <constant>MALLCTL_ARENAS_DESTROYED</constant>, and then completely
  1583. discard all metadata associated with the arena. Future calls to <link
  1584. linkend="arenas.create"><mallctl>arenas.create</mallctl></link> may
  1585. recycle the arena index. Destruction will fail if any threads are
  1586. currently associated with the arena as a result of calls to <link
  1587. linkend="thread.arena"><mallctl>thread.arena</mallctl></link>.</para></listitem>
  1588. </varlistentry>
  1589. <varlistentry id="arena.i.dss">
  1590. <term>
  1591. <mallctl>arena.&lt;i&gt;.dss</mallctl>
  1592. (<type>const char *</type>)
  1593. <literal>rw</literal>
  1594. </term>
  1595. <listitem><para>Set the precedence of dss allocation as related to mmap
  1596. allocation for arena &lt;i&gt;, or for all arenas if &lt;i&gt; equals
  1597. <constant>MALLCTL_ARENAS_ALL</constant>. See <link
  1598. linkend="opt.dss"><mallctl>opt.dss</mallctl></link> for supported
  1599. settings.</para></listitem>
  1600. </varlistentry>
  1601. <varlistentry id="arena.i.dirty_decay_ms">
  1602. <term>
  1603. <mallctl>arena.&lt;i&gt;.dirty_decay_ms</mallctl>
  1604. (<type>ssize_t</type>)
  1605. <literal>rw</literal>
  1606. </term>
  1607. <listitem><para>Current per-arena approximate time in milliseconds from
  1608. the creation of a set of unused dirty pages until an equivalent set of
  1609. unused dirty pages is purged and/or reused. Each time this interface is
  1610. set, all currently unused dirty pages are considered to have fully
  1611. decayed, which causes immediate purging of all unused dirty pages unless
  1612. the decay time is set to -1 (i.e. purging disabled). See <link
  1613. linkend="opt.dirty_decay_ms"><mallctl>opt.dirty_decay_ms</mallctl></link>
  1614. for additional information.</para></listitem>
  1615. </varlistentry>
  1616. <varlistentry id="arena.i.muzzy_decay_ms">
  1617. <term>
  1618. <mallctl>arena.&lt;i&gt;.muzzy_decay_ms</mallctl>
  1619. (<type>ssize_t</type>)
  1620. <literal>rw</literal>
  1621. </term>
  1622. <listitem><para>Current per-arena approximate time in milliseconds from
  1623. the creation of a set of unused muzzy pages until an equivalent set of
  1624. unused muzzy pages is purged and/or reused. Each time this interface is
  1625. set, all currently unused muzzy pages are considered to have fully
  1626. decayed, which causes immediate purging of all unused muzzy pages unless
  1627. the decay time is set to -1 (i.e. purging disabled). See <link
  1628. linkend="opt.muzzy_decay_ms"><mallctl>opt.muzzy_decay_ms</mallctl></link>
  1629. for additional information.</para></listitem>
  1630. </varlistentry>
  1631. <varlistentry id="arena.i.retain_grow_limit">
  1632. <term>
  1633. <mallctl>arena.&lt;i&gt;.retain_grow_limit</mallctl>
  1634. (<type>size_t</type>)
  1635. <literal>rw</literal>
  1636. </term>
  1637. <listitem><para>Maximum size to grow retained region (only relevant when
  1638. <link linkend="opt.retain"><mallctl>opt.retain</mallctl></link> is
  1639. enabled). This controls the maximum increment to expand virtual memory,
  1640. or allocation through <link
  1641. linkend="arena.i.extent_hooks"><mallctl>arena.&lt;i&gt;extent_hooks</mallctl></link>.
  1642. In particular, if customized extent hooks reserve physical memory
  1643. (e.g. 1G huge pages), this is useful to control the allocation hook's
  1644. input size. The default is no limit.</para></listitem>
  1645. </varlistentry>
  1646. <varlistentry id="arena.i.extent_hooks">
  1647. <term>
  1648. <mallctl>arena.&lt;i&gt;.extent_hooks</mallctl>
  1649. (<type>extent_hooks_t *</type>)
  1650. <literal>rw</literal>
  1651. </term>
  1652. <listitem><para>Get or set the extent management hook functions for
  1653. arena &lt;i&gt;. The functions must be capable of operating on all
  1654. extant extents associated with arena &lt;i&gt;, usually by passing
  1655. unknown extents to the replaced functions. In practice, it is feasible
  1656. to control allocation for arenas explicitly created via <link
  1657. linkend="arenas.create"><mallctl>arenas.create</mallctl></link> such
  1658. that all extents originate from an application-supplied extent allocator
  1659. (by specifying the custom extent hook functions during arena creation),
  1660. but the automatically created arenas will have already created extents
  1661. prior to the application having an opportunity to take over extent
  1662. allocation.</para>
  1663. <programlisting language="C"><![CDATA[
  1664. typedef extent_hooks_s extent_hooks_t;
  1665. struct extent_hooks_s {
  1666. extent_alloc_t *alloc;
  1667. extent_dalloc_t *dalloc;
  1668. extent_destroy_t *destroy;
  1669. extent_commit_t *commit;
  1670. extent_decommit_t *decommit;
  1671. extent_purge_t *purge_lazy;
  1672. extent_purge_t *purge_forced;
  1673. extent_split_t *split;
  1674. extent_merge_t *merge;
  1675. };]]></programlisting>
  1676. <para>The <type>extent_hooks_t</type> structure comprises function
  1677. pointers which are described individually below. jemalloc uses these
  1678. functions to manage extent lifetime, which starts off with allocation of
  1679. mapped committed memory, in the simplest case followed by deallocation.
  1680. However, there are performance and platform reasons to retain extents
  1681. for later reuse. Cleanup attempts cascade from deallocation to decommit
  1682. to forced purging to lazy purging, which gives the extent management
  1683. functions opportunities to reject the most permanent cleanup operations
  1684. in favor of less permanent (and often less costly) operations. All
  1685. operations except allocation can be universally opted out of by setting
  1686. the hook pointers to <constant>NULL</constant>, or selectively opted out
  1687. of by returning failure. Note that once the extent hook is set, the
  1688. structure is accessed directly by the associated arenas, so it must
  1689. remain valid for the entire lifetime of the arenas.</para>
  1690. <funcsynopsis><funcprototype>
  1691. <funcdef>typedef void *<function>(extent_alloc_t)</function></funcdef>
  1692. <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef>
  1693. <paramdef>void *<parameter>new_addr</parameter></paramdef>
  1694. <paramdef>size_t <parameter>size</parameter></paramdef>
  1695. <paramdef>size_t <parameter>alignment</parameter></paramdef>
  1696. <paramdef>bool *<parameter>zero</parameter></paramdef>
  1697. <paramdef>bool *<parameter>commit</parameter></paramdef>
  1698. <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
  1699. </funcprototype></funcsynopsis>
  1700. <literallayout></literallayout>
  1701. <para>An extent allocation function conforms to the
  1702. <type>extent_alloc_t</type> type and upon success returns a pointer to
  1703. <parameter>size</parameter> bytes of mapped memory on behalf of arena
  1704. <parameter>arena_ind</parameter> such that the extent's base address is
  1705. a multiple of <parameter>alignment</parameter>, as well as setting
  1706. <parameter>*zero</parameter> to indicate whether the extent is zeroed
  1707. and <parameter>*commit</parameter> to indicate whether the extent is
  1708. committed. Upon error the function returns <constant>NULL</constant>
  1709. and leaves <parameter>*zero</parameter> and
  1710. <parameter>*commit</parameter> unmodified. The
  1711. <parameter>size</parameter> parameter is always a multiple of the page
  1712. size. The <parameter>alignment</parameter> parameter is always a power
  1713. of two at least as large as the page size. Zeroing is mandatory if
  1714. <parameter>*zero</parameter> is true upon function entry. Committing is
  1715. mandatory if <parameter>*commit</parameter> is true upon function entry.
  1716. If <parameter>new_addr</parameter> is not <constant>NULL</constant>, the
  1717. returned pointer must be <parameter>new_addr</parameter> on success or
  1718. <constant>NULL</constant> on error. Committed memory may be committed
  1719. in absolute terms as on a system that does not overcommit, or in
  1720. implicit terms as on a system that overcommits and satisfies physical
  1721. memory needs on demand via soft page faults. Note that replacing the
  1722. default extent allocation function makes the arena's <link
  1723. linkend="arena.i.dss"><mallctl>arena.&lt;i&gt;.dss</mallctl></link>
  1724. setting irrelevant.</para>
  1725. <funcsynopsis><funcprototype>
  1726. <funcdef>typedef bool <function>(extent_dalloc_t)</function></funcdef>
  1727. <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef>
  1728. <paramdef>void *<parameter>addr</parameter></paramdef>
  1729. <paramdef>size_t <parameter>size</parameter></paramdef>
  1730. <paramdef>bool <parameter>committed</parameter></paramdef>
  1731. <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
  1732. </funcprototype></funcsynopsis>
  1733. <literallayout></literallayout>
  1734. <para>
  1735. An extent deallocation function conforms to the
  1736. <type>extent_dalloc_t</type> type and deallocates an extent at given
  1737. <parameter>addr</parameter> and <parameter>size</parameter> with
  1738. <parameter>committed</parameter>/decommited memory as indicated, on
  1739. behalf of arena <parameter>arena_ind</parameter>, returning false upon
  1740. success. If the function returns true, this indicates opt-out from
  1741. deallocation; the virtual memory mapping associated with the extent
  1742. remains mapped, in the same commit state, and available for future use,
  1743. in which case it will be automatically retained for later reuse.</para>
  1744. <funcsynopsis><funcprototype>
  1745. <funcdef>typedef void <function>(extent_destroy_t)</function></funcdef>
  1746. <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef>
  1747. <paramdef>void *<parameter>addr</parameter></paramdef>
  1748. <paramdef>size_t <parameter>size</parameter></paramdef>
  1749. <paramdef>bool <parameter>committed</parameter></paramdef>
  1750. <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
  1751. </funcprototype></funcsynopsis>
  1752. <literallayout></literallayout>
  1753. <para>
  1754. An extent destruction function conforms to the
  1755. <type>extent_destroy_t</type> type and unconditionally destroys an
  1756. extent at given <parameter>addr</parameter> and
  1757. <parameter>size</parameter> with
  1758. <parameter>committed</parameter>/decommited memory as indicated, on
  1759. behalf of arena <parameter>arena_ind</parameter>. This function may be
  1760. called to destroy retained extents during arena destruction (see <link
  1761. linkend="arena.i.destroy"><mallctl>arena.&lt;i&gt;.destroy</mallctl></link>).</para>
  1762. <funcsynopsis><funcprototype>
  1763. <funcdef>typedef bool <function>(extent_commit_t)</function></funcdef>
  1764. <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef>
  1765. <paramdef>void *<parameter>addr</parameter></paramdef>
  1766. <paramdef>size_t <parameter>size</parameter></paramdef>
  1767. <paramdef>size_t <parameter>offset</parameter></paramdef>
  1768. <paramdef>size_t <parameter>length</parameter></paramdef>
  1769. <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
  1770. </funcprototype></funcsynopsis>
  1771. <literallayout></literallayout>
  1772. <para>An extent commit function conforms to the
  1773. <type>extent_commit_t</type> type and commits zeroed physical memory to
  1774. back pages within an extent at given <parameter>addr</parameter> and
  1775. <parameter>size</parameter> at <parameter>offset</parameter> bytes,
  1776. extending for <parameter>length</parameter> on behalf of arena
  1777. <parameter>arena_ind</parameter>, returning false upon success.
  1778. Committed memory may be committed in absolute terms as on a system that
  1779. does not overcommit, or in implicit terms as on a system that
  1780. overcommits and satisfies physical memory needs on demand via soft page
  1781. faults. If the function returns true, this indicates insufficient
  1782. physical memory to satisfy the request.</para>
  1783. <funcsynopsis><funcprototype>
  1784. <funcdef>typedef bool <function>(extent_decommit_t)</function></funcdef>
  1785. <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef>
  1786. <paramdef>void *<parameter>addr</parameter></paramdef>
  1787. <paramdef>size_t <parameter>size</parameter></paramdef>
  1788. <paramdef>size_t <parameter>offset</parameter></paramdef>
  1789. <paramdef>size_t <parameter>length</parameter></paramdef>
  1790. <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
  1791. </funcprototype></funcsynopsis>
  1792. <literallayout></literallayout>
  1793. <para>An extent decommit function conforms to the
  1794. <type>extent_decommit_t</type> type and decommits any physical memory
  1795. that is backing pages within an extent at given
  1796. <parameter>addr</parameter> and <parameter>size</parameter> at
  1797. <parameter>offset</parameter> bytes, extending for
  1798. <parameter>length</parameter> on behalf of arena
  1799. <parameter>arena_ind</parameter>, returning false upon success, in which
  1800. case the pages will be committed via the extent commit function before
  1801. being reused. If the function returns true, this indicates opt-out from
  1802. decommit; the memory remains committed and available for future use, in
  1803. which case it will be automatically retained for later reuse.</para>
  1804. <funcsynopsis><funcprototype>
  1805. <funcdef>typedef bool <function>(extent_purge_t)</function></funcdef>
  1806. <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef>
  1807. <paramdef>void *<parameter>addr</parameter></paramdef>
  1808. <paramdef>size_t <parameter>size</parameter></paramdef>
  1809. <paramdef>size_t <parameter>offset</parameter></paramdef>
  1810. <paramdef>size_t <parameter>length</parameter></paramdef>
  1811. <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
  1812. </funcprototype></funcsynopsis>
  1813. <literallayout></literallayout>
  1814. <para>An extent purge function conforms to the
  1815. <type>extent_purge_t</type> type and discards physical pages
  1816. within the virtual memory mapping associated with an extent at given
  1817. <parameter>addr</parameter> and <parameter>size</parameter> at
  1818. <parameter>offset</parameter> bytes, extending for
  1819. <parameter>length</parameter> on behalf of arena
  1820. <parameter>arena_ind</parameter>. A lazy extent purge function (e.g.
  1821. implemented via
  1822. <function>madvise(<parameter>...</parameter><parameter><constant>MADV_FREE</constant></parameter>)</function>)
  1823. can delay purging indefinitely and leave the pages within the purged
  1824. virtual memory range in an indeterminite state, whereas a forced extent
  1825. purge function immediately purges, and the pages within the virtual
  1826. memory range will be zero-filled the next time they are accessed. If
  1827. the function returns true, this indicates failure to purge.</para>
  1828. <funcsynopsis><funcprototype>
  1829. <funcdef>typedef bool <function>(extent_split_t)</function></funcdef>
  1830. <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef>
  1831. <paramdef>void *<parameter>addr</parameter></paramdef>
  1832. <paramdef>size_t <parameter>size</parameter></paramdef>
  1833. <paramdef>size_t <parameter>size_a</parameter></paramdef>
  1834. <paramdef>size_t <parameter>size_b</parameter></paramdef>
  1835. <paramdef>bool <parameter>committed</parameter></paramdef>
  1836. <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
  1837. </funcprototype></funcsynopsis>
  1838. <literallayout></literallayout>
  1839. <para>An extent split function conforms to the
  1840. <type>extent_split_t</type> type and optionally splits an extent at
  1841. given <parameter>addr</parameter> and <parameter>size</parameter> into
  1842. two adjacent extents, the first of <parameter>size_a</parameter> bytes,
  1843. and the second of <parameter>size_b</parameter> bytes, operating on
  1844. <parameter>committed</parameter>/decommitted memory as indicated, on
  1845. behalf of arena <parameter>arena_ind</parameter>, returning false upon
  1846. success. If the function returns true, this indicates that the extent
  1847. remains unsplit and therefore should continue to be operated on as a
  1848. whole.</para>
  1849. <funcsynopsis><funcprototype>
  1850. <funcdef>typedef bool <function>(extent_merge_t)</function></funcdef>
  1851. <paramdef>extent_hooks_t *<parameter>extent_hooks</parameter></paramdef>
  1852. <paramdef>void *<parameter>addr_a</parameter></paramdef>
  1853. <paramdef>size_t <parameter>size_a</parameter></paramdef>
  1854. <paramdef>void *<parameter>addr_b</parameter></paramdef>
  1855. <paramdef>size_t <parameter>size_b</parameter></paramdef>
  1856. <paramdef>bool <parameter>committed</parameter></paramdef>
  1857. <paramdef>unsigned <parameter>arena_ind</parameter></paramdef>
  1858. </funcprototype></funcsynopsis>
  1859. <literallayout></literallayout>
  1860. <para>An extent merge function conforms to the
  1861. <type>extent_merge_t</type> type and optionally merges adjacent extents,
  1862. at given <parameter>addr_a</parameter> and <parameter>size_a</parameter>
  1863. with given <parameter>addr_b</parameter> and
  1864. <parameter>size_b</parameter> into one contiguous extent, operating on
  1865. <parameter>committed</parameter>/decommitted memory as indicated, on
  1866. behalf of arena <parameter>arena_ind</parameter>, returning false upon
  1867. success. If the function returns true, this indicates that the extents
  1868. remain distinct mappings and therefore should continue to be operated on
  1869. independently.</para>
  1870. </listitem>
  1871. </varlistentry>
  1872. <varlistentry id="arenas.narenas">
  1873. <term>
  1874. <mallctl>arenas.narenas</mallctl>
  1875. (<type>unsigned</type>)
  1876. <literal>r-</literal>
  1877. </term>
  1878. <listitem><para>Current limit on number of arenas.</para></listitem>
  1879. </varlistentry>
  1880. <varlistentry id="arenas.dirty_decay_ms">
  1881. <term>
  1882. <mallctl>arenas.dirty_decay_ms</mallctl>
  1883. (<type>ssize_t</type>)
  1884. <literal>rw</literal>
  1885. </term>
  1886. <listitem><para>Current default per-arena approximate time in
  1887. milliseconds from the creation of a set of unused dirty pages until an
  1888. equivalent set of unused dirty pages is purged and/or reused, used to
  1889. initialize <link
  1890. linkend="arena.i.dirty_decay_ms"><mallctl>arena.&lt;i&gt;.dirty_decay_ms</mallctl></link>
  1891. during arena creation. See <link
  1892. linkend="opt.dirty_decay_ms"><mallctl>opt.dirty_decay_ms</mallctl></link>
  1893. for additional information.</para></listitem>
  1894. </varlistentry>
  1895. <varlistentry id="arenas.muzzy_decay_ms">
  1896. <term>
  1897. <mallctl>arenas.muzzy_decay_ms</mallctl>
  1898. (<type>ssize_t</type>)
  1899. <literal>rw</literal>
  1900. </term>
  1901. <listitem><para>Current default per-arena approximate time in
  1902. milliseconds from the creation of a set of unused muzzy pages until an
  1903. equivalent set of unused muzzy pages is purged and/or reused, used to
  1904. initialize <link
  1905. linkend="arena.i.muzzy_decay_ms"><mallctl>arena.&lt;i&gt;.muzzy_decay_ms</mallctl></link>
  1906. during arena creation. See <link
  1907. linkend="opt.muzzy_decay_ms"><mallctl>opt.muzzy_decay_ms</mallctl></link>
  1908. for additional information.</para></listitem>
  1909. </varlistentry>
  1910. <varlistentry id="arenas.quantum">
  1911. <term>
  1912. <mallctl>arenas.quantum</mallctl>
  1913. (<type>size_t</type>)
  1914. <literal>r-</literal>
  1915. </term>
  1916. <listitem><para>Quantum size.</para></listitem>
  1917. </varlistentry>
  1918. <varlistentry id="arenas.page">
  1919. <term>
  1920. <mallctl>arenas.page</mallctl>
  1921. (<type>size_t</type>)
  1922. <literal>r-</literal>
  1923. </term>
  1924. <listitem><para>Page size.</para></listitem>
  1925. </varlistentry>
  1926. <varlistentry id="arenas.tcache_max">
  1927. <term>
  1928. <mallctl>arenas.tcache_max</mallctl>
  1929. (<type>size_t</type>)
  1930. <literal>r-</literal>
  1931. </term>
  1932. <listitem><para>Maximum thread-cached size class.</para></listitem>
  1933. </varlistentry>
  1934. <varlistentry id="arenas.nbins">
  1935. <term>
  1936. <mallctl>arenas.nbins</mallctl>
  1937. (<type>unsigned</type>)
  1938. <literal>r-</literal>
  1939. </term>
  1940. <listitem><para>Number of bin size classes.</para></listitem>
  1941. </varlistentry>
  1942. <varlistentry id="arenas.nhbins">
  1943. <term>
  1944. <mallctl>arenas.nhbins</mallctl>
  1945. (<type>unsigned</type>)
  1946. <literal>r-</literal>
  1947. </term>
  1948. <listitem><para>Total number of thread cache bin size
  1949. classes.</para></listitem>
  1950. </varlistentry>
  1951. <varlistentry id="arenas.bin.i.size">
  1952. <term>
  1953. <mallctl>arenas.bin.&lt;i&gt;.size</mallctl>
  1954. (<type>size_t</type>)
  1955. <literal>r-</literal>
  1956. </term>
  1957. <listitem><para>Maximum size supported by size class.</para></listitem>
  1958. </varlistentry>
  1959. <varlistentry id="arenas.bin.i.nregs">
  1960. <term>
  1961. <mallctl>arenas.bin.&lt;i&gt;.nregs</mallctl>
  1962. (<type>uint32_t</type>)
  1963. <literal>r-</literal>
  1964. </term>
  1965. <listitem><para>Number of regions per slab.</para></listitem>
  1966. </varlistentry>
  1967. <varlistentry id="arenas.bin.i.slab_size">
  1968. <term>
  1969. <mallctl>arenas.bin.&lt;i&gt;.slab_size</mallctl>
  1970. (<type>size_t</type>)
  1971. <literal>r-</literal>
  1972. </term>
  1973. <listitem><para>Number of bytes per slab.</para></listitem>
  1974. </varlistentry>
  1975. <varlistentry id="arenas.nlextents">
  1976. <term>
  1977. <mallctl>arenas.nlextents</mallctl>
  1978. (<type>unsigned</type>)
  1979. <literal>r-</literal>
  1980. </term>
  1981. <listitem><para>Total number of large size classes.</para></listitem>
  1982. </varlistentry>
  1983. <varlistentry id="arenas.lextent.i.size">
  1984. <term>
  1985. <mallctl>arenas.lextent.&lt;i&gt;.size</mallctl>
  1986. (<type>size_t</type>)
  1987. <literal>r-</literal>
  1988. </term>
  1989. <listitem><para>Maximum size supported by this large size
  1990. class.</para></listitem>
  1991. </varlistentry>
  1992. <varlistentry id="arenas.create">
  1993. <term>
  1994. <mallctl>arenas.create</mallctl>
  1995. (<type>unsigned</type>, <type>extent_hooks_t *</type>)
  1996. <literal>rw</literal>
  1997. </term>
  1998. <listitem><para>Explicitly create a new arena outside the range of
  1999. automatically managed arenas, with optionally specified extent hooks,
  2000. and return the new arena index.</para></listitem>
  2001. </varlistentry>
  2002. <varlistentry id="arenas.lookup">
  2003. <term>
  2004. <mallctl>arenas.lookup</mallctl>
  2005. (<type>unsigned</type>, <type>void*</type>)
  2006. <literal>rw</literal>
  2007. </term>
  2008. <listitem><para>Index of the arena to which an allocation belongs to.</para></listitem>
  2009. </varlistentry>
  2010. <varlistentry id="prof.thread_active_init">
  2011. <term>
  2012. <mallctl>prof.thread_active_init</mallctl>
  2013. (<type>bool</type>)
  2014. <literal>rw</literal>
  2015. [<option>--enable-prof</option>]
  2016. </term>
  2017. <listitem><para>Control the initial setting for <link
  2018. linkend="thread.prof.active"><mallctl>thread.prof.active</mallctl></link>
  2019. in newly created threads. See the <link
  2020. linkend="opt.prof_thread_active_init"><mallctl>opt.prof_thread_active_init</mallctl></link>
  2021. option for additional information.</para></listitem>
  2022. </varlistentry>
  2023. <varlistentry id="prof.active">
  2024. <term>
  2025. <mallctl>prof.active</mallctl>
  2026. (<type>bool</type>)
  2027. <literal>rw</literal>
  2028. [<option>--enable-prof</option>]
  2029. </term>
  2030. <listitem><para>Control whether sampling is currently active. See the
  2031. <link
  2032. linkend="opt.prof_active"><mallctl>opt.prof_active</mallctl></link>
  2033. option for additional information, as well as the interrelated <link
  2034. linkend="thread.prof.active"><mallctl>thread.prof.active</mallctl></link>
  2035. mallctl.</para></listitem>
  2036. </varlistentry>
  2037. <varlistentry id="prof.dump">
  2038. <term>
  2039. <mallctl>prof.dump</mallctl>
  2040. (<type>const char *</type>)
  2041. <literal>-w</literal>
  2042. [<option>--enable-prof</option>]
  2043. </term>
  2044. <listitem><para>Dump a memory profile to the specified file, or if NULL
  2045. is specified, to a file according to the pattern
  2046. <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.m&lt;mseq&gt;.heap</filename>,
  2047. where <literal>&lt;prefix&gt;</literal> is controlled by the
  2048. <link
  2049. linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
  2050. option.</para></listitem>
  2051. </varlistentry>
  2052. <varlistentry id="prof.gdump">
  2053. <term>
  2054. <mallctl>prof.gdump</mallctl>
  2055. (<type>bool</type>)
  2056. <literal>rw</literal>
  2057. [<option>--enable-prof</option>]
  2058. </term>
  2059. <listitem><para>When enabled, trigger a memory profile dump every time
  2060. the total virtual memory exceeds the previous maximum. Profiles are
  2061. dumped to files named according to the pattern
  2062. <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.u&lt;useq&gt;.heap</filename>,
  2063. where <literal>&lt;prefix&gt;</literal> is controlled by the <link
  2064. linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
  2065. option.</para></listitem>
  2066. </varlistentry>
  2067. <varlistentry id="prof.reset">
  2068. <term>
  2069. <mallctl>prof.reset</mallctl>
  2070. (<type>size_t</type>)
  2071. <literal>-w</literal>
  2072. [<option>--enable-prof</option>]
  2073. </term>
  2074. <listitem><para>Reset all memory profile statistics, and optionally
  2075. update the sample rate (see <link
  2076. linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link>
  2077. and <link
  2078. linkend="prof.lg_sample"><mallctl>prof.lg_sample</mallctl></link>).
  2079. </para></listitem>
  2080. </varlistentry>
  2081. <varlistentry id="prof.lg_sample">
  2082. <term>
  2083. <mallctl>prof.lg_sample</mallctl>
  2084. (<type>size_t</type>)
  2085. <literal>r-</literal>
  2086. [<option>--enable-prof</option>]
  2087. </term>
  2088. <listitem><para>Get the current sample rate (see <link
  2089. linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link>).
  2090. </para></listitem>
  2091. </varlistentry>
  2092. <varlistentry id="prof.interval">
  2093. <term>
  2094. <mallctl>prof.interval</mallctl>
  2095. (<type>uint64_t</type>)
  2096. <literal>r-</literal>
  2097. [<option>--enable-prof</option>]
  2098. </term>
  2099. <listitem><para>Average number of bytes allocated between
  2100. interval-based profile dumps. See the
  2101. <link
  2102. linkend="opt.lg_prof_interval"><mallctl>opt.lg_prof_interval</mallctl></link>
  2103. option for additional information.</para></listitem>
  2104. </varlistentry>
  2105. <varlistentry id="stats.allocated">
  2106. <term>
  2107. <mallctl>stats.allocated</mallctl>
  2108. (<type>size_t</type>)
  2109. <literal>r-</literal>
  2110. [<option>--enable-stats</option>]
  2111. </term>
  2112. <listitem><para>Total number of bytes allocated by the
  2113. application.</para></listitem>
  2114. </varlistentry>
  2115. <varlistentry id="stats.active">
  2116. <term>
  2117. <mallctl>stats.active</mallctl>
  2118. (<type>size_t</type>)
  2119. <literal>r-</literal>
  2120. [<option>--enable-stats</option>]
  2121. </term>
  2122. <listitem><para>Total number of bytes in active pages allocated by the
  2123. application. This is a multiple of the page size, and greater than or
  2124. equal to <link
  2125. linkend="stats.allocated"><mallctl>stats.allocated</mallctl></link>.
  2126. This does not include <link linkend="stats.arenas.i.pdirty">
  2127. <mallctl>stats.arenas.&lt;i&gt;.pdirty</mallctl></link>,
  2128. <link linkend="stats.arenas.i.pmuzzy">
  2129. <mallctl>stats.arenas.&lt;i&gt;.pmuzzy</mallctl></link>, nor pages
  2130. entirely devoted to allocator metadata.</para></listitem>
  2131. </varlistentry>
  2132. <varlistentry id="stats.metadata">
  2133. <term>
  2134. <mallctl>stats.metadata</mallctl>
  2135. (<type>size_t</type>)
  2136. <literal>r-</literal>
  2137. [<option>--enable-stats</option>]
  2138. </term>
  2139. <listitem><para>Total number of bytes dedicated to metadata, which
  2140. comprise base allocations used for bootstrap-sensitive allocator
  2141. metadata structures (see <link
  2142. linkend="stats.arenas.i.base"><mallctl>stats.arenas.&lt;i&gt;.base</mallctl></link>)
  2143. and internal allocations (see <link
  2144. linkend="stats.arenas.i.internal"><mallctl>stats.arenas.&lt;i&gt;.internal</mallctl></link>).
  2145. Transparent huge page (enabled with <link
  2146. linkend="opt.metadata_thp">opt.metadata_thp</link>) usage is not
  2147. considered.</para></listitem>
  2148. </varlistentry>
  2149. <varlistentry id="stats.metadata_thp">
  2150. <term>
  2151. <mallctl>stats.metadata_thp</mallctl>
  2152. (<type>size_t</type>)
  2153. <literal>r-</literal>
  2154. [<option>--enable-stats</option>]
  2155. </term>
  2156. <listitem><para>Number of transparent huge pages (THP) used for
  2157. metadata. See <link
  2158. linkend="stats.metadata"><mallctl>stats.metadata</mallctl></link> and
  2159. <link linkend="opt.metadata_thp">opt.metadata_thp</link>) for
  2160. details.</para></listitem>
  2161. </varlistentry>
  2162. <varlistentry id="stats.resident">
  2163. <term>
  2164. <mallctl>stats.resident</mallctl>
  2165. (<type>size_t</type>)
  2166. <literal>r-</literal>
  2167. [<option>--enable-stats</option>]
  2168. </term>
  2169. <listitem><para>Maximum number of bytes in physically resident data
  2170. pages mapped by the allocator, comprising all pages dedicated to
  2171. allocator metadata, pages backing active allocations, and unused dirty
  2172. pages. This is a maximum rather than precise because pages may not
  2173. actually be physically resident if they correspond to demand-zeroed
  2174. virtual memory that has not yet been touched. This is a multiple of the
  2175. page size, and is larger than <link
  2176. linkend="stats.active"><mallctl>stats.active</mallctl></link>.</para></listitem>
  2177. </varlistentry>
  2178. <varlistentry id="stats.mapped">
  2179. <term>
  2180. <mallctl>stats.mapped</mallctl>
  2181. (<type>size_t</type>)
  2182. <literal>r-</literal>
  2183. [<option>--enable-stats</option>]
  2184. </term>
  2185. <listitem><para>Total number of bytes in active extents mapped by the
  2186. allocator. This is larger than <link
  2187. linkend="stats.active"><mallctl>stats.active</mallctl></link>. This
  2188. does not include inactive extents, even those that contain unused dirty
  2189. pages, which means that there is no strict ordering between this and
  2190. <link
  2191. linkend="stats.resident"><mallctl>stats.resident</mallctl></link>.</para></listitem>
  2192. </varlistentry>
  2193. <varlistentry id="stats.retained">
  2194. <term>
  2195. <mallctl>stats.retained</mallctl>
  2196. (<type>size_t</type>)
  2197. <literal>r-</literal>
  2198. [<option>--enable-stats</option>]
  2199. </term>
  2200. <listitem><para>Total number of bytes in virtual memory mappings that
  2201. were retained rather than being returned to the operating system via
  2202. e.g. <citerefentry><refentrytitle>munmap</refentrytitle>
  2203. <manvolnum>2</manvolnum></citerefentry> or similar. Retained virtual
  2204. memory is typically untouched, decommitted, or purged, so it has no
  2205. strongly associated physical memory (see <link
  2206. linkend="arena.i.extent_hooks">extent hooks</link> for details).
  2207. Retained memory is excluded from mapped memory statistics, e.g. <link
  2208. linkend="stats.mapped"><mallctl>stats.mapped</mallctl></link>.
  2209. </para></listitem>
  2210. </varlistentry>
  2211. <varlistentry id="stats.background_thread.num_threads">
  2212. <term>
  2213. <mallctl>stats.background_thread.num_threads</mallctl>
  2214. (<type>size_t</type>)
  2215. <literal>r-</literal>
  2216. [<option>--enable-stats</option>]
  2217. </term>
  2218. <listitem><para> Number of <link linkend="background_thread">background
  2219. threads</link> running currently.</para></listitem>
  2220. </varlistentry>
  2221. <varlistentry id="stats.background_thread.num_runs">
  2222. <term>
  2223. <mallctl>stats.background_thread.num_runs</mallctl>
  2224. (<type>uint64_t</type>)
  2225. <literal>r-</literal>
  2226. [<option>--enable-stats</option>]
  2227. </term>
  2228. <listitem><para> Total number of runs from all <link
  2229. linkend="background_thread">background threads</link>.</para></listitem>
  2230. </varlistentry>
  2231. <varlistentry id="stats.background_thread.run_interval">
  2232. <term>
  2233. <mallctl>stats.background_thread.run_interval</mallctl>
  2234. (<type>uint64_t</type>)
  2235. <literal>r-</literal>
  2236. [<option>--enable-stats</option>]
  2237. </term>
  2238. <listitem><para> Average run interval in nanoseconds of <link
  2239. linkend="background_thread">background threads</link>.</para></listitem>
  2240. </varlistentry>
  2241. <varlistentry id="stats.mutexes.ctl">
  2242. <term>
  2243. <mallctl>stats.mutexes.ctl.{counter};</mallctl>
  2244. (<type>counter specific type</type>)
  2245. <literal>r-</literal>
  2246. [<option>--enable-stats</option>]
  2247. </term>
  2248. <listitem><para>Statistics on <varname>ctl</varname> mutex (global
  2249. scope; mallctl related). <mallctl>{counter}</mallctl> is one of the
  2250. counters below:</para>
  2251. <varlistentry id="mutex_counters">
  2252. <listitem><para><varname>num_ops</varname> (<type>uint64_t</type>):
  2253. Total number of lock acquisition operations on this mutex.</para>
  2254. <para><varname>num_spin_acq</varname> (<type>uint64_t</type>): Number
  2255. of times the mutex was spin-acquired. When the mutex is currently
  2256. locked and cannot be acquired immediately, a short period of
  2257. spin-retry within jemalloc will be performed. Acquired through spin
  2258. generally means the contention was lightweight and not causing context
  2259. switches.</para>
  2260. <para><varname>num_wait</varname> (<type>uint64_t</type>): Number of
  2261. times the mutex was wait-acquired, which means the mutex contention
  2262. was not solved by spin-retry, and blocking operation was likely
  2263. involved in order to acquire the mutex. This event generally implies
  2264. higher cost / longer delay, and should be investigated if it happens
  2265. often.</para>
  2266. <para><varname>max_wait_time</varname> (<type>uint64_t</type>):
  2267. Maximum length of time in nanoseconds spent on a single wait-acquired
  2268. lock operation. Note that to avoid profiling overhead on the common
  2269. path, this does not consider spin-acquired cases.</para>
  2270. <para><varname>total_wait_time</varname> (<type>uint64_t</type>):
  2271. Cumulative time in nanoseconds spent on wait-acquired lock operations.
  2272. Similarly, spin-acquired cases are not considered.</para>
  2273. <para><varname>max_num_thds</varname> (<type>uint32_t</type>): Maximum
  2274. number of threads waiting on this mutex simultaneously. Similarly,
  2275. spin-acquired cases are not considered.</para>
  2276. <para><varname>num_owner_switch</varname> (<type>uint64_t</type>):
  2277. Number of times the current mutex owner is different from the previous
  2278. one. This event does not generally imply an issue; rather it is an
  2279. indicator of how often the protected data are accessed by different
  2280. threads.
  2281. </para>
  2282. </listitem>
  2283. </varlistentry>
  2284. </listitem>
  2285. </varlistentry>
  2286. <varlistentry id="stats.mutexes.background_thread">
  2287. <term>
  2288. <mallctl>stats.mutexes.background_thread.{counter}</mallctl>
  2289. (<type>counter specific type</type>) <literal>r-</literal>
  2290. [<option>--enable-stats</option>]
  2291. </term>
  2292. <listitem><para>Statistics on <varname>background_thread</varname> mutex
  2293. (global scope; <link
  2294. linkend="background_thread"><mallctl>background_thread</mallctl></link>
  2295. related). <mallctl>{counter}</mallctl> is one of the counters in <link
  2296. linkend="mutex_counters">mutex profiling
  2297. counters</link>.</para></listitem>
  2298. </varlistentry>
  2299. <varlistentry id="stats.mutexes.prof">
  2300. <term>
  2301. <mallctl>stats.mutexes.prof.{counter}</mallctl>
  2302. (<type>counter specific type</type>) <literal>r-</literal>
  2303. [<option>--enable-stats</option>]
  2304. </term>
  2305. <listitem><para>Statistics on <varname>prof</varname> mutex (global
  2306. scope; profiling related). <mallctl>{counter}</mallctl> is one of the
  2307. counters in <link linkend="mutex_counters">mutex profiling
  2308. counters</link>.</para></listitem>
  2309. </varlistentry>
  2310. <varlistentry id="stats.mutexes.reset">
  2311. <term>
  2312. <mallctl>stats.mutexes.reset</mallctl>
  2313. (<type>void</type>) <literal>--</literal>
  2314. [<option>--enable-stats</option>]
  2315. </term>
  2316. <listitem><para>Reset all mutex profile statistics, including global
  2317. mutexes, arena mutexes and bin mutexes.</para></listitem>
  2318. </varlistentry>
  2319. <varlistentry id="stats.arenas.i.dss">
  2320. <term>
  2321. <mallctl>stats.arenas.&lt;i&gt;.dss</mallctl>
  2322. (<type>const char *</type>)
  2323. <literal>r-</literal>
  2324. </term>
  2325. <listitem><para>dss (<citerefentry><refentrytitle>sbrk</refentrytitle>
  2326. <manvolnum>2</manvolnum></citerefentry>) allocation precedence as
  2327. related to <citerefentry><refentrytitle>mmap</refentrytitle>
  2328. <manvolnum>2</manvolnum></citerefentry> allocation. See <link
  2329. linkend="opt.dss"><mallctl>opt.dss</mallctl></link> for details.
  2330. </para></listitem>
  2331. </varlistentry>
  2332. <varlistentry id="stats.arenas.i.dirty_decay_ms">
  2333. <term>
  2334. <mallctl>stats.arenas.&lt;i&gt;.dirty_decay_ms</mallctl>
  2335. (<type>ssize_t</type>)
  2336. <literal>r-</literal>
  2337. </term>
  2338. <listitem><para>Approximate time in milliseconds from the creation of a
  2339. set of unused dirty pages until an equivalent set of unused dirty pages
  2340. is purged and/or reused. See <link
  2341. linkend="opt.dirty_decay_ms"><mallctl>opt.dirty_decay_ms</mallctl></link>
  2342. for details.</para></listitem>
  2343. </varlistentry>
  2344. <varlistentry id="stats.arenas.i.muzzy_decay_ms">
  2345. <term>
  2346. <mallctl>stats.arenas.&lt;i&gt;.muzzy_decay_ms</mallctl>
  2347. (<type>ssize_t</type>)
  2348. <literal>r-</literal>
  2349. </term>
  2350. <listitem><para>Approximate time in milliseconds from the creation of a
  2351. set of unused muzzy pages until an equivalent set of unused muzzy pages
  2352. is purged and/or reused. See <link
  2353. linkend="opt.muzzy_decay_ms"><mallctl>opt.muzzy_decay_ms</mallctl></link>
  2354. for details.</para></listitem>
  2355. </varlistentry>
  2356. <varlistentry id="stats.arenas.i.nthreads">
  2357. <term>
  2358. <mallctl>stats.arenas.&lt;i&gt;.nthreads</mallctl>
  2359. (<type>unsigned</type>)
  2360. <literal>r-</literal>
  2361. </term>
  2362. <listitem><para>Number of threads currently assigned to
  2363. arena.</para></listitem>
  2364. </varlistentry>
  2365. <varlistentry id="stats.arenas.i.uptime">
  2366. <term>
  2367. <mallctl>stats.arenas.&lt;i&gt;.uptime</mallctl>
  2368. (<type>uint64_t</type>)
  2369. <literal>r-</literal>
  2370. </term>
  2371. <listitem><para>Time elapsed (in nanoseconds) since the arena was
  2372. created. If &lt;i&gt; equals <constant>0</constant> or
  2373. <constant>MALLCTL_ARENAS_ALL</constant>, this is the uptime since malloc
  2374. initialization.</para></listitem>
  2375. </varlistentry>
  2376. <varlistentry id="stats.arenas.i.pactive">
  2377. <term>
  2378. <mallctl>stats.arenas.&lt;i&gt;.pactive</mallctl>
  2379. (<type>size_t</type>)
  2380. <literal>r-</literal>
  2381. </term>
  2382. <listitem><para>Number of pages in active extents.</para></listitem>
  2383. </varlistentry>
  2384. <varlistentry id="stats.arenas.i.pdirty">
  2385. <term>
  2386. <mallctl>stats.arenas.&lt;i&gt;.pdirty</mallctl>
  2387. (<type>size_t</type>)
  2388. <literal>r-</literal>
  2389. </term>
  2390. <listitem><para>Number of pages within unused extents that are
  2391. potentially dirty, and for which <function>madvise()</function> or
  2392. similar has not been called. See <link
  2393. linkend="opt.dirty_decay_ms"><mallctl>opt.dirty_decay_ms</mallctl></link>
  2394. for a description of dirty pages.</para></listitem>
  2395. </varlistentry>
  2396. <varlistentry id="stats.arenas.i.pmuzzy">
  2397. <term>
  2398. <mallctl>stats.arenas.&lt;i&gt;.pmuzzy</mallctl>
  2399. (<type>size_t</type>)
  2400. <literal>r-</literal>
  2401. </term>
  2402. <listitem><para>Number of pages within unused extents that are muzzy.
  2403. See <link
  2404. linkend="opt.muzzy_decay_ms"><mallctl>opt.muzzy_decay_ms</mallctl></link>
  2405. for a description of muzzy pages.</para></listitem>
  2406. </varlistentry>
  2407. <varlistentry id="stats.arenas.i.mapped">
  2408. <term>
  2409. <mallctl>stats.arenas.&lt;i&gt;.mapped</mallctl>
  2410. (<type>size_t</type>)
  2411. <literal>r-</literal>
  2412. [<option>--enable-stats</option>]
  2413. </term>
  2414. <listitem><para>Number of mapped bytes.</para></listitem>
  2415. </varlistentry>
  2416. <varlistentry id="stats.arenas.i.retained">
  2417. <term>
  2418. <mallctl>stats.arenas.&lt;i&gt;.retained</mallctl>
  2419. (<type>size_t</type>)
  2420. <literal>r-</literal>
  2421. [<option>--enable-stats</option>]
  2422. </term>
  2423. <listitem><para>Number of retained bytes. See <link
  2424. linkend="stats.retained"><mallctl>stats.retained</mallctl></link> for
  2425. details.</para></listitem>
  2426. </varlistentry>
  2427. <varlistentry id="stats.arenas.i.base">
  2428. <term>
  2429. <mallctl>stats.arenas.&lt;i&gt;.base</mallctl>
  2430. (<type>size_t</type>)
  2431. <literal>r-</literal>
  2432. [<option>--enable-stats</option>]
  2433. </term>
  2434. <listitem><para>
  2435. Number of bytes dedicated to bootstrap-sensitive allocator metadata
  2436. structures.</para></listitem>
  2437. </varlistentry>
  2438. <varlistentry id="stats.arenas.i.internal">
  2439. <term>
  2440. <mallctl>stats.arenas.&lt;i&gt;.internal</mallctl>
  2441. (<type>size_t</type>)
  2442. <literal>r-</literal>
  2443. [<option>--enable-stats</option>]
  2444. </term>
  2445. <listitem><para>Number of bytes dedicated to internal allocations.
  2446. Internal allocations differ from application-originated allocations in
  2447. that they are for internal use, and that they are omitted from heap
  2448. profiles.</para></listitem>
  2449. </varlistentry>
  2450. <varlistentry id="stats.arenas.i.metadata_thp">
  2451. <term>
  2452. <mallctl>stats.arenas.&lt;i&gt;.metadata_thp</mallctl>
  2453. (<type>size_t</type>)
  2454. <literal>r-</literal>
  2455. [<option>--enable-stats</option>]
  2456. </term>
  2457. <listitem><para>Number of transparent huge pages (THP) used for
  2458. metadata. See <link linkend="opt.metadata_thp">opt.metadata_thp</link>
  2459. for details.</para></listitem>
  2460. </varlistentry>
  2461. <varlistentry id="stats.arenas.i.resident">
  2462. <term>
  2463. <mallctl>stats.arenas.&lt;i&gt;.resident</mallctl>
  2464. (<type>size_t</type>)
  2465. <literal>r-</literal>
  2466. [<option>--enable-stats</option>]
  2467. </term>
  2468. <listitem><para>Maximum number of bytes in physically resident data
  2469. pages mapped by the arena, comprising all pages dedicated to allocator
  2470. metadata, pages backing active allocations, and unused dirty pages.
  2471. This is a maximum rather than precise because pages may not actually be
  2472. physically resident if they correspond to demand-zeroed virtual memory
  2473. that has not yet been touched. This is a multiple of the page
  2474. size.</para></listitem>
  2475. </varlistentry>
  2476. <varlistentry id="stats.arenas.i.dirty_npurge">
  2477. <term>
  2478. <mallctl>stats.arenas.&lt;i&gt;.dirty_npurge</mallctl>
  2479. (<type>uint64_t</type>)
  2480. <literal>r-</literal>
  2481. [<option>--enable-stats</option>]
  2482. </term>
  2483. <listitem><para>Number of dirty page purge sweeps performed.
  2484. </para></listitem>
  2485. </varlistentry>
  2486. <varlistentry id="stats.arenas.i.dirty_nmadvise">
  2487. <term>
  2488. <mallctl>stats.arenas.&lt;i&gt;.dirty_nmadvise</mallctl>
  2489. (<type>uint64_t</type>)
  2490. <literal>r-</literal>
  2491. [<option>--enable-stats</option>]
  2492. </term>
  2493. <listitem><para>Number of <function>madvise()</function> or similar
  2494. calls made to purge dirty pages.</para></listitem>
  2495. </varlistentry>
  2496. <varlistentry id="stats.arenas.i.dirty_purged">
  2497. <term>
  2498. <mallctl>stats.arenas.&lt;i&gt;.dirty_purged</mallctl>
  2499. (<type>uint64_t</type>)
  2500. <literal>r-</literal>
  2501. [<option>--enable-stats</option>]
  2502. </term>
  2503. <listitem><para>Number of dirty pages purged.</para></listitem>
  2504. </varlistentry>
  2505. <varlistentry id="stats.arenas.i.muzzy_npurge">
  2506. <term>
  2507. <mallctl>stats.arenas.&lt;i&gt;.muzzy_npurge</mallctl>
  2508. (<type>uint64_t</type>)
  2509. <literal>r-</literal>
  2510. [<option>--enable-stats</option>]
  2511. </term>
  2512. <listitem><para>Number of muzzy page purge sweeps performed.
  2513. </para></listitem>
  2514. </varlistentry>
  2515. <varlistentry id="stats.arenas.i.muzzy_nmadvise">
  2516. <term>
  2517. <mallctl>stats.arenas.&lt;i&gt;.muzzy_nmadvise</mallctl>
  2518. (<type>uint64_t</type>)
  2519. <literal>r-</literal>
  2520. [<option>--enable-stats</option>]
  2521. </term>
  2522. <listitem><para>Number of <function>madvise()</function> or similar
  2523. calls made to purge muzzy pages.</para></listitem>
  2524. </varlistentry>
  2525. <varlistentry id="stats.arenas.i.muzzy_purged">
  2526. <term>
  2527. <mallctl>stats.arenas.&lt;i&gt;.muzzy_purged</mallctl>
  2528. (<type>uint64_t</type>)
  2529. <literal>r-</literal>
  2530. [<option>--enable-stats</option>]
  2531. </term>
  2532. <listitem><para>Number of muzzy pages purged.</para></listitem>
  2533. </varlistentry>
  2534. <varlistentry id="stats.arenas.i.small.allocated">
  2535. <term>
  2536. <mallctl>stats.arenas.&lt;i&gt;.small.allocated</mallctl>
  2537. (<type>size_t</type>)
  2538. <literal>r-</literal>
  2539. [<option>--enable-stats</option>]
  2540. </term>
  2541. <listitem><para>Number of bytes currently allocated by small objects.
  2542. </para></listitem>
  2543. </varlistentry>
  2544. <varlistentry id="stats.arenas.i.small.nmalloc">
  2545. <term>
  2546. <mallctl>stats.arenas.&lt;i&gt;.small.nmalloc</mallctl>
  2547. (<type>uint64_t</type>)
  2548. <literal>r-</literal>
  2549. [<option>--enable-stats</option>]
  2550. </term>
  2551. <listitem><para>Cumulative number of times a small allocation was
  2552. requested from the arena's bins, whether to fill the relevant tcache if
  2553. <link linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is
  2554. enabled, or to directly satisfy an allocation request
  2555. otherwise.</para></listitem>
  2556. </varlistentry>
  2557. <varlistentry id="stats.arenas.i.small.ndalloc">
  2558. <term>
  2559. <mallctl>stats.arenas.&lt;i&gt;.small.ndalloc</mallctl>
  2560. (<type>uint64_t</type>)
  2561. <literal>r-</literal>
  2562. [<option>--enable-stats</option>]
  2563. </term>
  2564. <listitem><para>Cumulative number of times a small allocation was
  2565. returned to the arena's bins, whether to flush the relevant tcache if
  2566. <link linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is
  2567. enabled, or to directly deallocate an allocation
  2568. otherwise.</para></listitem>
  2569. </varlistentry>
  2570. <varlistentry id="stats.arenas.i.small.nrequests">
  2571. <term>
  2572. <mallctl>stats.arenas.&lt;i&gt;.small.nrequests</mallctl>
  2573. (<type>uint64_t</type>)
  2574. <literal>r-</literal>
  2575. [<option>--enable-stats</option>]
  2576. </term>
  2577. <listitem><para>Cumulative number of allocation requests satisfied by
  2578. all bin size classes.</para></listitem>
  2579. </varlistentry>
  2580. <varlistentry id="stats.arenas.i.large.allocated">
  2581. <term>
  2582. <mallctl>stats.arenas.&lt;i&gt;.large.allocated</mallctl>
  2583. (<type>size_t</type>)
  2584. <literal>r-</literal>
  2585. [<option>--enable-stats</option>]
  2586. </term>
  2587. <listitem><para>Number of bytes currently allocated by large objects.
  2588. </para></listitem>
  2589. </varlistentry>
  2590. <varlistentry id="stats.arenas.i.large.nmalloc">
  2591. <term>
  2592. <mallctl>stats.arenas.&lt;i&gt;.large.nmalloc</mallctl>
  2593. (<type>uint64_t</type>)
  2594. <literal>r-</literal>
  2595. [<option>--enable-stats</option>]
  2596. </term>
  2597. <listitem><para>Cumulative number of times a large extent was allocated
  2598. from the arena, whether to fill the relevant tcache if <link
  2599. linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is enabled and
  2600. the size class is within the range being cached, or to directly satisfy
  2601. an allocation request otherwise.</para></listitem>
  2602. </varlistentry>
  2603. <varlistentry id="stats.arenas.i.large.ndalloc">
  2604. <term>
  2605. <mallctl>stats.arenas.&lt;i&gt;.large.ndalloc</mallctl>
  2606. (<type>uint64_t</type>)
  2607. <literal>r-</literal>
  2608. [<option>--enable-stats</option>]
  2609. </term>
  2610. <listitem><para>Cumulative number of times a large extent was returned
  2611. to the arena, whether to flush the relevant tcache if <link
  2612. linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is enabled and
  2613. the size class is within the range being cached, or to directly
  2614. deallocate an allocation otherwise.</para></listitem>
  2615. </varlistentry>
  2616. <varlistentry id="stats.arenas.i.large.nrequests">
  2617. <term>
  2618. <mallctl>stats.arenas.&lt;i&gt;.large.nrequests</mallctl>
  2619. (<type>uint64_t</type>)
  2620. <literal>r-</literal>
  2621. [<option>--enable-stats</option>]
  2622. </term>
  2623. <listitem><para>Cumulative number of allocation requests satisfied by
  2624. all large size classes.</para></listitem>
  2625. </varlistentry>
  2626. <varlistentry id="stats.arenas.i.bins.j.nmalloc">
  2627. <term>
  2628. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nmalloc</mallctl>
  2629. (<type>uint64_t</type>)
  2630. <literal>r-</literal>
  2631. [<option>--enable-stats</option>]
  2632. </term>
  2633. <listitem><para>Cumulative number of times a bin region of the
  2634. corresponding size class was allocated from the arena, whether to fill
  2635. the relevant tcache if <link
  2636. linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is enabled, or
  2637. to directly satisfy an allocation request otherwise.</para></listitem>
  2638. </varlistentry>
  2639. <varlistentry id="stats.arenas.i.bins.j.ndalloc">
  2640. <term>
  2641. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.ndalloc</mallctl>
  2642. (<type>uint64_t</type>)
  2643. <literal>r-</literal>
  2644. [<option>--enable-stats</option>]
  2645. </term>
  2646. <listitem><para>Cumulative number of times a bin region of the
  2647. corresponding size class was returned to the arena, whether to flush the
  2648. relevant tcache if <link
  2649. linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is enabled, or
  2650. to directly deallocate an allocation otherwise.</para></listitem>
  2651. </varlistentry>
  2652. <varlistentry id="stats.arenas.i.bins.j.nrequests">
  2653. <term>
  2654. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nrequests</mallctl>
  2655. (<type>uint64_t</type>)
  2656. <literal>r-</literal>
  2657. [<option>--enable-stats</option>]
  2658. </term>
  2659. <listitem><para>Cumulative number of allocation requests satisfied by
  2660. bin regions of the corresponding size class.</para></listitem>
  2661. </varlistentry>
  2662. <varlistentry id="stats.arenas.i.bins.j.curregs">
  2663. <term>
  2664. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.curregs</mallctl>
  2665. (<type>size_t</type>)
  2666. <literal>r-</literal>
  2667. [<option>--enable-stats</option>]
  2668. </term>
  2669. <listitem><para>Current number of regions for this size
  2670. class.</para></listitem>
  2671. </varlistentry>
  2672. <varlistentry id="stats.arenas.i.bins.j.nfills">
  2673. <term>
  2674. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nfills</mallctl>
  2675. (<type>uint64_t</type>)
  2676. <literal>r-</literal>
  2677. </term>
  2678. <listitem><para>Cumulative number of tcache fills.</para></listitem>
  2679. </varlistentry>
  2680. <varlistentry id="stats.arenas.i.bins.j.nflushes">
  2681. <term>
  2682. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nflushes</mallctl>
  2683. (<type>uint64_t</type>)
  2684. <literal>r-</literal>
  2685. </term>
  2686. <listitem><para>Cumulative number of tcache flushes.</para></listitem>
  2687. </varlistentry>
  2688. <varlistentry id="stats.arenas.i.bins.j.nslabs">
  2689. <term>
  2690. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nslabs</mallctl>
  2691. (<type>uint64_t</type>)
  2692. <literal>r-</literal>
  2693. [<option>--enable-stats</option>]
  2694. </term>
  2695. <listitem><para>Cumulative number of slabs created.</para></listitem>
  2696. </varlistentry>
  2697. <varlistentry id="stats.arenas.i.bins.j.nreslabs">
  2698. <term>
  2699. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.nreslabs</mallctl>
  2700. (<type>uint64_t</type>)
  2701. <literal>r-</literal>
  2702. [<option>--enable-stats</option>]
  2703. </term>
  2704. <listitem><para>Cumulative number of times the current slab from which
  2705. to allocate changed.</para></listitem>
  2706. </varlistentry>
  2707. <varlistentry id="stats.arenas.i.bins.j.curslabs">
  2708. <term>
  2709. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.curslabs</mallctl>
  2710. (<type>size_t</type>)
  2711. <literal>r-</literal>
  2712. [<option>--enable-stats</option>]
  2713. </term>
  2714. <listitem><para>Current number of slabs.</para></listitem>
  2715. </varlistentry>
  2716. <varlistentry id="stats.arenas.i.bins.mutex">
  2717. <term>
  2718. <mallctl>stats.arenas.&lt;i&gt;.bins.&lt;j&gt;.mutex.{counter}</mallctl>
  2719. (<type>counter specific type</type>) <literal>r-</literal>
  2720. [<option>--enable-stats</option>]
  2721. </term>
  2722. <listitem><para>Statistics on
  2723. <varname>arena.&lt;i&gt;.bins.&lt;j&gt;</varname> mutex (arena bin
  2724. scope; bin operation related). <mallctl>{counter}</mallctl> is one of
  2725. the counters in <link linkend="mutex_counters">mutex profiling
  2726. counters</link>.</para></listitem>
  2727. </varlistentry>
  2728. <varlistentry id="stats.arenas.i.lextents.j.nmalloc">
  2729. <term>
  2730. <mallctl>stats.arenas.&lt;i&gt;.lextents.&lt;j&gt;.nmalloc</mallctl>
  2731. (<type>uint64_t</type>)
  2732. <literal>r-</literal>
  2733. [<option>--enable-stats</option>]
  2734. </term>
  2735. <listitem><para>Cumulative number of times a large extent of the
  2736. corresponding size class was allocated from the arena, whether to fill
  2737. the relevant tcache if <link
  2738. linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is enabled and
  2739. the size class is within the range being cached, or to directly satisfy
  2740. an allocation request otherwise.</para></listitem>
  2741. </varlistentry>
  2742. <varlistentry id="stats.arenas.i.lextents.j.ndalloc">
  2743. <term>
  2744. <mallctl>stats.arenas.&lt;i&gt;.lextents.&lt;j&gt;.ndalloc</mallctl>
  2745. (<type>uint64_t</type>)
  2746. <literal>r-</literal>
  2747. [<option>--enable-stats</option>]
  2748. </term>
  2749. <listitem><para>Cumulative number of times a large extent of the
  2750. corresponding size class was returned to the arena, whether to flush the
  2751. relevant tcache if <link
  2752. linkend="opt.tcache"><mallctl>opt.tcache</mallctl></link> is enabled and
  2753. the size class is within the range being cached, or to directly
  2754. deallocate an allocation otherwise.</para></listitem>
  2755. </varlistentry>
  2756. <varlistentry id="stats.arenas.i.lextents.j.nrequests">
  2757. <term>
  2758. <mallctl>stats.arenas.&lt;i&gt;.lextents.&lt;j&gt;.nrequests</mallctl>
  2759. (<type>uint64_t</type>)
  2760. <literal>r-</literal>
  2761. [<option>--enable-stats</option>]
  2762. </term>
  2763. <listitem><para>Cumulative number of allocation requests satisfied by
  2764. large extents of the corresponding size class.</para></listitem>
  2765. </varlistentry>
  2766. <varlistentry id="stats.arenas.i.lextents.j.curlextents">
  2767. <term>
  2768. <mallctl>stats.arenas.&lt;i&gt;.lextents.&lt;j&gt;.curlextents</mallctl>
  2769. (<type>size_t</type>)
  2770. <literal>r-</literal>
  2771. [<option>--enable-stats</option>]
  2772. </term>
  2773. <listitem><para>Current number of large allocations for this size class.
  2774. </para></listitem>
  2775. </varlistentry>
  2776. <varlistentry id="stats.arenas.i.mutexes.large">
  2777. <term>
  2778. <mallctl>stats.arenas.&lt;i&gt;.mutexes.large.{counter}</mallctl>
  2779. (<type>counter specific type</type>) <literal>r-</literal>
  2780. [<option>--enable-stats</option>]
  2781. </term>
  2782. <listitem><para>Statistics on <varname>arena.&lt;i&gt;.large</varname>
  2783. mutex (arena scope; large allocation related).
  2784. <mallctl>{counter}</mallctl> is one of the counters in <link
  2785. linkend="mutex_counters">mutex profiling
  2786. counters</link>.</para></listitem>
  2787. </varlistentry>
  2788. <varlistentry id="stats.arenas.i.mutexes.extent_avail">
  2789. <term>
  2790. <mallctl>stats.arenas.&lt;i&gt;.mutexes.extent_avail.{counter}</mallctl>
  2791. (<type>counter specific type</type>) <literal>r-</literal>
  2792. [<option>--enable-stats</option>]
  2793. </term>
  2794. <listitem><para>Statistics on <varname>arena.&lt;i&gt;.extent_avail
  2795. </varname> mutex (arena scope; extent avail related).
  2796. <mallctl>{counter}</mallctl> is one of the counters in <link
  2797. linkend="mutex_counters">mutex profiling
  2798. counters</link>.</para></listitem>
  2799. </varlistentry>
  2800. <varlistentry id="stats.arenas.i.mutexes.extents_dirty">
  2801. <term>
  2802. <mallctl>stats.arenas.&lt;i&gt;.mutexes.extents_dirty.{counter}</mallctl>
  2803. (<type>counter specific type</type>) <literal>r-</literal>
  2804. [<option>--enable-stats</option>]
  2805. </term>
  2806. <listitem><para>Statistics on <varname>arena.&lt;i&gt;.extents_dirty
  2807. </varname> mutex (arena scope; dirty extents related).
  2808. <mallctl>{counter}</mallctl> is one of the counters in <link
  2809. linkend="mutex_counters">mutex profiling
  2810. counters</link>.</para></listitem>
  2811. </varlistentry>
  2812. <varlistentry id="stats.arenas.i.mutexes.extents_muzzy">
  2813. <term>
  2814. <mallctl>stats.arenas.&lt;i&gt;.mutexes.extents_muzzy.{counter}</mallctl>
  2815. (<type>counter specific type</type>) <literal>r-</literal>
  2816. [<option>--enable-stats</option>]
  2817. </term>
  2818. <listitem><para>Statistics on <varname>arena.&lt;i&gt;.extents_muzzy
  2819. </varname> mutex (arena scope; muzzy extents related).
  2820. <mallctl>{counter}</mallctl> is one of the counters in <link
  2821. linkend="mutex_counters">mutex profiling
  2822. counters</link>.</para></listitem>
  2823. </varlistentry>
  2824. <varlistentry id="stats.arenas.i.mutexes.extents_retained">
  2825. <term>
  2826. <mallctl>stats.arenas.&lt;i&gt;.mutexes.extents_retained.{counter}</mallctl>
  2827. (<type>counter specific type</type>) <literal>r-</literal>
  2828. [<option>--enable-stats</option>]
  2829. </term>
  2830. <listitem><para>Statistics on <varname>arena.&lt;i&gt;.extents_retained
  2831. </varname> mutex (arena scope; retained extents related).
  2832. <mallctl>{counter}</mallctl> is one of the counters in <link
  2833. linkend="mutex_counters">mutex profiling
  2834. counters</link>.</para></listitem>
  2835. </varlistentry>
  2836. <varlistentry id="stats.arenas.i.mutexes.decay_dirty">
  2837. <term>
  2838. <mallctl>stats.arenas.&lt;i&gt;.mutexes.decay_dirty.{counter}</mallctl>
  2839. (<type>counter specific type</type>) <literal>r-</literal>
  2840. [<option>--enable-stats</option>]
  2841. </term>
  2842. <listitem><para>Statistics on <varname>arena.&lt;i&gt;.decay_dirty
  2843. </varname> mutex (arena scope; decay for dirty pages related).
  2844. <mallctl>{counter}</mallctl> is one of the counters in <link
  2845. linkend="mutex_counters">mutex profiling
  2846. counters</link>.</para></listitem>
  2847. </varlistentry>
  2848. <varlistentry id="stats.arenas.i.mutexes.decay_muzzy">
  2849. <term>
  2850. <mallctl>stats.arenas.&lt;i&gt;.mutexes.decay_muzzy.{counter}</mallctl>
  2851. (<type>counter specific type</type>) <literal>r-</literal>
  2852. [<option>--enable-stats</option>]
  2853. </term>
  2854. <listitem><para>Statistics on <varname>arena.&lt;i&gt;.decay_muzzy
  2855. </varname> mutex (arena scope; decay for muzzy pages related).
  2856. <mallctl>{counter}</mallctl> is one of the counters in <link
  2857. linkend="mutex_counters">mutex profiling
  2858. counters</link>.</para></listitem>
  2859. </varlistentry>
  2860. <varlistentry id="stats.arenas.i.mutexes.base">
  2861. <term>
  2862. <mallctl>stats.arenas.&lt;i&gt;.mutexes.base.{counter}</mallctl>
  2863. (<type>counter specific type</type>) <literal>r-</literal>
  2864. [<option>--enable-stats</option>]
  2865. </term>
  2866. <listitem><para>Statistics on <varname>arena.&lt;i&gt;.base</varname>
  2867. mutex (arena scope; base allocator related).
  2868. <mallctl>{counter}</mallctl> is one of the counters in <link
  2869. linkend="mutex_counters">mutex profiling
  2870. counters</link>.</para></listitem>
  2871. </varlistentry>
  2872. <varlistentry id="stats.arenas.i.mutexes.tcache_list">
  2873. <term>
  2874. <mallctl>stats.arenas.&lt;i&gt;.mutexes.tcache_list.{counter}</mallctl>
  2875. (<type>counter specific type</type>) <literal>r-</literal>
  2876. [<option>--enable-stats</option>]
  2877. </term>
  2878. <listitem><para>Statistics on
  2879. <varname>arena.&lt;i&gt;.tcache_list</varname> mutex (arena scope;
  2880. tcache to arena association related). This mutex is expected to be
  2881. accessed less often. <mallctl>{counter}</mallctl> is one of the
  2882. counters in <link linkend="mutex_counters">mutex profiling
  2883. counters</link>.</para></listitem>
  2884. </varlistentry>
  2885. </variablelist>
  2886. </refsect1>
  2887. <refsect1 id="heap_profile_format">
  2888. <title>HEAP PROFILE FORMAT</title>
  2889. <para>Although the heap profiling functionality was originally designed to
  2890. be compatible with the
  2891. <command>pprof</command> command that is developed as part of the <ulink
  2892. url="http://code.google.com/p/gperftools/">gperftools
  2893. package</ulink>, the addition of per thread heap profiling functionality
  2894. required a different heap profile format. The <command>jeprof</command>
  2895. command is derived from <command>pprof</command>, with enhancements to
  2896. support the heap profile format described here.</para>
  2897. <para>In the following hypothetical heap profile, <constant>[...]</constant>
  2898. indicates elision for the sake of compactness. <programlisting><![CDATA[
  2899. heap_v2/524288
  2900. t*: 28106: 56637512 [0: 0]
  2901. [...]
  2902. t3: 352: 16777344 [0: 0]
  2903. [...]
  2904. t99: 17754: 29341640 [0: 0]
  2905. [...]
  2906. @ 0x5f86da8 0x5f5a1dc [...] 0x29e4d4e 0xa200316 0xabb2988 [...]
  2907. t*: 13: 6688 [0: 0]
  2908. t3: 12: 6496 [0: ]
  2909. t99: 1: 192 [0: 0]
  2910. [...]
  2911. MAPPED_LIBRARIES:
  2912. [...]]]></programlisting> The following matches the above heap profile, but most
  2913. tokens are replaced with <constant>&lt;description&gt;</constant> to indicate
  2914. descriptions of the corresponding fields. <programlisting><![CDATA[
  2915. <heap_profile_format_version>/<mean_sample_interval>
  2916. <aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
  2917. [...]
  2918. <thread_3_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>]
  2919. [...]
  2920. <thread_99_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>]
  2921. [...]
  2922. @ <top_frame> <frame> [...] <frame> <frame> <frame> [...]
  2923. <backtrace_aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
  2924. <backtrace_thread_3>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
  2925. <backtrace_thread_99>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
  2926. [...]
  2927. MAPPED_LIBRARIES:
  2928. </proc/<pid>/maps>]]></programlisting></para>
  2929. </refsect1>
  2930. <refsect1 id="debugging_malloc_problems">
  2931. <title>DEBUGGING MALLOC PROBLEMS</title>
  2932. <para>When debugging, it is a good idea to configure/build jemalloc with
  2933. the <option>--enable-debug</option> and <option>--enable-fill</option>
  2934. options, and recompile the program with suitable options and symbols for
  2935. debugger support. When so configured, jemalloc incorporates a wide variety
  2936. of run-time assertions that catch application errors such as double-free,
  2937. write-after-free, etc.</para>
  2938. <para>Programs often accidentally depend on <quote>uninitialized</quote>
  2939. memory actually being filled with zero bytes. Junk filling
  2940. (see the <link linkend="opt.junk"><mallctl>opt.junk</mallctl></link>
  2941. option) tends to expose such bugs in the form of obviously incorrect
  2942. results and/or coredumps. Conversely, zero
  2943. filling (see the <link
  2944. linkend="opt.zero"><mallctl>opt.zero</mallctl></link> option) eliminates
  2945. the symptoms of such bugs. Between these two options, it is usually
  2946. possible to quickly detect, diagnose, and eliminate such bugs.</para>
  2947. <para>This implementation does not provide much detail about the problems
  2948. it detects, because the performance impact for storing such information
  2949. would be prohibitive.</para>
  2950. </refsect1>
  2951. <refsect1 id="diagnostic_messages">
  2952. <title>DIAGNOSTIC MESSAGES</title>
  2953. <para>If any of the memory allocation/deallocation functions detect an
  2954. error or warning condition, a message will be printed to file descriptor
  2955. <constant>STDERR_FILENO</constant>. Errors will result in the process
  2956. dumping core. If the <link
  2957. linkend="opt.abort"><mallctl>opt.abort</mallctl></link> option is set, most
  2958. warnings are treated as errors.</para>
  2959. <para>The <varname>malloc_message</varname> variable allows the programmer
  2960. to override the function which emits the text strings forming the errors
  2961. and warnings if for some reason the <constant>STDERR_FILENO</constant> file
  2962. descriptor is not suitable for this.
  2963. <function>malloc_message()</function> takes the
  2964. <parameter>cbopaque</parameter> pointer argument that is
  2965. <constant>NULL</constant> unless overridden by the arguments in a call to
  2966. <function>malloc_stats_print()</function>, followed by a string
  2967. pointer. Please note that doing anything which tries to allocate memory in
  2968. this function is likely to result in a crash or deadlock.</para>
  2969. <para>All messages are prefixed by
  2970. <quote><computeroutput>&lt;jemalloc&gt;: </computeroutput></quote>.</para>
  2971. </refsect1>
  2972. <refsect1 id="return_values">
  2973. <title>RETURN VALUES</title>
  2974. <refsect2>
  2975. <title>Standard API</title>
  2976. <para>The <function>malloc()</function> and
  2977. <function>calloc()</function> functions return a pointer to the
  2978. allocated memory if successful; otherwise a <constant>NULL</constant>
  2979. pointer is returned and <varname>errno</varname> is set to
  2980. <errorname>ENOMEM</errorname>.</para>
  2981. <para>The <function>posix_memalign()</function> function
  2982. returns the value 0 if successful; otherwise it returns an error value.
  2983. The <function>posix_memalign()</function> function will fail
  2984. if:
  2985. <variablelist>
  2986. <varlistentry>
  2987. <term><errorname>EINVAL</errorname></term>
  2988. <listitem><para>The <parameter>alignment</parameter> parameter is
  2989. not a power of 2 at least as large as
  2990. <code language="C">sizeof(<type>void *</type>)</code>.
  2991. </para></listitem>
  2992. </varlistentry>
  2993. <varlistentry>
  2994. <term><errorname>ENOMEM</errorname></term>
  2995. <listitem><para>Memory allocation error.</para></listitem>
  2996. </varlistentry>
  2997. </variablelist>
  2998. </para>
  2999. <para>The <function>aligned_alloc()</function> function returns
  3000. a pointer to the allocated memory if successful; otherwise a
  3001. <constant>NULL</constant> pointer is returned and
  3002. <varname>errno</varname> is set. The
  3003. <function>aligned_alloc()</function> function will fail if:
  3004. <variablelist>
  3005. <varlistentry>
  3006. <term><errorname>EINVAL</errorname></term>
  3007. <listitem><para>The <parameter>alignment</parameter> parameter is
  3008. not a power of 2.
  3009. </para></listitem>
  3010. </varlistentry>
  3011. <varlistentry>
  3012. <term><errorname>ENOMEM</errorname></term>
  3013. <listitem><para>Memory allocation error.</para></listitem>
  3014. </varlistentry>
  3015. </variablelist>
  3016. </para>
  3017. <para>The <function>realloc()</function> function returns a
  3018. pointer, possibly identical to <parameter>ptr</parameter>, to the
  3019. allocated memory if successful; otherwise a <constant>NULL</constant>
  3020. pointer is returned, and <varname>errno</varname> is set to
  3021. <errorname>ENOMEM</errorname> if the error was the result of an
  3022. allocation failure. The <function>realloc()</function>
  3023. function always leaves the original buffer intact when an error occurs.
  3024. </para>
  3025. <para>The <function>free()</function> function returns no
  3026. value.</para>
  3027. </refsect2>
  3028. <refsect2>
  3029. <title>Non-standard API</title>
  3030. <para>The <function>mallocx()</function> and
  3031. <function>rallocx()</function> functions return a pointer to
  3032. the allocated memory if successful; otherwise a <constant>NULL</constant>
  3033. pointer is returned to indicate insufficient contiguous memory was
  3034. available to service the allocation request. </para>
  3035. <para>The <function>xallocx()</function> function returns the
  3036. real size of the resulting resized allocation pointed to by
  3037. <parameter>ptr</parameter>, which is a value less than
  3038. <parameter>size</parameter> if the allocation could not be adequately
  3039. grown in place. </para>
  3040. <para>The <function>sallocx()</function> function returns the
  3041. real size of the allocation pointed to by <parameter>ptr</parameter>.
  3042. </para>
  3043. <para>The <function>nallocx()</function> returns the real size
  3044. that would result from a successful equivalent
  3045. <function>mallocx()</function> function call, or zero if
  3046. insufficient memory is available to perform the size computation. </para>
  3047. <para>The <function>mallctl()</function>,
  3048. <function>mallctlnametomib()</function>, and
  3049. <function>mallctlbymib()</function> functions return 0 on
  3050. success; otherwise they return an error value. The functions will fail
  3051. if:
  3052. <variablelist>
  3053. <varlistentry>
  3054. <term><errorname>EINVAL</errorname></term>
  3055. <listitem><para><parameter>newp</parameter> is not
  3056. <constant>NULL</constant>, and <parameter>newlen</parameter> is too
  3057. large or too small. Alternatively, <parameter>*oldlenp</parameter>
  3058. is too large or too small; in this case as much data as possible
  3059. are read despite the error.</para></listitem>
  3060. </varlistentry>
  3061. <varlistentry>
  3062. <term><errorname>ENOENT</errorname></term>
  3063. <listitem><para><parameter>name</parameter> or
  3064. <parameter>mib</parameter> specifies an unknown/invalid
  3065. value.</para></listitem>
  3066. </varlistentry>
  3067. <varlistentry>
  3068. <term><errorname>EPERM</errorname></term>
  3069. <listitem><para>Attempt to read or write void value, or attempt to
  3070. write read-only value.</para></listitem>
  3071. </varlistentry>
  3072. <varlistentry>
  3073. <term><errorname>EAGAIN</errorname></term>
  3074. <listitem><para>A memory allocation failure
  3075. occurred.</para></listitem>
  3076. </varlistentry>
  3077. <varlistentry>
  3078. <term><errorname>EFAULT</errorname></term>
  3079. <listitem><para>An interface with side effects failed in some way
  3080. not directly related to <function>mallctl*()</function>
  3081. read/write processing.</para></listitem>
  3082. </varlistentry>
  3083. </variablelist>
  3084. </para>
  3085. <para>The <function>malloc_usable_size()</function> function
  3086. returns the usable size of the allocation pointed to by
  3087. <parameter>ptr</parameter>. </para>
  3088. </refsect2>
  3089. </refsect1>
  3090. <refsect1 id="environment">
  3091. <title>ENVIRONMENT</title>
  3092. <para>The following environment variable affects the execution of the
  3093. allocation functions:
  3094. <variablelist>
  3095. <varlistentry>
  3096. <term><envar>MALLOC_CONF</envar></term>
  3097. <listitem><para>If the environment variable
  3098. <envar>MALLOC_CONF</envar> is set, the characters it contains
  3099. will be interpreted as options.</para></listitem>
  3100. </varlistentry>
  3101. </variablelist>
  3102. </para>
  3103. </refsect1>
  3104. <refsect1 id="examples">
  3105. <title>EXAMPLES</title>
  3106. <para>To dump core whenever a problem occurs:
  3107. <screen>ln -s 'abort:true' /etc/malloc.conf</screen>
  3108. </para>
  3109. <para>To specify in the source that only one arena should be automatically
  3110. created:
  3111. <programlisting language="C"><![CDATA[
  3112. malloc_conf = "narenas:1";]]></programlisting></para>
  3113. </refsect1>
  3114. <refsect1 id="see_also">
  3115. <title>SEE ALSO</title>
  3116. <para><citerefentry><refentrytitle>madvise</refentrytitle>
  3117. <manvolnum>2</manvolnum></citerefentry>,
  3118. <citerefentry><refentrytitle>mmap</refentrytitle>
  3119. <manvolnum>2</manvolnum></citerefentry>,
  3120. <citerefentry><refentrytitle>sbrk</refentrytitle>
  3121. <manvolnum>2</manvolnum></citerefentry>,
  3122. <citerefentry><refentrytitle>utrace</refentrytitle>
  3123. <manvolnum>2</manvolnum></citerefentry>,
  3124. <citerefentry><refentrytitle>alloca</refentrytitle>
  3125. <manvolnum>3</manvolnum></citerefentry>,
  3126. <citerefentry><refentrytitle>atexit</refentrytitle>
  3127. <manvolnum>3</manvolnum></citerefentry>,
  3128. <citerefentry><refentrytitle>getpagesize</refentrytitle>
  3129. <manvolnum>3</manvolnum></citerefentry></para>
  3130. </refsect1>
  3131. <refsect1 id="standards">
  3132. <title>STANDARDS</title>
  3133. <para>The <function>malloc()</function>,
  3134. <function>calloc()</function>,
  3135. <function>realloc()</function>, and
  3136. <function>free()</function> functions conform to ISO/IEC
  3137. 9899:1990 (<quote>ISO C90</quote>).</para>
  3138. <para>The <function>posix_memalign()</function> function conforms
  3139. to IEEE Std 1003.1-2001 (<quote>POSIX.1</quote>).</para>
  3140. </refsect1>
  3141. </refentry>