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