]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/jemalloc/doc/jemalloc.3
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / jemalloc / doc / jemalloc.3
1 '\" t
2 .\"     Title: JEMALLOC
3 .\"    Author: Jason Evans
4 .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
5 .\"      Date: 11/10/2019
6 .\"    Manual: User Manual
7 .\"    Source: jemalloc 5.2.1-0-gea6b3e973b477b8061e0076bb257dbd7f3faa756
8 .\"  Language: English
9 .\"
10 .TH "JEMALLOC" "3" "11/10/2019" "jemalloc 5.2.1-0-gea6b3e973b47" "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 5\&.2\&.1\-0\-gea6b3e973b477b8061e0076bb257dbd7f3faa756\&. More information can be found at the
35 \m[blue]\fBjemalloc website\fR\m[]\&\s-2\u[1]\d\s+2\&.
36 .PP
37 The following configuration options are enabled in libc\*(Aqs built\-in jemalloc:
38 \fB\-\-enable\-fill\fR,
39 \fB\-\-enable\-lazy\-lock\fR,
40 \fB\-\-enable\-stats\fR,
41 \fB\-\-enable\-utrace\fR,
42 \fB\-\-enable\-xmalloc\fR, and
43 \fB\-\-with\-malloc\-conf=abort_conf:false\fR\&. Additionally,
44 \fB\-\-enable\-debug\fR
45 is enabled in development versions of FreeBSD (controlled by the
46 \fBMALLOC_PRODUCTION\fR
47 make variable)\&.
48 .SH "SYNOPSIS"
49 .sp
50 .ft B
51 .nf
52 #include <stdlib\&.h>
53 #include <malloc_np\&.h>
54 .fi
55 .ft
56 .SS "Standard API"
57 .HP \w'void\ *malloc('u
58 .BI "void *malloc(size_t\ " "size" ");"
59 .HP \w'void\ *calloc('u
60 .BI "void *calloc(size_t\ " "number" ", size_t\ " "size" ");"
61 .HP \w'int\ posix_memalign('u
62 .BI "int posix_memalign(void\ **" "ptr" ", size_t\ " "alignment" ", size_t\ " "size" ");"
63 .HP \w'void\ *aligned_alloc('u
64 .BI "void *aligned_alloc(size_t\ " "alignment" ", size_t\ " "size" ");"
65 .HP \w'void\ *realloc('u
66 .BI "void *realloc(void\ *" "ptr" ", size_t\ " "size" ");"
67 .HP \w'void\ free('u
68 .BI "void free(void\ *" "ptr" ");"
69 .SS "Non\-standard API"
70 .HP \w'void\ *mallocx('u
71 .BI "void *mallocx(size_t\ " "size" ", int\ " "flags" ");"
72 .HP \w'void\ *rallocx('u
73 .BI "void *rallocx(void\ *" "ptr" ", size_t\ " "size" ", int\ " "flags" ");"
74 .HP \w'size_t\ xallocx('u
75 .BI "size_t xallocx(void\ *" "ptr" ", size_t\ " "size" ", size_t\ " "extra" ", int\ " "flags" ");"
76 .HP \w'size_t\ sallocx('u
77 .BI "size_t sallocx(void\ *" "ptr" ", int\ " "flags" ");"
78 .HP \w'void\ dallocx('u
79 .BI "void dallocx(void\ *" "ptr" ", int\ " "flags" ");"
80 .HP \w'void\ sdallocx('u
81 .BI "void sdallocx(void\ *" "ptr" ", size_t\ " "size" ", int\ " "flags" ");"
82 .HP \w'size_t\ nallocx('u
83 .BI "size_t nallocx(size_t\ " "size" ", int\ " "flags" ");"
84 .HP \w'int\ mallctl('u
85 .BI "int mallctl(const\ char\ *" "name" ", void\ *" "oldp" ", size_t\ *" "oldlenp" ", void\ *" "newp" ", size_t\ " "newlen" ");"
86 .HP \w'int\ mallctlnametomib('u
87 .BI "int mallctlnametomib(const\ char\ *" "name" ", size_t\ *" "mibp" ", size_t\ *" "miblenp" ");"
88 .HP \w'int\ mallctlbymib('u
89 .BI "int mallctlbymib(const\ size_t\ *" "mib" ", size_t\ " "miblen" ", void\ *" "oldp" ", size_t\ *" "oldlenp" ", void\ *" "newp" ", size_t\ " "newlen" ");"
90 .HP \w'void\ malloc_stats_print('u
91 .BI "void malloc_stats_print(void\ " "(*write_cb)" "\ (void\ *,\ const\ char\ *), void\ *" "cbopaque" ", const\ char\ *" "opts" ");"
92 .HP \w'size_t\ malloc_usable_size('u
93 .BI "size_t malloc_usable_size(const\ void\ *" "ptr" ");"
94 .HP \w'void\ (*malloc_message)('u
95 .BI "void (*malloc_message)(void\ *" "cbopaque" ", const\ char\ *" "s" ");"
96 .PP
97 const char *\fImalloc_conf\fR;
98 .SH "DESCRIPTION"
99 .SS "Standard API"
100 .PP
101 The
102 malloc()
103 function allocates
104 \fIsize\fR
105 bytes of uninitialized memory\&. The allocated space is suitably aligned (after possible pointer coercion) for storage of any type of object\&.
106 .PP
107 The
108 calloc()
109 function allocates space for
110 \fInumber\fR
111 objects, each
112 \fIsize\fR
113 bytes in length\&. The result is identical to calling
114 malloc()
115 with an argument of
116 \fInumber\fR
117 *
118 \fIsize\fR, with the exception that the allocated memory is explicitly initialized to zero bytes\&.
119 .PP
120 The
121 posix_memalign()
122 function allocates
123 \fIsize\fR
124 bytes of memory such that the allocation\*(Aqs base address is a multiple of
125 \fIalignment\fR, and returns the allocation in the value pointed to by
126 \fIptr\fR\&. The requested
127 \fIalignment\fR
128 must be a power of 2 at least as large as
129 sizeof(\fBvoid *\fR)\&.
130 .PP
131 The
132 aligned_alloc()
133 function allocates
134 \fIsize\fR
135 bytes of memory such that the allocation\*(Aqs base address is a multiple of
136 \fIalignment\fR\&. The requested
137 \fIalignment\fR
138 must be a power of 2\&. Behavior is undefined if
139 \fIsize\fR
140 is not an integral multiple of
141 \fIalignment\fR\&.
142 .PP
143 The
144 realloc()
145 function changes the size of the previously allocated memory referenced by
146 \fIptr\fR
147 to
148 \fIsize\fR
149 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
150 \fIptr\fR
151 is freed and a pointer to the newly allocated memory is returned\&. Note that
152 realloc()
153 may move the memory allocation, resulting in a different return value than
154 \fIptr\fR\&. If
155 \fIptr\fR
156 is
157 \fBNULL\fR, the
158 realloc()
159 function behaves identically to
160 malloc()
161 for the specified size\&.
162 .PP
163 The
164 free()
165 function causes the allocated memory referenced by
166 \fIptr\fR
167 to be made available for future allocations\&. If
168 \fIptr\fR
169 is
170 \fBNULL\fR, no action occurs\&.
171 .SS "Non\-standard API"
172 .PP
173 The
174 mallocx(),
175 rallocx(),
176 xallocx(),
177 sallocx(),
178 dallocx(),
179 sdallocx(), and
180 nallocx()
181 functions all have a
182 \fIflags\fR
183 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:
184 .PP
185 \fBMALLOCX_LG_ALIGN(\fR\fB\fIla\fR\fR\fB) \fR
186 .RS 4
187 Align the memory allocation to start at an address that is a multiple of
188 (1 << \fIla\fR)\&. This macro does not validate that
189 \fIla\fR
190 is within the valid range\&.
191 .RE
192 .PP
193 \fBMALLOCX_ALIGN(\fR\fB\fIa\fR\fR\fB) \fR
194 .RS 4
195 Align the memory allocation to start at an address that is a multiple of
196 \fIa\fR, where
197 \fIa\fR
198 is a power of two\&. This macro does not validate that
199 \fIa\fR
200 is a power of 2\&.
201 .RE
202 .PP
203 \fBMALLOCX_ZERO\fR
204 .RS 4
205 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\&.
206 .RE
207 .PP
208 \fBMALLOCX_TCACHE(\fR\fB\fItc\fR\fR\fB) \fR
209 .RS 4
210 Use the thread\-specific cache (tcache) specified by the identifier
211 \fItc\fR, which must have been acquired via the
212 tcache\&.create
213 mallctl\&. This macro does not validate that
214 \fItc\fR
215 specifies a valid identifier\&.
216 .RE
217 .PP
218 \fBMALLOCX_TCACHE_NONE\fR
219 .RS 4
220 Do not use a thread\-specific cache (tcache)\&. Unless
221 \fBMALLOCX_TCACHE(\fR\fB\fItc\fR\fR\fB)\fR
222 or
223 \fBMALLOCX_TCACHE_NONE\fR
224 is specified, an automatically managed tcache will be used under many circumstances\&. This macro cannot be used in the same
225 \fIflags\fR
226 argument as
227 \fBMALLOCX_TCACHE(\fR\fB\fItc\fR\fR\fB)\fR\&.
228 .RE
229 .PP
230 \fBMALLOCX_ARENA(\fR\fB\fIa\fR\fR\fB) \fR
231 .RS 4
232 Use the arena specified by the index
233 \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
234 \fIa\fR
235 specifies an arena index in the valid range\&.
236 .RE
237 .PP
238 The
239 mallocx()
240 function allocates at least
241 \fIsize\fR
242 bytes of memory, and returns a pointer to the base address of the allocation\&. Behavior is undefined if
243 \fIsize\fR
244 is
245 \fB0\fR\&.
246 .PP
247 The
248 rallocx()
249 function resizes the allocation at
250 \fIptr\fR
251 to be at least
252 \fIsize\fR
253 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
254 \fIsize\fR
255 is
256 \fB0\fR\&.
257 .PP
258 The
259 xallocx()
260 function resizes the allocation at
261 \fIptr\fR
262 in place to be at least
263 \fIsize\fR
264 bytes, and returns the real size of the allocation\&. If
265 \fIextra\fR
266 is non\-zero, an attempt is made to resize the allocation to be at least
267 (\fIsize\fR + \fIextra\fR)
268 bytes, though inability to allocate the extra byte(s) will not by itself result in failure to resize\&. Behavior is undefined if
269 \fIsize\fR
270 is
271 \fB0\fR, or if
272 (\fIsize\fR + \fIextra\fR > \fBSIZE_T_MAX\fR)\&.
273 .PP
274 The
275 sallocx()
276 function returns the real size of the allocation at
277 \fIptr\fR\&.
278 .PP
279 The
280 dallocx()
281 function causes the memory referenced by
282 \fIptr\fR
283 to be made available for future allocations\&.
284 .PP
285 The
286 sdallocx()
287 function is an extension of
288 dallocx()
289 with a
290 \fIsize\fR
291 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
292 nallocx()
293 or
294 sallocx()\&.
295 .PP
296 The
297 nallocx()
298 function allocates no memory, but it performs the same size computation as the
299 mallocx()
300 function, and returns the real size of the allocation that would result from the equivalent
301 mallocx()
302 function call, or
303 \fB0\fR
304 if the inputs exceed the maximum supported size class and/or alignment\&. Behavior is undefined if
305 \fIsize\fR
306 is
307 \fB0\fR\&.
308 .PP
309 The
310 mallctl()
311 function provides a general interface for introspecting the memory allocator, as well as setting modifiable parameters and triggering actions\&. The period\-separated
312 \fIname\fR
313 argument specifies a location in a tree\-structured namespace; see the
314 MALLCTL NAMESPACE
315 section for documentation on the tree contents\&. To read a value, pass a pointer via
316 \fIoldp\fR
317 to adequate space to contain the value, and a pointer to its length via
318 \fIoldlenp\fR; otherwise pass
319 \fBNULL\fR
320 and
321 \fBNULL\fR\&. Similarly, to write a value, pass a pointer to the value via
322 \fInewp\fR, and its length via
323 \fInewlen\fR; otherwise pass
324 \fBNULL\fR
325 and
326 \fB0\fR\&.
327 .PP
328 The
329 mallctlnametomib()
330 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
331 \(lqManagement Information Base\(rq
332 (MIB) that can be passed repeatedly to
333 mallctlbymib()\&. Upon successful return from
334 mallctlnametomib(),
335 \fImibp\fR
336 contains an array of
337 \fI*miblenp\fR
338 integers, where
339 \fI*miblenp\fR
340 is the lesser of the number of components in
341 \fIname\fR
342 and the input value of
343 \fI*miblenp\fR\&. Thus it is possible to pass a
344 \fI*miblenp\fR
345 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
346 arenas\&.bin\&.2\&.size), the corresponding MIB component will always be that integer\&. Therefore, it is legitimate to construct code like the following:
347 .sp
348 .if n \{\
349 .RS 4
350 .\}
351 .nf
352 unsigned nbins, i;
353 size_t mib[4];
354 size_t len, miblen;
355
356 len = sizeof(nbins);
357 mallctl("arenas\&.nbins", &nbins, &len, NULL, 0);
358
359 miblen = 4;
360 mallctlnametomib("arenas\&.bin\&.0\&.size", mib, &miblen);
361 for (i = 0; i < nbins; i++) {
362         size_t bin_size;
363
364         mib[2] = i;
365         len = sizeof(bin_size);
366         mallctlbymib(mib, miblen, (void *)&bin_size, &len, NULL, 0);
367         /* Do something with bin_size\&.\&.\&. */
368 }
369 .fi
370 .if n \{\
371 .RE
372 .\}
373 .PP
374 .RS 4
375 .RE
376 .PP
377 The
378 malloc_stats_print()
379 function writes summary statistics via the
380 \fIwrite_cb\fR
381 callback function pointer and
382 \fIcbopaque\fR
383 data passed to
384 \fIwrite_cb\fR, or
385 malloc_message()
386 if
387 \fIwrite_cb\fR
388 is
389 \fBNULL\fR\&. The statistics are presented in human\-readable form unless
390 \(lqJ\(rq
391 is specified as a character within the
392 \fIopts\fR
393 string, in which case the statistics are presented in
394 \m[blue]\fBJSON format\fR\m[]\&\s-2\u[2]\d\s+2\&. This function can be called repeatedly\&. General information that never changes during execution can be omitted by specifying
395 \(lqg\(rq
396 as a character within the
397 \fIopts\fR
398 string\&. Note that
399 malloc_stats_print()
400 uses the
401 mallctl*()
402 functions internally, so inconsistent statistics can be reported if multiple threads use these functions simultaneously\&. If
403 \fB\-\-enable\-stats\fR
404 is specified during configuration,
405 \(lqm\(rq,
406 \(lqd\(rq, and
407 \(lqa\(rq
408 can be specified to omit merged arena, destroyed merged arena, and per arena statistics, respectively;
409 \(lqb\(rq
410 and
411 \(lql\(rq
412 can be specified to omit per size class statistics for bins and large objects, respectively;
413 \(lqx\(rq
414 can be specified to omit all mutex statistics;
415 \(lqe\(rq
416 can be used to omit extent statistics\&. 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\&.
417 .PP
418 The
419 malloc_usable_size()
420 function returns the usable size of the allocation pointed to by
421 \fIptr\fR\&. The return value may be larger than the size that was requested during allocation\&. The
422 malloc_usable_size()
423 function is not a mechanism for in\-place
424 realloc(); rather it is provided solely as a tool for introspection purposes\&. Any discrepancy between the requested allocation size and the size reported by
425 malloc_usable_size()
426 should not be depended on, since such behavior is entirely implementation\-dependent\&.
427 .SH "TUNING"
428 .PP
429 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\&.
430 .PP
431 The string specified via
432 \fB\-\-with\-malloc\-conf\fR, the string pointed to by the global variable
433 \fImalloc_conf\fR, the
434 \(lqname\(rq
435 of the file referenced by the symbolic link named
436 /etc/malloc\&.conf, and the value of the environment variable
437 \fBMALLOC_CONF\fR, will be interpreted, in that order, from left to right as options\&. Note that
438 \fImalloc_conf\fR
439 may be read before
440 main()
441 is entered, so the declaration of
442 \fImalloc_conf\fR
443 should specify an initializer that contains the final value to be read by jemalloc\&.
444 \fB\-\-with\-malloc\-conf\fR
445 and
446 \fImalloc_conf\fR
447 are compile\-time mechanisms, whereas
448 /etc/malloc\&.conf
449 and
450 \fBMALLOC_CONF\fR
451 can be safely set any time prior to program invocation\&.
452 .PP
453 An options string is a comma\-separated list of option:value pairs\&. There is one key corresponding to each
454 opt\&.*
455 mallctl (see the
456 MALLCTL NAMESPACE
457 section for options documentation)\&. For example,
458 abort:true,narenas:1
459 sets the
460 opt\&.abort
461 and
462 opt\&.narenas
463 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\&.
464 .SH "IMPLEMENTATION NOTES"
465 .PP
466 Traditionally, allocators have used
467 \fBsbrk\fR(2)
468 to obtain memory, which is suboptimal for several reasons, including race conditions, increased fragmentation, and artificial limitations on maximum usable memory\&. If
469 \fBsbrk\fR(2)
470 is supported by the operating system, this allocator uses both
471 \fBmmap\fR(2)
472 and
473 \fBsbrk\fR(2), in that order of preference; otherwise only
474 \fBmmap\fR(2)
475 is used\&.
476 .PP
477 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\&.
478 .PP
479 In addition to multiple arenas, this allocator supports thread\-specific caching, 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\&.
480 .PP
481 Memory is conceptually broken into extents\&. Extents are always aligned to multiples of the page size\&. This alignment makes it possible to find metadata for user objects quickly\&. User objects are broken into two categories according to size: small and large\&. Contiguous small objects comprise a slab, which resides within a single extent, whereas large objects each have their own extents backing them\&.
482 .PP
483 Small objects are managed in groups by slabs\&. Each slab 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
484 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, and large size classes extend from four times the page size up to the largest size class that does not exceed
485 \fBPTRDIFF_MAX\fR\&.
486 .PP
487 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\&.
488 .PP
489 The
490 realloc(),
491 rallocx(), and
492 xallocx()
493 functions may resize allocations without moving them under limited circumstances\&. Unlike the
494 *allocx()
495 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
496 realloc()
497 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 allocations in place, as long as the pre\-size and post\-size are both large\&. For shrinkage to succeed, the extent allocator must support splitting (see
498 arena\&.<i>\&.extent_hooks)\&. Growth only succeeds if the trailing memory is currently available, and the extent allocator supports merging\&.
499 .PP
500 Assuming 4 KiB pages and a 16\-byte quantum on a 64\-bit system, the size classes in each category are as shown in
501 Table 1\&.
502 .sp
503 .it 1 an-trap
504 .nr an-no-space-flag 1
505 .nr an-break-flag 1
506 .br
507 .B Table\ \&1.\ \&Size classes
508 .TS
509 allbox tab(:);
510 lB rB lB.
511 T{
512 Category
513 T}:T{
514 Spacing
515 T}:T{
516 Size
517 T}
518 .T&
519 l r l
520 ^ r l
521 ^ r l
522 ^ r l
523 ^ r l
524 ^ r l
525 ^ r l
526 ^ r l
527 ^ r l
528 l r l
529 ^ r l
530 ^ r l
531 ^ r l
532 ^ r l
533 ^ r l
534 ^ r l
535 ^ r l
536 ^ r l
537 ^ r l
538 ^ r l
539 ^ r l
540 ^ r l
541 ^ r l
542 ^ r l
543 ^ r l.
544 T{
545 Small
546 T}:T{
547 lg
548 T}:T{
549 [8]
550 T}
551 :T{
552 16
553 T}:T{
554 [16, 32, 48, 64, 80, 96, 112, 128]
555 T}
556 :T{
557 32
558 T}:T{
559 [160, 192, 224, 256]
560 T}
561 :T{
562 64
563 T}:T{
564 [320, 384, 448, 512]
565 T}
566 :T{
567 128
568 T}:T{
569 [640, 768, 896, 1024]
570 T}
571 :T{
572 256
573 T}:T{
574 [1280, 1536, 1792, 2048]
575 T}
576 :T{
577 512
578 T}:T{
579 [2560, 3072, 3584, 4096]
580 T}
581 :T{
582 1 KiB
583 T}:T{
584 [5 KiB, 6 KiB, 7 KiB, 8 KiB]
585 T}
586 :T{
587 2 KiB
588 T}:T{
589 [10 KiB, 12 KiB, 14 KiB]
590 T}
591 T{
592 Large
593 T}:T{
594 2 KiB
595 T}:T{
596 [16 KiB]
597 T}
598 :T{
599 4 KiB
600 T}:T{
601 [20 KiB, 24 KiB, 28 KiB, 32 KiB]
602 T}
603 :T{
604 8 KiB
605 T}:T{
606 [40 KiB, 48 KiB, 54 KiB, 64 KiB]
607 T}
608 :T{
609 16 KiB
610 T}:T{
611 [80 KiB, 96 KiB, 112 KiB, 128 KiB]
612 T}
613 :T{
614 32 KiB
615 T}:T{
616 [160 KiB, 192 KiB, 224 KiB, 256 KiB]
617 T}
618 :T{
619 64 KiB
620 T}:T{
621 [320 KiB, 384 KiB, 448 KiB, 512 KiB]
622 T}
623 :T{
624 128 KiB
625 T}:T{
626 [640 KiB, 768 KiB, 896 KiB, 1 MiB]
627 T}
628 :T{
629 256 KiB
630 T}:T{
631 [1280 KiB, 1536 KiB, 1792 KiB, 2 MiB]
632 T}
633 :T{
634 512 KiB
635 T}:T{
636 [2560 KiB, 3 MiB, 3584 KiB, 4 MiB]
637 T}
638 :T{
639 1 MiB
640 T}:T{
641 [5 MiB, 6 MiB, 7 MiB, 8 MiB]
642 T}
643 :T{
644 2 MiB
645 T}:T{
646 [10 MiB, 12 MiB, 14 MiB, 16 MiB]
647 T}
648 :T{
649 4 MiB
650 T}:T{
651 [20 MiB, 24 MiB, 28 MiB, 32 MiB]
652 T}
653 :T{
654 8 MiB
655 T}:T{
656 [40 MiB, 48 MiB, 56 MiB, 64 MiB]
657 T}
658 :T{
659 \&.\&.\&.
660 T}:T{
661 \&.\&.\&.
662 T}
663 :T{
664 512 PiB
665 T}:T{
666 [2560 PiB, 3 EiB, 3584 PiB, 4 EiB]
667 T}
668 :T{
669 1 EiB
670 T}:T{
671 [5 EiB, 6 EiB, 7 EiB]
672 T}
673 .TE
674 .sp 1
675 .SH "MALLCTL NAMESPACE"
676 .PP
677 The following names are defined in the namespace accessible via the
678 mallctl*()
679 functions\&. Value types are specified in parentheses, their readable/writable statuses are encoded as
680 rw,
681 r\-,
682 \-w, or
683 \-\-, and required build configuration flags follow, if any\&. A name element encoded as
684 <i>
685 or
686 <j>
687 indicates an integer component, where the integer varies from 0 to some upper value that must be determined via introspection\&. In the case of
688 stats\&.arenas\&.<i>\&.*
689 and
690 arena\&.<i>\&.{initialized,purge,decay,dss},
691 <i>
692 equal to
693 \fBMALLCTL_ARENAS_ALL\fR
694 can be used to operate on all arenas or access the summation of statistics from all arenas; similarly
695 <i>
696 equal to
697 \fBMALLCTL_ARENAS_DESTROYED\fR
698 can be used to access the summation of statistics from all destroyed arenas\&. These constants can be utilized either via
699 mallctlnametomib()
700 followed by
701 mallctlbymib(), or via code such as the following:
702 .sp
703 .if n \{\
704 .RS 4
705 .\}
706 .nf
707 #define STRINGIFY_HELPER(x) #x
708 #define STRINGIFY(x) STRINGIFY_HELPER(x)
709
710 mallctl("arena\&." STRINGIFY(MALLCTL_ARENAS_ALL) "\&.decay",
711     NULL, NULL, NULL, 0);
712 .fi
713 .if n \{\
714 .RE
715 .\}
716 .sp
717 Take special note of the
718 epoch
719 mallctl, which controls refreshing of cached dynamic statistics\&.
720 .PP
721 version (\fBconst char *\fR) r\-
722 .RS 4
723 Return the jemalloc version string\&.
724 .RE
725 .PP
726 epoch (\fBuint64_t\fR) rw
727 .RS 4
728 If a value is passed in, refresh the data from which the
729 mallctl*()
730 functions report values, and increment the epoch\&. Return the current epoch\&. This is useful for detecting whether another thread caused a refresh\&.
731 .RE
732 .PP
733 background_thread (\fBbool\fR) rw
734 .RS 4
735 Enable/disable internal background worker threads\&. When set to true, background threads are created on demand (the number of background threads will be no more than the number of CPUs or active arenas)\&. Threads run periodically, and handle
736 purging
737 asynchronously\&. When switching off, background threads are terminated synchronously\&. Note that after
738 \fBfork\fR(2)
739 function, the state in the child process will be disabled regardless the state in parent process\&. See
740 stats\&.background_thread
741 for related stats\&.
742 opt\&.background_thread
743 can be used to set the default option\&. This option is only available on selected pthread\-based platforms\&.
744 .RE
745 .PP
746 max_background_threads (\fBsize_t\fR) rw
747 .RS 4
748 Maximum number of background worker threads that will be created\&. This value is capped at
749 opt\&.max_background_threads
750 at startup\&.
751 .RE
752 .PP
753 config\&.cache_oblivious (\fBbool\fR) r\-
754 .RS 4
755 \fB\-\-enable\-cache\-oblivious\fR
756 was specified during build configuration\&.
757 .RE
758 .PP
759 config\&.debug (\fBbool\fR) r\-
760 .RS 4
761 \fB\-\-enable\-debug\fR
762 was specified during build configuration\&.
763 .RE
764 .PP
765 config\&.fill (\fBbool\fR) r\-
766 .RS 4
767 \fB\-\-enable\-fill\fR
768 was specified during build configuration\&.
769 .RE
770 .PP
771 config\&.lazy_lock (\fBbool\fR) r\-
772 .RS 4
773 \fB\-\-enable\-lazy\-lock\fR
774 was specified during build configuration\&.
775 .RE
776 .PP
777 config\&.malloc_conf (\fBconst char *\fR) r\-
778 .RS 4
779 Embedded configure\-time\-specified run\-time options string, empty unless
780 \fB\-\-with\-malloc\-conf\fR
781 was specified during build configuration\&.
782 .RE
783 .PP
784 config\&.prof (\fBbool\fR) r\-
785 .RS 4
786 \fB\-\-enable\-prof\fR
787 was specified during build configuration\&.
788 .RE
789 .PP
790 config\&.prof_libgcc (\fBbool\fR) r\-
791 .RS 4
792 \fB\-\-disable\-prof\-libgcc\fR
793 was not specified during build configuration\&.
794 .RE
795 .PP
796 config\&.prof_libunwind (\fBbool\fR) r\-
797 .RS 4
798 \fB\-\-enable\-prof\-libunwind\fR
799 was specified during build configuration\&.
800 .RE
801 .PP
802 config\&.stats (\fBbool\fR) r\-
803 .RS 4
804 \fB\-\-enable\-stats\fR
805 was specified during build configuration\&.
806 .RE
807 .PP
808 config\&.utrace (\fBbool\fR) r\-
809 .RS 4
810 \fB\-\-enable\-utrace\fR
811 was specified during build configuration\&.
812 .RE
813 .PP
814 config\&.xmalloc (\fBbool\fR) r\-
815 .RS 4
816 \fB\-\-enable\-xmalloc\fR
817 was specified during build configuration\&.
818 .RE
819 .PP
820 opt\&.abort (\fBbool\fR) r\-
821 .RS 4
822 Abort\-on\-warning enabled/disabled\&. If true, most warnings are fatal\&. Note that runtime option warnings are not included (see
823 opt\&.abort_conf
824 for that)\&. The process will call
825 \fBabort\fR(3)
826 in these cases\&. This option is disabled by default unless
827 \fB\-\-enable\-debug\fR
828 is specified during configuration, in which case it is enabled by default\&.
829 .RE
830 .PP
831 opt\&.confirm_conf (\fBbool\fR) r\-
832 .RS 4
833 Confirm\-runtime\-options\-when\-program\-starts enabled/disabled\&. If true, the string specified via
834 \fB\-\-with\-malloc\-conf\fR, the string pointed to by the global variable
835 \fImalloc_conf\fR, the
836 \(lqname\(rq
837 of the file referenced by the symbolic link named
838 /etc/malloc\&.conf, and the value of the environment variable
839 \fBMALLOC_CONF\fR, will be printed in order\&. Then, each option being set will be individually printed\&. This option is disabled by default\&.
840 .RE
841 .PP
842 opt\&.abort_conf (\fBbool\fR) r\-
843 .RS 4
844 Abort\-on\-invalid\-configuration enabled/disabled\&. If true, invalid runtime options are fatal\&. The process will call
845 \fBabort\fR(3)
846 in these cases\&. This option is disabled by default unless
847 \fB\-\-enable\-debug\fR
848 is specified during configuration, in which case it is enabled by default\&.
849 .RE
850 .PP
851 opt\&.metadata_thp (\fBconst char *\fR) r\-
852 .RS 4
853 Controls whether to allow jemalloc to use transparent huge page (THP) for internal metadata (see
854 stats\&.metadata)\&.
855 \(lqalways\(rq
856 allows such usage\&.
857 \(lqauto\(rq
858 uses no THP initially, but may begin to do so when metadata usage reaches certain level\&. The default is
859 \(lqdisabled\(rq\&.
860 .RE
861 .PP
862 opt\&.retain (\fBbool\fR) r\-
863 .RS 4
864 If true, retain unused virtual memory for later reuse rather than discarding it by calling
865 \fBmunmap\fR(2)
866 or equivalent (see
867 stats\&.retained
868 for related details)\&. It also makes jemalloc use
869 \fBmmap\fR(2)
870 or equivalent in a more greedy way, mapping larger chunks in one go\&. This option is disabled by default unless discarding virtual memory is known to trigger platform\-specific performance problems, namely 1) for [64\-bit] Linux, which has a quirk in its virtual memory allocation algorithm that causes semi\-permanent VM map holes under normal jemalloc operation; and 2) for [64\-bit] Windows, which disallows split / merged regions with
871 \fI\fBMEM_RELEASE\fR\fR\&. Although the same issues may present on 32\-bit platforms as well, retaining virtual memory for 32\-bit Linux and Windows is disabled by default due to the practical possibility of address space exhaustion\&.
872 .RE
873 .PP
874 opt\&.dss (\fBconst char *\fR) r\-
875 .RS 4
876 dss (\fBsbrk\fR(2)) allocation precedence as related to
877 \fBmmap\fR(2)
878 allocation\&. The following settings are supported if
879 \fBsbrk\fR(2)
880 is supported by the operating system:
881 \(lqdisabled\(rq,
882 \(lqprimary\(rq, and
883 \(lqsecondary\(rq; otherwise only
884 \(lqdisabled\(rq
885 is supported\&. The default is
886 \(lqsecondary\(rq
887 if
888 \fBsbrk\fR(2)
889 is supported by the operating system;
890 \(lqdisabled\(rq
891 otherwise\&.
892 .RE
893 .PP
894 opt\&.narenas (\fBunsigned\fR) r\-
895 .RS 4
896 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\&.
897 .RE
898 .PP
899 opt\&.oversize_threshold (\fBsize_t\fR) r\-
900 .RS 4
901 The threshold in bytes of which requests are considered oversize\&. Allocation requests with greater sizes are fulfilled from a dedicated arena (automatically managed, however not within
902 narenas), in order to reduce fragmentation by not mixing huge allocations with small ones\&. In addition, the decay API guarantees on the extents greater than the specified threshold may be overridden\&. Note that requests with arena index specified via
903 \fBMALLOCX_ARENA\fR, or threads associated with explicit arenas will not be considered\&. The default threshold is 8MiB\&. Values not within large size classes disables this feature\&.
904 .RE
905 .PP
906 opt\&.percpu_arena (\fBconst char *\fR) r\-
907 .RS 4
908 Per CPU arena mode\&. Use the
909 \(lqpercpu\(rq
910 setting to enable this feature, which uses number of CPUs to determine number of arenas, and bind threads to arenas dynamically based on the CPU the thread runs on currently\&.
911 \(lqphycpu\(rq
912 setting uses one arena per physical CPU, which means the two hyper threads on the same CPU share one arena\&. Note that no runtime checking regarding the availability of hyper threading is done at the moment\&. When set to
913 \(lqdisabled\(rq, narenas and thread to arena association will not be impacted by this option\&. The default is
914 \(lqdisabled\(rq\&.
915 .RE
916 .PP
917 opt\&.background_thread (\fBbool\fR) r\-
918 .RS 4
919 Internal background worker threads enabled/disabled\&. Because of potential circular dependencies, enabling background thread using this option may cause crash or deadlock during initialization\&. For a reliable way to use this feature, see
920 background_thread
921 for dynamic control options and details\&. This option is disabled by default\&.
922 .RE
923 .PP
924 opt\&.max_background_threads (\fBsize_t\fR) r\-
925 .RS 4
926 Maximum number of background threads that will be created if
927 background_thread
928 is set\&. Defaults to number of cpus\&.
929 .RE
930 .PP
931 opt\&.dirty_decay_ms (\fBssize_t\fR) r\-
932 .RS 4
933 Approximate time in milliseconds from the creation of a set of unused dirty pages until an equivalent set of unused dirty pages is purged (i\&.e\&. converted to muzzy via e\&.g\&.
934 madvise(\fI\&.\&.\&.\fR\fI\fBMADV_FREE\fR\fR)
935 if supported by the operating system, or converted to clean otherwise) and/or reused\&. Dirty pages are defined as previously having been potentially written to by the application, and therefore consuming physical memory, yet having no current use\&. The pages are incrementally purged according to a sigmoidal decay curve that starts and ends with zero purge rate\&. A decay time of 0 causes all unused dirty pages to be purged immediately upon creation\&. A decay time of \-1 disables purging\&. The default decay time is 10 seconds\&. See
936 arenas\&.dirty_decay_ms
937 and
938 arena\&.<i>\&.dirty_decay_ms
939 for related dynamic control options\&. See
940 opt\&.muzzy_decay_ms
941 for a description of muzzy pages\&.for a description of muzzy pages\&. Note that when the
942 oversize_threshold
943 feature is enabled, the arenas reserved for oversize requests may have its own default decay settings\&.
944 .RE
945 .PP
946 opt\&.muzzy_decay_ms (\fBssize_t\fR) r\-
947 .RS 4
948 Approximate time in milliseconds from the creation of a set of unused muzzy pages until an equivalent set of unused muzzy pages is purged (i\&.e\&. converted to clean) and/or reused\&. Muzzy pages are defined as previously having been unused dirty pages that were subsequently purged in a manner that left them subject to the reclamation whims of the operating system (e\&.g\&.
949 madvise(\fI\&.\&.\&.\fR\fI\fBMADV_FREE\fR\fR)), and therefore in an indeterminate state\&. The pages are incrementally purged according to a sigmoidal decay curve that starts and ends with zero purge rate\&. A decay time of 0 causes all unused muzzy pages to be purged immediately upon creation\&. A decay time of \-1 disables purging\&. The default decay time is 10 seconds\&. See
950 arenas\&.muzzy_decay_ms
951 and
952 arena\&.<i>\&.muzzy_decay_ms
953 for related dynamic control options\&.
954 .RE
955 .PP
956 opt\&.lg_extent_max_active_fit (\fBsize_t\fR) r\-
957 .RS 4
958 When reusing dirty extents, this determines the (log base 2 of the) maximum ratio between the size of the active extent selected (to split off from) and the size of the requested allocation\&. This prevents the splitting of large active extents for smaller allocations, which can reduce fragmentation over the long run (especially for non\-active extents)\&. Lower value may reduce fragmentation, at the cost of extra active extents\&. The default value is 6, which gives a maximum ratio of 64 (2^6)\&.
959 .RE
960 .PP
961 opt\&.stats_print (\fBbool\fR) r\-
962 .RS 4
963 Enable/disable statistics printing at exit\&. If enabled, the
964 malloc_stats_print()
965 function is called at program exit via an
966 \fBatexit\fR(3)
967 function\&.
968 opt\&.stats_print_opts
969 can be combined to specify output options\&. If
970 \fB\-\-enable\-stats\fR
971 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,
972 atexit()
973 may allocate memory during application initialization and then deadlock internally when jemalloc in turn calls
974 atexit(), so this option is not universally usable (though the application can register its own
975 atexit()
976 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\&.
977 .RE
978 .PP
979 opt\&.stats_print_opts (\fBconst char *\fR) r\-
980 .RS 4
981 Options (the
982 \fIopts\fR
983 string) to pass to the
984 malloc_stats_print()
985 at exit (enabled through
986 opt\&.stats_print)\&. See available options in
987 malloc_stats_print()\&. Has no effect unless
988 opt\&.stats_print
989 is enabled\&. The default is
990 \(lq\(rq\&.
991 .RE
992 .PP
993 opt\&.junk (\fBconst char *\fR) r\- [\fB\-\-enable\-fill\fR]
994 .RS 4
995 Junk filling\&. If set to
996 \(lqalloc\(rq, each byte of uninitialized allocated memory will be initialized to
997 0xa5\&. If set to
998 \(lqfree\(rq, all deallocated memory will be initialized to
999 0x5a\&. If set to
1000 \(lqtrue\(rq, both allocated and deallocated memory will be initialized, and if set to
1001 \(lqfalse\(rq, junk filling be disabled entirely\&. This is intended for debugging and will impact performance negatively\&. This option is
1002 \(lqfalse\(rq
1003 by default unless
1004 \fB\-\-enable\-debug\fR
1005 is specified during configuration, in which case it is
1006 \(lqtrue\(rq
1007 by default\&.
1008 .RE
1009 .PP
1010 opt\&.zero (\fBbool\fR) r\- [\fB\-\-enable\-fill\fR]
1011 .RS 4
1012 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
1013 realloc()
1014 and
1015 rallocx()
1016 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\&.
1017 .RE
1018 .PP
1019 opt\&.utrace (\fBbool\fR) r\- [\fB\-\-enable\-utrace\fR]
1020 .RS 4
1021 Allocation tracing based on
1022 \fButrace\fR(2)
1023 enabled/disabled\&. This option is disabled by default\&.
1024 .RE
1025 .PP
1026 opt\&.xmalloc (\fBbool\fR) r\- [\fB\-\-enable\-xmalloc\fR]
1027 .RS 4
1028 Abort\-on\-out\-of\-memory enabled/disabled\&. If enabled, rather than returning failure for any allocation function, display a diagnostic message on
1029 \fBSTDERR_FILENO\fR
1030 and cause the program to drop core (using
1031 \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:
1032 .sp
1033 .if n \{\
1034 .RS 4
1035 .\}
1036 .nf
1037 malloc_conf = "xmalloc:true";
1038 .fi
1039 .if n \{\
1040 .RE
1041 .\}
1042 .sp
1043 This option is disabled by default\&.
1044 .RE
1045 .PP
1046 opt\&.tcache (\fBbool\fR) r\-
1047 .RS 4
1048 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
1049 opt\&.lg_tcache_max
1050 option for related tuning information\&. This option is enabled by default\&.
1051 .RE
1052 .PP
1053 opt\&.lg_tcache_max (\fBsize_t\fR) r\-
1054 .RS 4
1055 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)\&.
1056 .RE
1057 .PP
1058 opt\&.thp (\fBconst char *\fR) r\-
1059 .RS 4
1060 Transparent hugepage (THP) mode\&. Settings "always", "never" and "default" are available if THP is supported by the operating system\&. The "always" setting enables transparent hugepage for all user memory mappings with
1061 \fI\fBMADV_HUGEPAGE\fR\fR; "never" ensures no transparent hugepage with
1062 \fI\fBMADV_NOHUGEPAGE\fR\fR; the default setting "default" makes no changes\&. Note that: this option does not affect THP for jemalloc internal metadata (see
1063 opt\&.metadata_thp); in addition, for arenas with customized
1064 extent_hooks, this option is bypassed as it is implemented as part of the default extent hooks\&.
1065 .RE
1066 .PP
1067 opt\&.prof (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
1068 .RS 4
1069 Memory profiling enabled/disabled\&. If enabled, profile memory allocation activity\&. See the
1070 opt\&.prof_active
1071 option for on\-the\-fly activation/deactivation\&. See the
1072 opt\&.lg_prof_sample
1073 option for probabilistic sampling control\&. See the
1074 opt\&.prof_accum
1075 option for control of cumulative sample reporting\&. See the
1076 opt\&.lg_prof_interval
1077 option for information on interval\-triggered profile dumping, the
1078 opt\&.prof_gdump
1079 option for information on high\-water\-triggered profile dumping, and the
1080 opt\&.prof_final
1081 option for final profile dumping\&. Profile output is compatible with the
1082 \fBjeprof\fR
1083 command, which is based on the
1084 \fBpprof\fR
1085 that is developed as part of the
1086 \m[blue]\fBgperftools package\fR\m[]\&\s-2\u[3]\d\s+2\&. See
1087 HEAP PROFILE FORMAT
1088 for heap profile format documentation\&.
1089 .RE
1090 .PP
1091 opt\&.prof_prefix (\fBconst char *\fR) r\- [\fB\-\-enable\-prof\fR]
1092 .RS 4
1093 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
1094 jeprof\&.
1095 .RE
1096 .PP
1097 opt\&.prof_active (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
1098 .RS 4
1099 Profiling activated/deactivated\&. This is a secondary control mechanism that makes it possible to start the application with profiling enabled (see the
1100 opt\&.prof
1101 option) but inactive, then toggle profiling at any time during program execution with the
1102 prof\&.active
1103 mallctl\&. This option is enabled by default\&.
1104 .RE
1105 .PP
1106 opt\&.prof_thread_active_init (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
1107 .RS 4
1108 Initial setting for
1109 thread\&.prof\&.active
1110 in newly created threads\&. The initial setting for newly created threads can also be changed during execution via the
1111 prof\&.thread_active_init
1112 mallctl\&. This option is enabled by default\&.
1113 .RE
1114 .PP
1115 opt\&.lg_prof_sample (\fBsize_t\fR) r\- [\fB\-\-enable\-prof\fR]
1116 .RS 4
1117 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)\&.
1118 .RE
1119 .PP
1120 opt\&.prof_accum (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
1121 .RS 4
1122 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\&.
1123 .RE
1124 .PP
1125 opt\&.lg_prof_interval (\fBssize_t\fR) r\- [\fB\-\-enable\-prof\fR]
1126 .RS 4
1127 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
1128 <prefix>\&.<pid>\&.<seq>\&.i<iseq>\&.heap, where
1129 <prefix>
1130 is controlled by the
1131 opt\&.prof_prefix
1132 option\&. By default, interval\-triggered profile dumping is disabled (encoded as \-1)\&.
1133 .RE
1134 .PP
1135 opt\&.prof_gdump (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
1136 .RS 4
1137 Set the initial state of
1138 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\&.
1139 .RE
1140 .PP
1141 opt\&.prof_final (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
1142 .RS 4
1143 Use an
1144 \fBatexit\fR(3)
1145 function to dump final memory usage to a file named according to the pattern
1146 <prefix>\&.<pid>\&.<seq>\&.f\&.heap, where
1147 <prefix>
1148 is controlled by the
1149 opt\&.prof_prefix
1150 option\&. Note that
1151 atexit()
1152 may allocate memory during application initialization and then deadlock internally when jemalloc in turn calls
1153 atexit(), so this option is not universally usable (though the application can register its own
1154 atexit()
1155 function with equivalent functionality)\&. This option is disabled by default\&.
1156 .RE
1157 .PP
1158 opt\&.prof_leak (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
1159 .RS 4
1160 Leak reporting enabled/disabled\&. If enabled, use an
1161 \fBatexit\fR(3)
1162 function to report memory leaks detected by allocation sampling\&. See the
1163 opt\&.prof
1164 option for information on analyzing heap profile output\&. This option is disabled by default\&.
1165 .RE
1166 .PP
1167 thread\&.arena (\fBunsigned\fR) rw
1168 .RS 4
1169 Get or set the arena associated with the calling thread\&. If the specified arena was not initialized beforehand (see the
1170 arena\&.i\&.initialized
1171 mallctl), it will be automatically initialized as a side effect of calling this interface\&.
1172 .RE
1173 .PP
1174 thread\&.allocated (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1175 .RS 4
1176 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\&.
1177 .RE
1178 .PP
1179 thread\&.allocatedp (\fBuint64_t *\fR) r\- [\fB\-\-enable\-stats\fR]
1180 .RS 4
1181 Get a pointer to the the value that is returned by the
1182 thread\&.allocated
1183 mallctl\&. This is useful for avoiding the overhead of repeated
1184 mallctl*()
1185 calls\&.
1186 .RE
1187 .PP
1188 thread\&.deallocated (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1189 .RS 4
1190 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\&.
1191 .RE
1192 .PP
1193 thread\&.deallocatedp (\fBuint64_t *\fR) r\- [\fB\-\-enable\-stats\fR]
1194 .RS 4
1195 Get a pointer to the the value that is returned by the
1196 thread\&.deallocated
1197 mallctl\&. This is useful for avoiding the overhead of repeated
1198 mallctl*()
1199 calls\&.
1200 .RE
1201 .PP
1202 thread\&.tcache\&.enabled (\fBbool\fR) rw
1203 .RS 4
1204 Enable/disable calling thread\*(Aqs tcache\&. The tcache is implicitly flushed as a side effect of becoming disabled (see
1205 thread\&.tcache\&.flush)\&.
1206 .RE
1207 .PP
1208 thread\&.tcache\&.flush (\fBvoid\fR) \-\-
1209 .RS 4
1210 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\&.
1211 .RE
1212 .PP
1213 thread\&.prof\&.name (\fBconst char *\fR) r\- or \-w [\fB\-\-enable\-prof\fR]
1214 .RS 4
1215 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 be nil\-terminated and comprised only of characters in the sets recognized by
1216 \fBisgraph\fR(3)
1217 and
1218 \fBisblank\fR(3)\&.
1219 .RE
1220 .PP
1221 thread\&.prof\&.active (\fBbool\fR) rw [\fB\-\-enable\-prof\fR]
1222 .RS 4
1223 Control whether sampling is currently active for the calling thread\&. This is an activation mechanism in addition to
1224 prof\&.active; both must be active for the calling thread to sample\&. This flag is enabled by default\&.
1225 .RE
1226 .PP
1227 tcache\&.create (\fBunsigned\fR) r\-
1228 .RS 4
1229 Create an explicit thread\-specific cache (tcache) and return an identifier that can be passed to the
1230 \fBMALLOCX_TCACHE(\fR\fB\fItc\fR\fR\fB)\fR
1231 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\&.
1232 .RE
1233 .PP
1234 tcache\&.flush (\fBunsigned\fR) \-w
1235 .RS 4
1236 Flush the specified thread\-specific cache (tcache)\&. The same considerations apply to this interface as to
1237 thread\&.tcache\&.flush, except that the tcache will never be automatically discarded\&.
1238 .RE
1239 .PP
1240 tcache\&.destroy (\fBunsigned\fR) \-w
1241 .RS 4
1242 Flush the specified thread\-specific cache (tcache) and make the identifier available for use during a future tcache creation\&.
1243 .RE
1244 .PP
1245 arena\&.<i>\&.initialized (\fBbool\fR) r\-
1246 .RS 4
1247 Get whether the specified arena\*(Aqs statistics are initialized (i\&.e\&. the arena was initialized prior to the current epoch)\&. This interface can also be nominally used to query whether the merged statistics corresponding to
1248 \fBMALLCTL_ARENAS_ALL\fR
1249 are initialized (always true)\&.
1250 .RE
1251 .PP
1252 arena\&.<i>\&.decay (\fBvoid\fR) \-\-
1253 .RS 4
1254 Trigger decay\-based purging of unused dirty/muzzy pages for arena <i>, or for all arenas if <i> equals
1255 \fBMALLCTL_ARENAS_ALL\fR\&. The proportion of unused dirty/muzzy pages to be purged depends on the current time; see
1256 opt\&.dirty_decay_ms
1257 and
1258 opt\&.muzy_decay_ms
1259 for details\&.
1260 .RE
1261 .PP
1262 arena\&.<i>\&.purge (\fBvoid\fR) \-\-
1263 .RS 4
1264 Purge all unused dirty pages for arena <i>, or for all arenas if <i> equals
1265 \fBMALLCTL_ARENAS_ALL\fR\&.
1266 .RE
1267 .PP
1268 arena\&.<i>\&.reset (\fBvoid\fR) \-\-
1269 .RS 4
1270 Discard all of the arena\*(Aqs extant allocations\&. This interface can only be used with arenas explicitly created via
1271 arenas\&.create\&. None of the arena\*(Aqs discarded/cached allocations may accessed afterward\&. As part of this requirement, all thread caches which were used to allocate/deallocate in conjunction with the arena must be flushed beforehand\&.
1272 .RE
1273 .PP
1274 arena\&.<i>\&.destroy (\fBvoid\fR) \-\-
1275 .RS 4
1276 Destroy the arena\&. Discard all of the arena\*(Aqs extant allocations using the same mechanism as for
1277 arena\&.<i>\&.reset
1278 (with all the same constraints and side effects), merge the arena stats into those accessible at arena index
1279 \fBMALLCTL_ARENAS_DESTROYED\fR, and then completely discard all metadata associated with the arena\&. Future calls to
1280 arenas\&.create
1281 may recycle the arena index\&. Destruction will fail if any threads are currently associated with the arena as a result of calls to
1282 thread\&.arena\&.
1283 .RE
1284 .PP
1285 arena\&.<i>\&.dss (\fBconst char *\fR) rw
1286 .RS 4
1287 Set the precedence of dss allocation as related to mmap allocation for arena <i>, or for all arenas if <i> equals
1288 \fBMALLCTL_ARENAS_ALL\fR\&. See
1289 opt\&.dss
1290 for supported settings\&.
1291 .RE
1292 .PP
1293 arena\&.<i>\&.dirty_decay_ms (\fBssize_t\fR) rw
1294 .RS 4
1295 Current per\-arena approximate time in milliseconds from the creation of a set of unused dirty pages until an equivalent set of unused dirty pages is purged and/or reused\&. Each time this interface is set, all currently unused dirty pages are considered to have fully decayed, which causes immediate purging of all unused dirty pages unless the decay time is set to \-1 (i\&.e\&. purging disabled)\&. See
1296 opt\&.dirty_decay_ms
1297 for additional information\&.
1298 .RE
1299 .PP
1300 arena\&.<i>\&.muzzy_decay_ms (\fBssize_t\fR) rw
1301 .RS 4
1302 Current per\-arena approximate time in milliseconds from the creation of a set of unused muzzy pages until an equivalent set of unused muzzy pages is purged and/or reused\&. Each time this interface is set, all currently unused muzzy pages are considered to have fully decayed, which causes immediate purging of all unused muzzy pages unless the decay time is set to \-1 (i\&.e\&. purging disabled)\&. See
1303 opt\&.muzzy_decay_ms
1304 for additional information\&.
1305 .RE
1306 .PP
1307 arena\&.<i>\&.retain_grow_limit (\fBsize_t\fR) rw
1308 .RS 4
1309 Maximum size to grow retained region (only relevant when
1310 opt\&.retain
1311 is enabled)\&. This controls the maximum increment to expand virtual memory, or allocation through
1312 arena\&.<i>extent_hooks\&. In particular, if customized extent hooks reserve physical memory (e\&.g\&. 1G huge pages), this is useful to control the allocation hook\*(Aqs input size\&. The default is no limit\&.
1313 .RE
1314 .PP
1315 arena\&.<i>\&.extent_hooks (\fBextent_hooks_t *\fR) rw
1316 .RS 4
1317 Get or set the extent management hook functions for arena <i>\&. The functions must be capable of operating on all extant extents associated with arena <i>, usually by passing unknown extents to the replaced functions\&. In practice, it is feasible to control allocation for arenas explicitly created via
1318 arenas\&.create
1319 such that all extents originate from an application\-supplied extent allocator (by specifying the custom extent hook functions during arena creation)\&. However, the API guarantees for the automatically created arenas may be relaxed \-\- hooks set there may be called in a "best effort" fashion; in addition there may be extents created prior to the application having an opportunity to take over extent allocation\&.
1320 .sp
1321 .if n \{\
1322 .RS 4
1323 .\}
1324 .nf
1325 typedef extent_hooks_s extent_hooks_t;
1326 struct extent_hooks_s {
1327         extent_alloc_t          *alloc;
1328         extent_dalloc_t         *dalloc;
1329         extent_destroy_t        *destroy;
1330         extent_commit_t         *commit;
1331         extent_decommit_t       *decommit;
1332         extent_purge_t          *purge_lazy;
1333         extent_purge_t          *purge_forced;
1334         extent_split_t          *split;
1335         extent_merge_t          *merge;
1336 };
1337 .fi
1338 .if n \{\
1339 .RE
1340 .\}
1341 .sp
1342 The
1343 \fBextent_hooks_t\fR
1344 structure comprises function pointers which are described individually below\&. jemalloc uses these functions to manage extent 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 extents for later reuse\&. Cleanup attempts cascade from deallocation to decommit to forced purging to lazy purging, which gives the extent management functions opportunities to reject the most permanent cleanup operations in favor of less permanent (and often less costly) operations\&. All operations except allocation can be universally opted out of by setting the hook pointers to
1345 \fBNULL\fR, or selectively opted out of by returning failure\&. Note that once the extent hook is set, the structure is accessed directly by the associated arenas, so it must remain valid for the entire lifetime of the arenas\&.
1346 .HP \w'typedef\ void\ *(extent_alloc_t)('u
1347 .BI "typedef void *(extent_alloc_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "new_addr" ", size_t\ " "size" ", size_t\ " "alignment" ", bool\ *" "zero" ", bool\ *" "commit" ", unsigned\ " "arena_ind" ");"
1348 .sp
1349 .if n \{\
1350 .RS 4
1351 .\}
1352 .nf
1353 .fi
1354 .if n \{\
1355 .RE
1356 .\}
1357 .sp
1358 An extent allocation function conforms to the
1359 \fBextent_alloc_t\fR
1360 type and upon success returns a pointer to
1361 \fIsize\fR
1362 bytes of mapped memory on behalf of arena
1363 \fIarena_ind\fR
1364 such that the extent\*(Aqs base address is a multiple of
1365 \fIalignment\fR, as well as setting
1366 \fI*zero\fR
1367 to indicate whether the extent is zeroed and
1368 \fI*commit\fR
1369 to indicate whether the extent is committed\&. Upon error the function returns
1370 \fBNULL\fR
1371 and leaves
1372 \fI*zero\fR
1373 and
1374 \fI*commit\fR
1375 unmodified\&. The
1376 \fIsize\fR
1377 parameter is always a multiple of the page size\&. The
1378 \fIalignment\fR
1379 parameter is always a power of two at least as large as the page size\&. Zeroing is mandatory if
1380 \fI*zero\fR
1381 is true upon function entry\&. Committing is mandatory if
1382 \fI*commit\fR
1383 is true upon function entry\&. If
1384 \fInew_addr\fR
1385 is not
1386 \fBNULL\fR, the returned pointer must be
1387 \fInew_addr\fR
1388 on success or
1389 \fBNULL\fR
1390 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 extent allocation function makes the arena\*(Aqs
1391 arena\&.<i>\&.dss
1392 setting irrelevant\&.
1393 .HP \w'typedef\ bool\ (extent_dalloc_t)('u
1394 .BI "typedef bool (extent_dalloc_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "addr" ", size_t\ " "size" ", bool\ " "committed" ", unsigned\ " "arena_ind" ");"
1395 .sp
1396 .if n \{\
1397 .RS 4
1398 .\}
1399 .nf
1400 .fi
1401 .if n \{\
1402 .RE
1403 .\}
1404 .sp
1405 An extent deallocation function conforms to the
1406 \fBextent_dalloc_t\fR
1407 type and deallocates an extent at given
1408 \fIaddr\fR
1409 and
1410 \fIsize\fR
1411 with
1412 \fIcommitted\fR/decommited memory as indicated, on behalf of arena
1413 \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 extent remains mapped, in the same commit state, and available for future use, in which case it will be automatically retained for later reuse\&.
1414 .HP \w'typedef\ void\ (extent_destroy_t)('u
1415 .BI "typedef void (extent_destroy_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "addr" ", size_t\ " "size" ", bool\ " "committed" ", unsigned\ " "arena_ind" ");"
1416 .sp
1417 .if n \{\
1418 .RS 4
1419 .\}
1420 .nf
1421 .fi
1422 .if n \{\
1423 .RE
1424 .\}
1425 .sp
1426 An extent destruction function conforms to the
1427 \fBextent_destroy_t\fR
1428 type and unconditionally destroys an extent at given
1429 \fIaddr\fR
1430 and
1431 \fIsize\fR
1432 with
1433 \fIcommitted\fR/decommited memory as indicated, on behalf of arena
1434 \fIarena_ind\fR\&. This function may be called to destroy retained extents during arena destruction (see
1435 arena\&.<i>\&.destroy)\&.
1436 .HP \w'typedef\ bool\ (extent_commit_t)('u
1437 .BI "typedef bool (extent_commit_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "addr" ", size_t\ " "size" ", size_t\ " "offset" ", size_t\ " "length" ", unsigned\ " "arena_ind" ");"
1438 .sp
1439 .if n \{\
1440 .RS 4
1441 .\}
1442 .nf
1443 .fi
1444 .if n \{\
1445 .RE
1446 .\}
1447 .sp
1448 An extent commit function conforms to the
1449 \fBextent_commit_t\fR
1450 type and commits zeroed physical memory to back pages within an extent at given
1451 \fIaddr\fR
1452 and
1453 \fIsize\fR
1454 at
1455 \fIoffset\fR
1456 bytes, extending for
1457 \fIlength\fR
1458 on behalf of arena
1459 \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\&.
1460 .HP \w'typedef\ bool\ (extent_decommit_t)('u
1461 .BI "typedef bool (extent_decommit_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "addr" ", size_t\ " "size" ", size_t\ " "offset" ", size_t\ " "length" ", unsigned\ " "arena_ind" ");"
1462 .sp
1463 .if n \{\
1464 .RS 4
1465 .\}
1466 .nf
1467 .fi
1468 .if n \{\
1469 .RE
1470 .\}
1471 .sp
1472 An extent decommit function conforms to the
1473 \fBextent_decommit_t\fR
1474 type and decommits any physical memory that is backing pages within an extent at given
1475 \fIaddr\fR
1476 and
1477 \fIsize\fR
1478 at
1479 \fIoffset\fR
1480 bytes, extending for
1481 \fIlength\fR
1482 on behalf of arena
1483 \fIarena_ind\fR, returning false upon success, in which case the pages will be committed via the extent 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\&.
1484 .HP \w'typedef\ bool\ (extent_purge_t)('u
1485 .BI "typedef bool (extent_purge_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "addr" ", size_t\ " "size" ", size_t\ " "offset" ", size_t\ " "length" ", unsigned\ " "arena_ind" ");"
1486 .sp
1487 .if n \{\
1488 .RS 4
1489 .\}
1490 .nf
1491 .fi
1492 .if n \{\
1493 .RE
1494 .\}
1495 .sp
1496 An extent purge function conforms to the
1497 \fBextent_purge_t\fR
1498 type and discards physical pages within the virtual memory mapping associated with an extent at given
1499 \fIaddr\fR
1500 and
1501 \fIsize\fR
1502 at
1503 \fIoffset\fR
1504 bytes, extending for
1505 \fIlength\fR
1506 on behalf of arena
1507 \fIarena_ind\fR\&. A lazy extent purge function (e\&.g\&. implemented via
1508 madvise(\fI\&.\&.\&.\fR\fI\fBMADV_FREE\fR\fR)) can delay purging indefinitely and leave the pages within the purged virtual memory range in an indeterminite state, whereas a forced extent purge function immediately purges, and the pages within the virtual memory range will be zero\-filled the next time they are accessed\&. If the function returns true, this indicates failure to purge\&.
1509 .HP \w'typedef\ bool\ (extent_split_t)('u
1510 .BI "typedef bool (extent_split_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "addr" ", size_t\ " "size" ", size_t\ " "size_a" ", size_t\ " "size_b" ", bool\ " "committed" ", unsigned\ " "arena_ind" ");"
1511 .sp
1512 .if n \{\
1513 .RS 4
1514 .\}
1515 .nf
1516 .fi
1517 .if n \{\
1518 .RE
1519 .\}
1520 .sp
1521 An extent split function conforms to the
1522 \fBextent_split_t\fR
1523 type and optionally splits an extent at given
1524 \fIaddr\fR
1525 and
1526 \fIsize\fR
1527 into two adjacent extents, the first of
1528 \fIsize_a\fR
1529 bytes, and the second of
1530 \fIsize_b\fR
1531 bytes, operating on
1532 \fIcommitted\fR/decommitted memory as indicated, on behalf of arena
1533 \fIarena_ind\fR, returning false upon success\&. If the function returns true, this indicates that the extent remains unsplit and therefore should continue to be operated on as a whole\&.
1534 .HP \w'typedef\ bool\ (extent_merge_t)('u
1535 .BI "typedef bool (extent_merge_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "addr_a" ", size_t\ " "size_a" ", void\ *" "addr_b" ", size_t\ " "size_b" ", bool\ " "committed" ", unsigned\ " "arena_ind" ");"
1536 .sp
1537 .if n \{\
1538 .RS 4
1539 .\}
1540 .nf
1541 .fi
1542 .if n \{\
1543 .RE
1544 .\}
1545 .sp
1546 An extent merge function conforms to the
1547 \fBextent_merge_t\fR
1548 type and optionally merges adjacent extents, at given
1549 \fIaddr_a\fR
1550 and
1551 \fIsize_a\fR
1552 with given
1553 \fIaddr_b\fR
1554 and
1555 \fIsize_b\fR
1556 into one contiguous extent, operating on
1557 \fIcommitted\fR/decommitted memory as indicated, on behalf of arena
1558 \fIarena_ind\fR, returning false upon success\&. If the function returns true, this indicates that the extents remain distinct mappings and therefore should continue to be operated on independently\&.
1559 .RE
1560 .PP
1561 arenas\&.narenas (\fBunsigned\fR) r\-
1562 .RS 4
1563 Current limit on number of arenas\&.
1564 .RE
1565 .PP
1566 arenas\&.dirty_decay_ms (\fBssize_t\fR) rw
1567 .RS 4
1568 Current default per\-arena approximate time in milliseconds from the creation of a set of unused dirty pages until an equivalent set of unused dirty pages is purged and/or reused, used to initialize
1569 arena\&.<i>\&.dirty_decay_ms
1570 during arena creation\&. See
1571 opt\&.dirty_decay_ms
1572 for additional information\&.
1573 .RE
1574 .PP
1575 arenas\&.muzzy_decay_ms (\fBssize_t\fR) rw
1576 .RS 4
1577 Current default per\-arena approximate time in milliseconds from the creation of a set of unused muzzy pages until an equivalent set of unused muzzy pages is purged and/or reused, used to initialize
1578 arena\&.<i>\&.muzzy_decay_ms
1579 during arena creation\&. See
1580 opt\&.muzzy_decay_ms
1581 for additional information\&.
1582 .RE
1583 .PP
1584 arenas\&.quantum (\fBsize_t\fR) r\-
1585 .RS 4
1586 Quantum size\&.
1587 .RE
1588 .PP
1589 arenas\&.page (\fBsize_t\fR) r\-
1590 .RS 4
1591 Page size\&.
1592 .RE
1593 .PP
1594 arenas\&.tcache_max (\fBsize_t\fR) r\-
1595 .RS 4
1596 Maximum thread\-cached size class\&.
1597 .RE
1598 .PP
1599 arenas\&.nbins (\fBunsigned\fR) r\-
1600 .RS 4
1601 Number of bin size classes\&.
1602 .RE
1603 .PP
1604 arenas\&.nhbins (\fBunsigned\fR) r\-
1605 .RS 4
1606 Total number of thread cache bin size classes\&.
1607 .RE
1608 .PP
1609 arenas\&.bin\&.<i>\&.size (\fBsize_t\fR) r\-
1610 .RS 4
1611 Maximum size supported by size class\&.
1612 .RE
1613 .PP
1614 arenas\&.bin\&.<i>\&.nregs (\fBuint32_t\fR) r\-
1615 .RS 4
1616 Number of regions per slab\&.
1617 .RE
1618 .PP
1619 arenas\&.bin\&.<i>\&.slab_size (\fBsize_t\fR) r\-
1620 .RS 4
1621 Number of bytes per slab\&.
1622 .RE
1623 .PP
1624 arenas\&.nlextents (\fBunsigned\fR) r\-
1625 .RS 4
1626 Total number of large size classes\&.
1627 .RE
1628 .PP
1629 arenas\&.lextent\&.<i>\&.size (\fBsize_t\fR) r\-
1630 .RS 4
1631 Maximum size supported by this large size class\&.
1632 .RE
1633 .PP
1634 arenas\&.create (\fBunsigned\fR, \fBextent_hooks_t *\fR) rw
1635 .RS 4
1636 Explicitly create a new arena outside the range of automatically managed arenas, with optionally specified extent hooks, and return the new arena index\&.
1637 .RE
1638 .PP
1639 arenas\&.lookup (\fBunsigned\fR, \fBvoid*\fR) rw
1640 .RS 4
1641 Index of the arena to which an allocation belongs to\&.
1642 .RE
1643 .PP
1644 prof\&.thread_active_init (\fBbool\fR) rw [\fB\-\-enable\-prof\fR]
1645 .RS 4
1646 Control the initial setting for
1647 thread\&.prof\&.active
1648 in newly created threads\&. See the
1649 opt\&.prof_thread_active_init
1650 option for additional information\&.
1651 .RE
1652 .PP
1653 prof\&.active (\fBbool\fR) rw [\fB\-\-enable\-prof\fR]
1654 .RS 4
1655 Control whether sampling is currently active\&. See the
1656 opt\&.prof_active
1657 option for additional information, as well as the interrelated
1658 thread\&.prof\&.active
1659 mallctl\&.
1660 .RE
1661 .PP
1662 prof\&.dump (\fBconst char *\fR) \-w [\fB\-\-enable\-prof\fR]
1663 .RS 4
1664 Dump a memory profile to the specified file, or if NULL is specified, to a file according to the pattern
1665 <prefix>\&.<pid>\&.<seq>\&.m<mseq>\&.heap, where
1666 <prefix>
1667 is controlled by the
1668 opt\&.prof_prefix
1669 option\&.
1670 .RE
1671 .PP
1672 prof\&.gdump (\fBbool\fR) rw [\fB\-\-enable\-prof\fR]
1673 .RS 4
1674 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
1675 <prefix>\&.<pid>\&.<seq>\&.u<useq>\&.heap, where
1676 <prefix>
1677 is controlled by the
1678 opt\&.prof_prefix
1679 option\&.
1680 .RE
1681 .PP
1682 prof\&.reset (\fBsize_t\fR) \-w [\fB\-\-enable\-prof\fR]
1683 .RS 4
1684 Reset all memory profile statistics, and optionally update the sample rate (see
1685 opt\&.lg_prof_sample
1686 and
1687 prof\&.lg_sample)\&.
1688 .RE
1689 .PP
1690 prof\&.lg_sample (\fBsize_t\fR) r\- [\fB\-\-enable\-prof\fR]
1691 .RS 4
1692 Get the current sample rate (see
1693 opt\&.lg_prof_sample)\&.
1694 .RE
1695 .PP
1696 prof\&.interval (\fBuint64_t\fR) r\- [\fB\-\-enable\-prof\fR]
1697 .RS 4
1698 Average number of bytes allocated between interval\-based profile dumps\&. See the
1699 opt\&.lg_prof_interval
1700 option for additional information\&.
1701 .RE
1702 .PP
1703 stats\&.allocated (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1704 .RS 4
1705 Total number of bytes allocated by the application\&.
1706 .RE
1707 .PP
1708 stats\&.active (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1709 .RS 4
1710 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
1711 stats\&.allocated\&. This does not include
1712 stats\&.arenas\&.<i>\&.pdirty,
1713 stats\&.arenas\&.<i>\&.pmuzzy, nor pages entirely devoted to allocator metadata\&.
1714 .RE
1715 .PP
1716 stats\&.metadata (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1717 .RS 4
1718 Total number of bytes dedicated to metadata, which comprise base allocations used for bootstrap\-sensitive allocator metadata structures (see
1719 stats\&.arenas\&.<i>\&.base) and internal allocations (see
1720 stats\&.arenas\&.<i>\&.internal)\&. Transparent huge page (enabled with
1721 opt\&.metadata_thp) usage is not considered\&.
1722 .RE
1723 .PP
1724 stats\&.metadata_thp (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1725 .RS 4
1726 Number of transparent huge pages (THP) used for metadata\&. See
1727 stats\&.metadata
1728 and
1729 opt\&.metadata_thp) for details\&.
1730 .RE
1731 .PP
1732 stats\&.resident (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1733 .RS 4
1734 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
1735 stats\&.active\&.
1736 .RE
1737 .PP
1738 stats\&.mapped (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1739 .RS 4
1740 Total number of bytes in active extents mapped by the allocator\&. This is larger than
1741 stats\&.active\&. This does not include inactive extents, even those that contain unused dirty pages, which means that there is no strict ordering between this and
1742 stats\&.resident\&.
1743 .RE
1744 .PP
1745 stats\&.retained (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1746 .RS 4
1747 Total number of bytes in virtual memory mappings that were retained rather than being returned to the operating system via e\&.g\&.
1748 \fBmunmap\fR(2)
1749 or similar\&. Retained virtual memory is typically untouched, decommitted, or purged, so it has no strongly associated physical memory (see
1750 extent hooks
1751 for details)\&. Retained memory is excluded from mapped memory statistics, e\&.g\&.
1752 stats\&.mapped\&.
1753 .RE
1754 .PP
1755 stats\&.background_thread\&.num_threads (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1756 .RS 4
1757 Number of
1758 background threads
1759 running currently\&.
1760 .RE
1761 .PP
1762 stats\&.background_thread\&.num_runs (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1763 .RS 4
1764 Total number of runs from all
1765 background threads\&.
1766 .RE
1767 .PP
1768 stats\&.background_thread\&.run_interval (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1769 .RS 4
1770 Average run interval in nanoseconds of
1771 background threads\&.
1772 .RE
1773 .PP
1774 stats\&.mutexes\&.ctl\&.{counter}; (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
1775 .RS 4
1776 Statistics on
1777 \fIctl\fR
1778 mutex (global scope; mallctl related)\&.
1779 {counter}
1780 is one of the counters below:
1781 .PP
1782 .RS 4
1783 \fInum_ops\fR
1784 (\fBuint64_t\fR): Total number of lock acquisition operations on this mutex\&.
1785 .sp
1786 \fInum_spin_acq\fR
1787 (\fBuint64_t\fR): Number of times the mutex was spin\-acquired\&. When the mutex is currently locked and cannot be acquired immediately, a short period of spin\-retry within jemalloc will be performed\&. Acquired through spin generally means the contention was lightweight and not causing context switches\&.
1788 .sp
1789 \fInum_wait\fR
1790 (\fBuint64_t\fR): Number of times the mutex was wait\-acquired, which means the mutex contention was not solved by spin\-retry, and blocking operation was likely involved in order to acquire the mutex\&. This event generally implies higher cost / longer delay, and should be investigated if it happens often\&.
1791 .sp
1792 \fImax_wait_time\fR
1793 (\fBuint64_t\fR): Maximum length of time in nanoseconds spent on a single wait\-acquired lock operation\&. Note that to avoid profiling overhead on the common path, this does not consider spin\-acquired cases\&.
1794 .sp
1795 \fItotal_wait_time\fR
1796 (\fBuint64_t\fR): Cumulative time in nanoseconds spent on wait\-acquired lock operations\&. Similarly, spin\-acquired cases are not considered\&.
1797 .sp
1798 \fImax_num_thds\fR
1799 (\fBuint32_t\fR): Maximum number of threads waiting on this mutex simultaneously\&. Similarly, spin\-acquired cases are not considered\&.
1800 .sp
1801 \fInum_owner_switch\fR
1802 (\fBuint64_t\fR): Number of times the current mutex owner is different from the previous one\&. This event does not generally imply an issue; rather it is an indicator of how often the protected data are accessed by different threads\&.
1803 .RE
1804 .RE
1805 .PP
1806 stats\&.mutexes\&.background_thread\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
1807 .RS 4
1808 Statistics on
1809 \fIbackground_thread\fR
1810 mutex (global scope;
1811 background_thread
1812 related)\&.
1813 {counter}
1814 is one of the counters in
1815 mutex profiling counters\&.
1816 .RE
1817 .PP
1818 stats\&.mutexes\&.prof\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
1819 .RS 4
1820 Statistics on
1821 \fIprof\fR
1822 mutex (global scope; profiling related)\&.
1823 {counter}
1824 is one of the counters in
1825 mutex profiling counters\&.
1826 .RE
1827 .PP
1828 stats\&.mutexes\&.reset (\fBvoid\fR) \-\- [\fB\-\-enable\-stats\fR]
1829 .RS 4
1830 Reset all mutex profile statistics, including global mutexes, arena mutexes and bin mutexes\&.
1831 .RE
1832 .PP
1833 stats\&.arenas\&.<i>\&.dss (\fBconst char *\fR) r\-
1834 .RS 4
1835 dss (\fBsbrk\fR(2)) allocation precedence as related to
1836 \fBmmap\fR(2)
1837 allocation\&. See
1838 opt\&.dss
1839 for details\&.
1840 .RE
1841 .PP
1842 stats\&.arenas\&.<i>\&.dirty_decay_ms (\fBssize_t\fR) r\-
1843 .RS 4
1844 Approximate time in milliseconds from the creation of a set of unused dirty pages until an equivalent set of unused dirty pages is purged and/or reused\&. See
1845 opt\&.dirty_decay_ms
1846 for details\&.
1847 .RE
1848 .PP
1849 stats\&.arenas\&.<i>\&.muzzy_decay_ms (\fBssize_t\fR) r\-
1850 .RS 4
1851 Approximate time in milliseconds from the creation of a set of unused muzzy pages until an equivalent set of unused muzzy pages is purged and/or reused\&. See
1852 opt\&.muzzy_decay_ms
1853 for details\&.
1854 .RE
1855 .PP
1856 stats\&.arenas\&.<i>\&.nthreads (\fBunsigned\fR) r\-
1857 .RS 4
1858 Number of threads currently assigned to arena\&.
1859 .RE
1860 .PP
1861 stats\&.arenas\&.<i>\&.uptime (\fBuint64_t\fR) r\-
1862 .RS 4
1863 Time elapsed (in nanoseconds) since the arena was created\&. If <i> equals
1864 \fB0\fR
1865 or
1866 \fBMALLCTL_ARENAS_ALL\fR, this is the uptime since malloc initialization\&.
1867 .RE
1868 .PP
1869 stats\&.arenas\&.<i>\&.pactive (\fBsize_t\fR) r\-
1870 .RS 4
1871 Number of pages in active extents\&.
1872 .RE
1873 .PP
1874 stats\&.arenas\&.<i>\&.pdirty (\fBsize_t\fR) r\-
1875 .RS 4
1876 Number of pages within unused extents that are potentially dirty, and for which
1877 madvise()
1878 or similar has not been called\&. See
1879 opt\&.dirty_decay_ms
1880 for a description of dirty pages\&.
1881 .RE
1882 .PP
1883 stats\&.arenas\&.<i>\&.pmuzzy (\fBsize_t\fR) r\-
1884 .RS 4
1885 Number of pages within unused extents that are muzzy\&. See
1886 opt\&.muzzy_decay_ms
1887 for a description of muzzy pages\&.
1888 .RE
1889 .PP
1890 stats\&.arenas\&.<i>\&.mapped (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1891 .RS 4
1892 Number of mapped bytes\&.
1893 .RE
1894 .PP
1895 stats\&.arenas\&.<i>\&.retained (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1896 .RS 4
1897 Number of retained bytes\&. See
1898 stats\&.retained
1899 for details\&.
1900 .RE
1901 .PP
1902 stats\&.arenas\&.<i>\&.extent_avail (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1903 .RS 4
1904 Number of allocated (but unused) extent structs in this arena\&.
1905 .RE
1906 .PP
1907 stats\&.arenas\&.<i>\&.base (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1908 .RS 4
1909 Number of bytes dedicated to bootstrap\-sensitive allocator metadata structures\&.
1910 .RE
1911 .PP
1912 stats\&.arenas\&.<i>\&.internal (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1913 .RS 4
1914 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\&.
1915 .RE
1916 .PP
1917 stats\&.arenas\&.<i>\&.metadata_thp (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1918 .RS 4
1919 Number of transparent huge pages (THP) used for metadata\&. See
1920 opt\&.metadata_thp
1921 for details\&.
1922 .RE
1923 .PP
1924 stats\&.arenas\&.<i>\&.resident (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1925 .RS 4
1926 Maximum number of bytes in physically resident data pages mapped by the arena, 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\&.
1927 .RE
1928 .PP
1929 stats\&.arenas\&.<i>\&.dirty_npurge (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1930 .RS 4
1931 Number of dirty page purge sweeps performed\&.
1932 .RE
1933 .PP
1934 stats\&.arenas\&.<i>\&.dirty_nmadvise (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1935 .RS 4
1936 Number of
1937 madvise()
1938 or similar calls made to purge dirty pages\&.
1939 .RE
1940 .PP
1941 stats\&.arenas\&.<i>\&.dirty_purged (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1942 .RS 4
1943 Number of dirty pages purged\&.
1944 .RE
1945 .PP
1946 stats\&.arenas\&.<i>\&.muzzy_npurge (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1947 .RS 4
1948 Number of muzzy page purge sweeps performed\&.
1949 .RE
1950 .PP
1951 stats\&.arenas\&.<i>\&.muzzy_nmadvise (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1952 .RS 4
1953 Number of
1954 madvise()
1955 or similar calls made to purge muzzy pages\&.
1956 .RE
1957 .PP
1958 stats\&.arenas\&.<i>\&.muzzy_purged (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1959 .RS 4
1960 Number of muzzy pages purged\&.
1961 .RE
1962 .PP
1963 stats\&.arenas\&.<i>\&.small\&.allocated (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1964 .RS 4
1965 Number of bytes currently allocated by small objects\&.
1966 .RE
1967 .PP
1968 stats\&.arenas\&.<i>\&.small\&.nmalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1969 .RS 4
1970 Cumulative number of times a small allocation was requested from the arena\*(Aqs bins, whether to fill the relevant tcache if
1971 opt\&.tcache
1972 is enabled, or to directly satisfy an allocation request otherwise\&.
1973 .RE
1974 .PP
1975 stats\&.arenas\&.<i>\&.small\&.ndalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1976 .RS 4
1977 Cumulative number of times a small allocation was returned to the arena\*(Aqs bins, whether to flush the relevant tcache if
1978 opt\&.tcache
1979 is enabled, or to directly deallocate an allocation otherwise\&.
1980 .RE
1981 .PP
1982 stats\&.arenas\&.<i>\&.small\&.nrequests (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1983 .RS 4
1984 Cumulative number of allocation requests satisfied by all bin size classes\&.
1985 .RE
1986 .PP
1987 stats\&.arenas\&.<i>\&.small\&.nfills (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1988 .RS 4
1989 Cumulative number of tcache fills by all small size classes\&.
1990 .RE
1991 .PP
1992 stats\&.arenas\&.<i>\&.small\&.nflushes (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1993 .RS 4
1994 Cumulative number of tcache flushes by all small size classes\&.
1995 .RE
1996 .PP
1997 stats\&.arenas\&.<i>\&.large\&.allocated (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1998 .RS 4
1999 Number of bytes currently allocated by large objects\&.
2000 .RE
2001 .PP
2002 stats\&.arenas\&.<i>\&.large\&.nmalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
2003 .RS 4
2004 Cumulative number of times a large extent was allocated from the arena, whether to fill the relevant tcache if
2005 opt\&.tcache
2006 is enabled and the size class is within the range being cached, or to directly satisfy an allocation request otherwise\&.
2007 .RE
2008 .PP
2009 stats\&.arenas\&.<i>\&.large\&.ndalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
2010 .RS 4
2011 Cumulative number of times a large extent was returned to the arena, whether to flush the relevant tcache if
2012 opt\&.tcache
2013 is enabled and the size class is within the range being cached, or to directly deallocate an allocation otherwise\&.
2014 .RE
2015 .PP
2016 stats\&.arenas\&.<i>\&.large\&.nrequests (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
2017 .RS 4
2018 Cumulative number of allocation requests satisfied by all large size classes\&.
2019 .RE
2020 .PP
2021 stats\&.arenas\&.<i>\&.large\&.nfills (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
2022 .RS 4
2023 Cumulative number of tcache fills by all large size classes\&.
2024 .RE
2025 .PP
2026 stats\&.arenas\&.<i>\&.large\&.nflushes (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
2027 .RS 4
2028 Cumulative number of tcache flushes by all large size classes\&.
2029 .RE
2030 .PP
2031 stats\&.arenas\&.<i>\&.bins\&.<j>\&.nmalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
2032 .RS 4
2033 Cumulative number of times a bin region of the corresponding size class was allocated from the arena, whether to fill the relevant tcache if
2034 opt\&.tcache
2035 is enabled, or to directly satisfy an allocation request otherwise\&.
2036 .RE
2037 .PP
2038 stats\&.arenas\&.<i>\&.bins\&.<j>\&.ndalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
2039 .RS 4
2040 Cumulative number of times a bin region of the corresponding size class was returned to the arena, whether to flush the relevant tcache if
2041 opt\&.tcache
2042 is enabled, or to directly deallocate an allocation otherwise\&.
2043 .RE
2044 .PP
2045 stats\&.arenas\&.<i>\&.bins\&.<j>\&.nrequests (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
2046 .RS 4
2047 Cumulative number of allocation requests satisfied by bin regions of the corresponding size class\&.
2048 .RE
2049 .PP
2050 stats\&.arenas\&.<i>\&.bins\&.<j>\&.curregs (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
2051 .RS 4
2052 Current number of regions for this size class\&.
2053 .RE
2054 .PP
2055 stats\&.arenas\&.<i>\&.bins\&.<j>\&.nfills (\fBuint64_t\fR) r\-
2056 .RS 4
2057 Cumulative number of tcache fills\&.
2058 .RE
2059 .PP
2060 stats\&.arenas\&.<i>\&.bins\&.<j>\&.nflushes (\fBuint64_t\fR) r\-
2061 .RS 4
2062 Cumulative number of tcache flushes\&.
2063 .RE
2064 .PP
2065 stats\&.arenas\&.<i>\&.bins\&.<j>\&.nslabs (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
2066 .RS 4
2067 Cumulative number of slabs created\&.
2068 .RE
2069 .PP
2070 stats\&.arenas\&.<i>\&.bins\&.<j>\&.nreslabs (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
2071 .RS 4
2072 Cumulative number of times the current slab from which to allocate changed\&.
2073 .RE
2074 .PP
2075 stats\&.arenas\&.<i>\&.bins\&.<j>\&.curslabs (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
2076 .RS 4
2077 Current number of slabs\&.
2078 .RE
2079 .PP
2080 stats\&.arenas\&.<i>\&.bins\&.<j>\&.nonfull_slabs (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
2081 .RS 4
2082 Current number of nonfull slabs\&.
2083 .RE
2084 .PP
2085 stats\&.arenas\&.<i>\&.bins\&.<j>\&.mutex\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
2086 .RS 4
2087 Statistics on
2088 \fIarena\&.<i>\&.bins\&.<j>\fR
2089 mutex (arena bin scope; bin operation related)\&.
2090 {counter}
2091 is one of the counters in
2092 mutex profiling counters\&.
2093 .RE
2094 .PP
2095 stats\&.arenas\&.<i>\&.extents\&.<j>\&.n{extent_type} (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
2096 .RS 4
2097 Number of extents of the given type in this arena in the bucket corresponding to page size index <j>\&. The extent type is one of dirty, muzzy, or retained\&.
2098 .RE
2099 .PP
2100 stats\&.arenas\&.<i>\&.extents\&.<j>\&.{extent_type}_bytes (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
2101 .RS 4
2102 Sum of the bytes managed by extents of the given type in this arena in the bucket corresponding to page size index <j>\&. The extent type is one of dirty, muzzy, or retained\&.
2103 .RE
2104 .PP
2105 stats\&.arenas\&.<i>\&.lextents\&.<j>\&.nmalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
2106 .RS 4
2107 Cumulative number of times a large extent of the corresponding size class was allocated from the arena, whether to fill the relevant tcache if
2108 opt\&.tcache
2109 is enabled and the size class is within the range being cached, or to directly satisfy an allocation request otherwise\&.
2110 .RE
2111 .PP
2112 stats\&.arenas\&.<i>\&.lextents\&.<j>\&.ndalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
2113 .RS 4
2114 Cumulative number of times a large extent of the corresponding size class was returned to the arena, whether to flush the relevant tcache if
2115 opt\&.tcache
2116 is enabled and the size class is within the range being cached, or to directly deallocate an allocation otherwise\&.
2117 .RE
2118 .PP
2119 stats\&.arenas\&.<i>\&.lextents\&.<j>\&.nrequests (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
2120 .RS 4
2121 Cumulative number of allocation requests satisfied by large extents of the corresponding size class\&.
2122 .RE
2123 .PP
2124 stats\&.arenas\&.<i>\&.lextents\&.<j>\&.curlextents (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
2125 .RS 4
2126 Current number of large allocations for this size class\&.
2127 .RE
2128 .PP
2129 stats\&.arenas\&.<i>\&.mutexes\&.large\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
2130 .RS 4
2131 Statistics on
2132 \fIarena\&.<i>\&.large\fR
2133 mutex (arena scope; large allocation related)\&.
2134 {counter}
2135 is one of the counters in
2136 mutex profiling counters\&.
2137 .RE
2138 .PP
2139 stats\&.arenas\&.<i>\&.mutexes\&.extent_avail\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
2140 .RS 4
2141 Statistics on
2142 \fIarena\&.<i>\&.extent_avail \fR
2143 mutex (arena scope; extent avail related)\&.
2144 {counter}
2145 is one of the counters in
2146 mutex profiling counters\&.
2147 .RE
2148 .PP
2149 stats\&.arenas\&.<i>\&.mutexes\&.extents_dirty\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
2150 .RS 4
2151 Statistics on
2152 \fIarena\&.<i>\&.extents_dirty \fR
2153 mutex (arena scope; dirty extents related)\&.
2154 {counter}
2155 is one of the counters in
2156 mutex profiling counters\&.
2157 .RE
2158 .PP
2159 stats\&.arenas\&.<i>\&.mutexes\&.extents_muzzy\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
2160 .RS 4
2161 Statistics on
2162 \fIarena\&.<i>\&.extents_muzzy \fR
2163 mutex (arena scope; muzzy extents related)\&.
2164 {counter}
2165 is one of the counters in
2166 mutex profiling counters\&.
2167 .RE
2168 .PP
2169 stats\&.arenas\&.<i>\&.mutexes\&.extents_retained\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
2170 .RS 4
2171 Statistics on
2172 \fIarena\&.<i>\&.extents_retained \fR
2173 mutex (arena scope; retained extents related)\&.
2174 {counter}
2175 is one of the counters in
2176 mutex profiling counters\&.
2177 .RE
2178 .PP
2179 stats\&.arenas\&.<i>\&.mutexes\&.decay_dirty\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
2180 .RS 4
2181 Statistics on
2182 \fIarena\&.<i>\&.decay_dirty \fR
2183 mutex (arena scope; decay for dirty pages related)\&.
2184 {counter}
2185 is one of the counters in
2186 mutex profiling counters\&.
2187 .RE
2188 .PP
2189 stats\&.arenas\&.<i>\&.mutexes\&.decay_muzzy\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
2190 .RS 4
2191 Statistics on
2192 \fIarena\&.<i>\&.decay_muzzy \fR
2193 mutex (arena scope; decay for muzzy pages related)\&.
2194 {counter}
2195 is one of the counters in
2196 mutex profiling counters\&.
2197 .RE
2198 .PP
2199 stats\&.arenas\&.<i>\&.mutexes\&.base\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
2200 .RS 4
2201 Statistics on
2202 \fIarena\&.<i>\&.base\fR
2203 mutex (arena scope; base allocator related)\&.
2204 {counter}
2205 is one of the counters in
2206 mutex profiling counters\&.
2207 .RE
2208 .PP
2209 stats\&.arenas\&.<i>\&.mutexes\&.tcache_list\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
2210 .RS 4
2211 Statistics on
2212 \fIarena\&.<i>\&.tcache_list\fR
2213 mutex (arena scope; tcache to arena association related)\&. This mutex is expected to be accessed less often\&.
2214 {counter}
2215 is one of the counters in
2216 mutex profiling counters\&.
2217 .RE
2218 .SH "HEAP PROFILE FORMAT"
2219 .PP
2220 Although the heap profiling functionality was originally designed to be compatible with the
2221 \fBpprof\fR
2222 command that is developed as part of the
2223 \m[blue]\fBgperftools package\fR\m[]\&\s-2\u[3]\d\s+2, the addition of per thread heap profiling functionality required a different heap profile format\&. The
2224 \fBjeprof\fR
2225 command is derived from
2226 \fBpprof\fR, with enhancements to support the heap profile format described here\&.
2227 .PP
2228 In the following hypothetical heap profile,
2229 \fB[\&.\&.\&.]\fR
2230 indicates elision for the sake of compactness\&.
2231 .sp
2232 .if n \{\
2233 .RS 4
2234 .\}
2235 .nf
2236 heap_v2/524288
2237   t*: 28106: 56637512 [0: 0]
2238   [\&.\&.\&.]
2239   t3: 352: 16777344 [0: 0]
2240   [\&.\&.\&.]
2241   t99: 17754: 29341640 [0: 0]
2242   [\&.\&.\&.]
2243 @ 0x5f86da8 0x5f5a1dc [\&.\&.\&.] 0x29e4d4e 0xa200316 0xabb2988 [\&.\&.\&.]
2244   t*: 13: 6688 [0: 0]
2245   t3: 12: 6496 [0: ]
2246   t99: 1: 192 [0: 0]
2247 [\&.\&.\&.]
2248
2249 MAPPED_LIBRARIES:
2250 [\&.\&.\&.]
2251 .fi
2252 .if n \{\
2253 .RE
2254 .\}
2255 .sp
2256 The following matches the above heap profile, but most tokens are replaced with
2257 \fB<description>\fR
2258 to indicate descriptions of the corresponding fields\&.
2259 .sp
2260 .if n \{\
2261 .RS 4
2262 .\}
2263 .nf
2264 <heap_profile_format_version>/<mean_sample_interval>
2265   <aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
2266   [\&.\&.\&.]
2267   <thread_3_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>]
2268   [\&.\&.\&.]
2269   <thread_99_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>]
2270   [\&.\&.\&.]
2271 @ <top_frame> <frame> [\&.\&.\&.] <frame> <frame> <frame> [\&.\&.\&.]
2272   <backtrace_aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
2273   <backtrace_thread_3>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
2274   <backtrace_thread_99>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
2275 [\&.\&.\&.]
2276
2277 MAPPED_LIBRARIES:
2278 </proc/<pid>/maps>
2279 .fi
2280 .if n \{\
2281 .RE
2282 .\}
2283 .SH "DEBUGGING MALLOC PROBLEMS"
2284 .PP
2285 When debugging, it is a good idea to configure/build jemalloc with the
2286 \fB\-\-enable\-debug\fR
2287 and
2288 \fB\-\-enable\-fill\fR
2289 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\&.
2290 .PP
2291 Programs often accidentally depend on
2292 \(lquninitialized\(rq
2293 memory actually being filled with zero bytes\&. Junk filling (see the
2294 opt\&.junk
2295 option) tends to expose such bugs in the form of obviously incorrect results and/or coredumps\&. Conversely, zero filling (see the
2296 opt\&.zero
2297 option) eliminates the symptoms of such bugs\&. Between these two options, it is usually possible to quickly detect, diagnose, and eliminate such bugs\&.
2298 .PP
2299 This implementation does not provide much detail about the problems it detects, because the performance impact for storing such information would be prohibitive\&.
2300 .SH "DIAGNOSTIC MESSAGES"
2301 .PP
2302 If any of the memory allocation/deallocation functions detect an error or warning condition, a message will be printed to file descriptor
2303 \fBSTDERR_FILENO\fR\&. Errors will result in the process dumping core\&. If the
2304 opt\&.abort
2305 option is set, most warnings are treated as errors\&.
2306 .PP
2307 The
2308 \fImalloc_message\fR
2309 variable allows the programmer to override the function which emits the text strings forming the errors and warnings if for some reason the
2310 \fBSTDERR_FILENO\fR
2311 file descriptor is not suitable for this\&.
2312 malloc_message()
2313 takes the
2314 \fIcbopaque\fR
2315 pointer argument that is
2316 \fBNULL\fR
2317 unless overridden by the arguments in a call to
2318 malloc_stats_print(), 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\&.
2319 .PP
2320 All messages are prefixed by
2321 \(lq<jemalloc>: \(rq\&.
2322 .SH "RETURN VALUES"
2323 .SS "Standard API"
2324 .PP
2325 The
2326 malloc()
2327 and
2328 calloc()
2329 functions return a pointer to the allocated memory if successful; otherwise a
2330 \fBNULL\fR
2331 pointer is returned and
2332 \fIerrno\fR
2333 is set to
2334 ENOMEM\&.
2335 .PP
2336 The
2337 posix_memalign()
2338 function returns the value 0 if successful; otherwise it returns an error value\&. The
2339 posix_memalign()
2340 function will fail if:
2341 .PP
2342 EINVAL
2343 .RS 4
2344 The
2345 \fIalignment\fR
2346 parameter is not a power of 2 at least as large as
2347 sizeof(\fBvoid *\fR)\&.
2348 .RE
2349 .PP
2350 ENOMEM
2351 .RS 4
2352 Memory allocation error\&.
2353 .RE
2354 .PP
2355 The
2356 aligned_alloc()
2357 function returns a pointer to the allocated memory if successful; otherwise a
2358 \fBNULL\fR
2359 pointer is returned and
2360 \fIerrno\fR
2361 is set\&. The
2362 aligned_alloc()
2363 function will fail if:
2364 .PP
2365 EINVAL
2366 .RS 4
2367 The
2368 \fIalignment\fR
2369 parameter is not a power of 2\&.
2370 .RE
2371 .PP
2372 ENOMEM
2373 .RS 4
2374 Memory allocation error\&.
2375 .RE
2376 .PP
2377 The
2378 realloc()
2379 function returns a pointer, possibly identical to
2380 \fIptr\fR, to the allocated memory if successful; otherwise a
2381 \fBNULL\fR
2382 pointer is returned, and
2383 \fIerrno\fR
2384 is set to
2385 ENOMEM
2386 if the error was the result of an allocation failure\&. The
2387 realloc()
2388 function always leaves the original buffer intact when an error occurs\&.
2389 .PP
2390 The
2391 free()
2392 function returns no value\&.
2393 .SS "Non\-standard API"
2394 .PP
2395 The
2396 mallocx()
2397 and
2398 rallocx()
2399 functions return a pointer to the allocated memory if successful; otherwise a
2400 \fBNULL\fR
2401 pointer is returned to indicate insufficient contiguous memory was available to service the allocation request\&.
2402 .PP
2403 The
2404 xallocx()
2405 function returns the real size of the resulting resized allocation pointed to by
2406 \fIptr\fR, which is a value less than
2407 \fIsize\fR
2408 if the allocation could not be adequately grown in place\&.
2409 .PP
2410 The
2411 sallocx()
2412 function returns the real size of the allocation pointed to by
2413 \fIptr\fR\&.
2414 .PP
2415 The
2416 nallocx()
2417 returns the real size that would result from a successful equivalent
2418 mallocx()
2419 function call, or zero if insufficient memory is available to perform the size computation\&.
2420 .PP
2421 The
2422 mallctl(),
2423 mallctlnametomib(), and
2424 mallctlbymib()
2425 functions return 0 on success; otherwise they return an error value\&. The functions will fail if:
2426 .PP
2427 EINVAL
2428 .RS 4
2429 \fInewp\fR
2430 is not
2431 \fBNULL\fR, and
2432 \fInewlen\fR
2433 is too large or too small\&. Alternatively,
2434 \fI*oldlenp\fR
2435 is too large or too small; in this case as much data as possible are read despite the error\&.
2436 .RE
2437 .PP
2438 ENOENT
2439 .RS 4
2440 \fIname\fR
2441 or
2442 \fImib\fR
2443 specifies an unknown/invalid value\&.
2444 .RE
2445 .PP
2446 EPERM
2447 .RS 4
2448 Attempt to read or write void value, or attempt to write read\-only value\&.
2449 .RE
2450 .PP
2451 EAGAIN
2452 .RS 4
2453 A memory allocation failure occurred\&.
2454 .RE
2455 .PP
2456 EFAULT
2457 .RS 4
2458 An interface with side effects failed in some way not directly related to
2459 mallctl*()
2460 read/write processing\&.
2461 .RE
2462 .PP
2463 The
2464 malloc_usable_size()
2465 function returns the usable size of the allocation pointed to by
2466 \fIptr\fR\&.
2467 .SH "ENVIRONMENT"
2468 .PP
2469 The following environment variable affects the execution of the allocation functions:
2470 .PP
2471 \fBMALLOC_CONF\fR
2472 .RS 4
2473 If the environment variable
2474 \fBMALLOC_CONF\fR
2475 is set, the characters it contains will be interpreted as options\&.
2476 .RE
2477 .SH "EXAMPLES"
2478 .PP
2479 To dump core whenever a problem occurs:
2480 .sp
2481 .if n \{\
2482 .RS 4
2483 .\}
2484 .nf
2485 ln \-s \*(Aqabort:true\*(Aq /etc/malloc\&.conf
2486 .fi
2487 .if n \{\
2488 .RE
2489 .\}
2490 .PP
2491 To specify in the source that only one arena should be automatically created:
2492 .sp
2493 .if n \{\
2494 .RS 4
2495 .\}
2496 .nf
2497 malloc_conf = "narenas:1";
2498 .fi
2499 .if n \{\
2500 .RE
2501 .\}
2502 .SH "SEE ALSO"
2503 .PP
2504 \fBmadvise\fR(2),
2505 \fBmmap\fR(2),
2506 \fBsbrk\fR(2),
2507 \fButrace\fR(2),
2508 \fBalloca\fR(3),
2509 \fBatexit\fR(3),
2510 \fBgetpagesize\fR(3)
2511 .SH "STANDARDS"
2512 .PP
2513 The
2514 malloc(),
2515 calloc(),
2516 realloc(), and
2517 free()
2518 functions conform to ISO/IEC 9899:1990 (\(lqISO C90\(rq)\&.
2519 .PP
2520 The
2521 posix_memalign()
2522 function conforms to IEEE Std 1003\&.1\-2001 (\(lqPOSIX\&.1\(rq)\&.
2523 .SH "HISTORY"
2524 .PP
2525 The
2526 malloc_usable_size()
2527 and
2528 posix_memalign()
2529 functions first appeared in FreeBSD 7\&.0\&.
2530 .PP
2531 The
2532 aligned_alloc(),
2533 malloc_stats_print(), and
2534 mallctl*()
2535 functions first appeared in FreeBSD 10\&.0\&.
2536 .PP
2537 The
2538 *allocx()
2539 functions first appeared in FreeBSD 11\&.0\&.
2540 .SH "AUTHOR"
2541 .PP
2542 \fBJason Evans\fR
2543 .RS 4
2544 .RE
2545 .SH "NOTES"
2546 .IP " 1." 4
2547 jemalloc website
2548 .RS 4
2549 \%http://jemalloc.net/
2550 .RE
2551 .IP " 2." 4
2552 JSON format
2553 .RS 4
2554 \%http://www.json.org/
2555 .RE
2556 .IP " 3." 4
2557 gperftools package
2558 .RS 4
2559 \%http://code.google.com/p/gperftools/
2560 .RE