jemalloc.xml.in 169 KB

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