2
0

jemalloc.3 66 KB

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