3 .\" Author: Jason Evans
4 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
6 .\" Manual: User Manual
7 .\" Source: jemalloc 4.4.0-0-gf1f76357313e7dcad7262f17a48ff0a2e005fcdc
10 .TH "JEMALLOC" "3" "12/04/2016" "jemalloc 4.4.0-0-gf1f76357313e" "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 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 jemalloc \- general purpose memory allocation functions
34 This manual describes jemalloc 4\&.4\&.0\-0\-gf1f76357313e7dcad7262f17a48ff0a2e005fcdc\&. More information can be found at the
35 \m[blue]\fBjemalloc website\fR\m[]\&\s-2\u[1]\d\s+2\&.
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\-munmap\fR,
41 \fB\-\-enable\-stats\fR,
42 \fB\-\-enable\-tcache\fR,
43 \fB\-\-enable\-tls\fR,
44 \fB\-\-enable\-utrace\fR, and
45 \fB\-\-enable\-xmalloc\fR\&. Additionally,
46 \fB\-\-enable\-debug\fR
47 is enabled in development versions of FreeBSD (controlled by the
48 \fBMALLOC_PRODUCTION\fR
55 #include <malloc_np\&.h>
59 .HP \w'void\ *malloc('u
60 .BI "void *malloc(size_t\ " "size" ");"
61 .HP \w'void\ *calloc('u
62 .BI "void *calloc(size_t\ " "number" ", size_t\ " "size" ");"
63 .HP \w'int\ posix_memalign('u
64 .BI "int posix_memalign(void\ **" "ptr" ", size_t\ " "alignment" ", size_t\ " "size" ");"
65 .HP \w'void\ *aligned_alloc('u
66 .BI "void *aligned_alloc(size_t\ " "alignment" ", size_t\ " "size" ");"
67 .HP \w'void\ *realloc('u
68 .BI "void *realloc(void\ *" "ptr" ", size_t\ " "size" ");"
70 .BI "void free(void\ *" "ptr" ");"
71 .SS "Non\-standard API"
72 .HP \w'void\ *mallocx('u
73 .BI "void *mallocx(size_t\ " "size" ", int\ " "flags" ");"
74 .HP \w'void\ *rallocx('u
75 .BI "void *rallocx(void\ *" "ptr" ", size_t\ " "size" ", int\ " "flags" ");"
76 .HP \w'size_t\ xallocx('u
77 .BI "size_t xallocx(void\ *" "ptr" ", size_t\ " "size" ", size_t\ " "extra" ", int\ " "flags" ");"
78 .HP \w'size_t\ sallocx('u
79 .BI "size_t sallocx(void\ *" "ptr" ", int\ " "flags" ");"
80 .HP \w'void\ dallocx('u
81 .BI "void dallocx(void\ *" "ptr" ", int\ " "flags" ");"
82 .HP \w'void\ sdallocx('u
83 .BI "void sdallocx(void\ *" "ptr" ", size_t\ " "size" ", int\ " "flags" ");"
84 .HP \w'size_t\ nallocx('u
85 .BI "size_t nallocx(size_t\ " "size" ", int\ " "flags" ");"
86 .HP \w'int\ mallctl('u
87 .BI "int mallctl(const\ char\ *" "name" ", void\ *" "oldp" ", size_t\ *" "oldlenp" ", void\ *" "newp" ", size_t\ " "newlen" ");"
88 .HP \w'int\ mallctlnametomib('u
89 .BI "int mallctlnametomib(const\ char\ *" "name" ", size_t\ *" "mibp" ", size_t\ *" "miblenp" ");"
90 .HP \w'int\ mallctlbymib('u
91 .BI "int mallctlbymib(const\ size_t\ *" "mib" ", size_t\ " "miblen" ", void\ *" "oldp" ", size_t\ *" "oldlenp" ", void\ *" "newp" ", size_t\ " "newlen" ");"
92 .HP \w'void\ malloc_stats_print('u
93 .BI "void malloc_stats_print(void\ " "(*write_cb)" "\ (void\ *,\ const\ char\ *), void\ *" "cbopaque" ", const\ char\ *" "opts" ");"
94 .HP \w'size_t\ malloc_usable_size('u
95 .BI "size_t malloc_usable_size(const\ void\ *" "ptr" ");"
96 .HP \w'void\ (*malloc_message)('u
97 .BI "void (*malloc_message)(void\ *" "cbopaque" ", const\ char\ *" "s" ");"
99 const char *\fImalloc_conf\fR;
107 bytes of uninitialized memory\&. The allocated space is suitably aligned (after possible pointer coercion) for storage of any type of object\&.
111 function allocates space for
115 bytes in length\&. The result is identical to calling
120 \fIsize\fR, with the exception that the allocated memory is explicitly initialized to zero bytes\&.
126 bytes of memory such that the allocation\*(Aqs base address is a multiple of
127 \fIalignment\fR, and returns the allocation in the value pointed to by
128 \fIptr\fR\&. The requested
130 must be a power of 2 at least as large as
131 sizeof(\fBvoid *\fR)\&.
137 bytes of memory such that the allocation\*(Aqs base address is a multiple of
138 \fIalignment\fR\&. The requested
140 must be a power of 2\&. Behavior is undefined if
142 is not an integral multiple of
147 function changes the size of the previously allocated memory referenced by
151 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
153 is freed and a pointer to the newly allocated memory is returned\&. Note that
155 may move the memory allocation, resulting in a different return value than
161 function behaves identically to
163 for the specified size\&.
167 function causes the allocated memory referenced by
169 to be made available for future allocations\&. If
172 \fBNULL\fR, no action occurs\&.
173 .SS "Non\-standard API"
185 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:
187 \fBMALLOCX_LG_ALIGN(\fR\fB\fIla\fR\fR\fB) \fR
189 Align the memory allocation to start at an address that is a multiple of
190 (1 << \fIla\fR)\&. This macro does not validate that
192 is within the valid range\&.
195 \fBMALLOCX_ALIGN(\fR\fB\fIa\fR\fR\fB) \fR
197 Align the memory allocation to start at an address that is a multiple of
200 is a power of two\&. This macro does not validate that
207 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\&.
210 \fBMALLOCX_TCACHE(\fR\fB\fItc\fR\fR\fB) \fR
212 Use the thread\-specific cache (tcache) specified by the identifier
213 \fItc\fR, which must have been acquired via the
215 mallctl\&. This macro does not validate that
217 specifies a valid identifier\&.
220 \fBMALLOCX_TCACHE_NONE\fR
222 Do not use a thread\-specific cache (tcache)\&. Unless
223 \fBMALLOCX_TCACHE(\fR\fB\fItc\fR\fR\fB)\fR
225 \fBMALLOCX_TCACHE_NONE\fR
226 is specified, an automatically managed tcache will be used under many circumstances\&. This macro cannot be used in the same
229 \fBMALLOCX_TCACHE(\fR\fB\fItc\fR\fR\fB)\fR\&.
232 \fBMALLOCX_ARENA(\fR\fB\fIa\fR\fR\fB) \fR
234 Use the arena specified by the index
235 \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
237 specifies an arena index in the valid range\&.
242 function allocates at least
244 bytes of memory, and returns a pointer to the base address of the allocation\&. Behavior is undefined if
251 function resizes the allocation at
255 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
262 function resizes the allocation at
264 in place to be at least
266 bytes, and returns the real size of the allocation\&. If
268 is non\-zero, an attempt is made to resize the allocation to be at least
269 (\fIsize\fR + \fIextra\fR)
270 bytes, though inability to allocate the extra byte(s) will not by itself result in failure to resize\&. Behavior is undefined if
274 (\fIsize\fR + \fIextra\fR > \fBSIZE_T_MAX\fR)\&.
278 function returns the real size of the allocation at
283 function causes the memory referenced by
285 to be made available for future allocations\&.
289 function is an extension of
293 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
300 function allocates no memory, but it performs the same size computation as the
302 function, and returns the real size of the allocation that would result from the equivalent
306 if the inputs exceed the maximum supported size class and/or alignment\&. Behavior is undefined if
313 function provides a general interface for introspecting the memory allocator, as well as setting modifiable parameters and triggering actions\&. The period\-separated
315 argument specifies a location in a tree\-structured namespace; see the
317 section for documentation on the tree contents\&. To read a value, pass a pointer via
319 to adequate space to contain the value, and a pointer to its length via
320 \fIoldlenp\fR; otherwise pass
323 \fBNULL\fR\&. Similarly, to write a value, pass a pointer to the value via
324 \fInewp\fR, and its length via
325 \fInewlen\fR; otherwise pass
332 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
333 \(lqManagement Information Base\(rq
334 (MIB) that can be passed repeatedly to
335 mallctlbymib()\&. Upon successful return from
342 is the lesser of the number of components in
344 and the input value of
345 \fI*miblenp\fR\&. Thus it is possible to pass a
347 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
348 arenas\&.bin\&.2\&.size), the corresponding MIB component will always be that integer\&. Therefore, it is legitimate to construct code like the following:
359 mallctl("arenas\&.nbins", &nbins, &len, NULL, 0);
362 mallctlnametomib("arenas\&.bin\&.0\&.size", mib, &miblen);
363 for (i = 0; i < nbins; i++) {
367 len = sizeof(bin_size);
368 mallctlbymib(mib, miblen, (void *)&bin_size, &len, NULL, 0);
369 /* Do something with bin_size\&.\&.\&. */
378 function writes summary statistics via the
380 callback function pointer and
388 \fBNULL\fR\&. The statistics are presented in human\-readable form unless
390 is specified as a character within the
392 string, in which case the statistics are presented in
393 \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 as a character within the
401 functions internally, so inconsistent statistics can be reported if multiple threads use these functions simultaneously\&. If
402 \fB\-\-enable\-stats\fR
403 is specified during configuration,
407 can be specified to omit merged arena and per arena statistics, respectively;
411 can be specified to omit per size class statistics for bins, large objects, and huge objects, respectively\&. Unrecognized characters are silently ignored\&. Note that thread caching may prevent some statistics from being completely up to date, since extra locking would be required to merge counters that track thread cache operations\&.
415 function returns the usable size of the allocation pointed to by
416 \fIptr\fR\&. The return value may be larger than the size that was requested during allocation\&. The
418 function is not a mechanism for in\-place
419 realloc(); rather it is provided solely as a tool for introspection purposes\&. Any discrepancy between the requested allocation size and the size reported by
421 should not be depended on, since such behavior is entirely implementation\-dependent\&.
424 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\&.
426 The string specified via
427 \fB\-\-with\-malloc\-conf\fR, the string pointed to by the global variable
428 \fImalloc_conf\fR, the
430 of the file referenced by the symbolic link named
431 /etc/malloc\&.conf, and the value of the environment variable
432 \fBMALLOC_CONF\fR, will be interpreted, in that order, from left to right as options\&. Note that
436 is entered, so the declaration of
438 should specify an initializer that contains the final value to be read by jemalloc\&.
439 \fB\-\-with\-malloc\-conf\fR
442 are compile\-time mechanisms, whereas
446 can be safely set any time prior to program invocation\&.
448 An options string is a comma\-separated list of option:value pairs\&. There is one key corresponding to each
452 section for options documentation)\&. For example,
458 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\&.
459 .SH "IMPLEMENTATION NOTES"
461 Traditionally, allocators have used
463 to obtain memory, which is suboptimal for several reasons, including race conditions, increased fragmentation, and artificial limitations on maximum usable memory\&. If
465 is supported by the operating system, this allocator uses both
468 \fBsbrk\fR(2), in that order of preference; otherwise only
472 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\&.
474 In addition to multiple arenas, unless
475 \fB\-\-disable\-tcache\fR
476 is specified during configuration, this allocator supports thread\-specific caching for small and large objects, in order to make it possible to completely avoid synchronization for most allocation requests\&. Such caching allows very fast allocation in the common case, but it increases memory usage and fragmentation, since a bounded number of objects can remain allocated in each thread cache\&.
478 Memory is conceptually broken into equal\-sized chunks, where the chunk size is a power of two that is greater than the page size\&. Chunks are always aligned to multiples of the chunk size\&. This alignment makes it possible to find metadata for user objects very quickly\&. User objects are broken into three categories according to size: small, large, and huge\&. Multiple small and large objects can reside within a single chunk, whereas huge objects each have one or more chunks backing them\&. Each chunk that contains small and/or large objects tracks its contents as runs of contiguous pages (unused, backing a set of small objects, or backing one large object)\&. The combination of chunk alignment and chunk page maps makes it possible to determine all metadata regarding small and large allocations in constant time\&.
480 Small objects are managed in groups by page runs\&. Each run maintains a bitmap to track which regions are in use\&. Allocation requests that are no more than half the quantum (8 or 16, depending on architecture) are rounded up to the nearest power of two that is at least
481 sizeof(\fBdouble\fR)\&. All other object size classes are multiples of the quantum, spaced such that there are four size classes for each doubling in size, which limits internal fragmentation to approximately 20% for all but the smallest size classes\&. Small size classes are smaller than four times the page size, large size classes are smaller than the chunk size (see the
483 option), and huge size classes extend from the chunk size up to the largest size class that does not exceed
486 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\&.
492 functions may resize allocations without moving them under limited circumstances\&. Unlike the
494 API, the standard API does not officially round up the usable size of an allocation to the nearest size class, so technically it is necessary to call
496 to grow e\&.g\&. a 9\-byte allocation to 16 bytes, or shrink a 16\-byte allocation to 9 bytes\&. Growth and shrinkage trivially succeeds in place as long as the pre\-size and post\-size both round up to the same size class\&. No other API guarantees are made regarding in\-place resizing, but the current implementation also tries to resize large and huge allocations in place, as long as the pre\-size and post\-size are both large or both huge\&. In such cases shrinkage always succeeds for large size classes, but for huge size classes the chunk allocator must support splitting (see
497 arena\&.<i>\&.chunk_hooks)\&. Growth only succeeds if the trailing memory is currently available, and additionally for huge size classes the chunk allocator must support merging\&.
499 Assuming 2 MiB chunks, 4 KiB pages, and a 16\-byte quantum on a 64\-bit system, the size classes in each category are as shown in
503 .nr an-no-space-flag 1
506 .B Table\ \&1.\ \&Size classes
554 [16, 32, 48, 64, 80, 96, 112, 128]
569 [640, 768, 896, 1024]
574 [1280, 1536, 1792, 2048]
579 [2560, 3072, 3584, 4096]
584 [5 KiB, 6 KiB, 7 KiB, 8 KiB]
589 [10 KiB, 12 KiB, 14 KiB]
601 [20 KiB, 24 KiB, 28 KiB, 32 KiB]
606 [40 KiB, 48 KiB, 54 KiB, 64 KiB]
611 [80 KiB, 96 KiB, 112 KiB, 128 KiB]
616 [160 KiB, 192 KiB, 224 KiB, 256 KiB]
621 [320 KiB, 384 KiB, 448 KiB, 512 KiB]
626 [640 KiB, 768 KiB, 896 KiB, 1 MiB]
631 [1280 KiB, 1536 KiB, 1792 KiB]
643 [2560 KiB, 3 MiB, 3584 KiB, 4 MiB]
648 [5 MiB, 6 MiB, 7 MiB, 8 MiB]
653 [10 MiB, 12 MiB, 14 MiB, 16 MiB]
658 [20 MiB, 24 MiB, 28 MiB, 32 MiB]
663 [40 MiB, 48 MiB, 56 MiB, 64 MiB]
673 [2560 PiB, 3 EiB, 3584 PiB, 4 EiB]
678 [5 EiB, 6 EiB, 7 EiB]
682 .SH "MALLCTL NAMESPACE"
684 The following names are defined in the namespace accessible via the
686 functions\&. Value types are specified in parentheses, their readable/writable statuses are encoded as
690 \-\-, and required build configuration flags follow, if any\&. A name element encoded as
694 indicates an integer component, where the integer varies from 0 to some upper value that must be determined via introspection\&. In the case of
695 stats\&.arenas\&.<i>\&.*,
699 can be used to access the summation of statistics from all arenas\&. Take special note of the
701 mallctl, which controls refreshing of cached dynamic statistics\&.
703 version (\fBconst char *\fR) r\-
705 Return the jemalloc version string\&.
708 epoch (\fBuint64_t\fR) rw
710 If a value is passed in, refresh the data from which the
712 functions report values, and increment the epoch\&. Return the current epoch\&. This is useful for detecting whether another thread caused a refresh\&.
715 config\&.cache_oblivious (\fBbool\fR) r\-
717 \fB\-\-enable\-cache\-oblivious\fR
718 was specified during build configuration\&.
721 config\&.debug (\fBbool\fR) r\-
723 \fB\-\-enable\-debug\fR
724 was specified during build configuration\&.
727 config\&.fill (\fBbool\fR) r\-
729 \fB\-\-enable\-fill\fR
730 was specified during build configuration\&.
733 config\&.lazy_lock (\fBbool\fR) r\-
735 \fB\-\-enable\-lazy\-lock\fR
736 was specified during build configuration\&.
739 config\&.malloc_conf (\fBconst char *\fR) r\-
741 Embedded configure\-time\-specified run\-time options string, empty unless
742 \fB\-\-with\-malloc\-conf\fR
743 was specified during build configuration\&.
746 config\&.munmap (\fBbool\fR) r\-
748 \fB\-\-enable\-munmap\fR
749 was specified during build configuration\&.
752 config\&.prof (\fBbool\fR) r\-
754 \fB\-\-enable\-prof\fR
755 was specified during build configuration\&.
758 config\&.prof_libgcc (\fBbool\fR) r\-
760 \fB\-\-disable\-prof\-libgcc\fR
761 was not specified during build configuration\&.
764 config\&.prof_libunwind (\fBbool\fR) r\-
766 \fB\-\-enable\-prof\-libunwind\fR
767 was specified during build configuration\&.
770 config\&.stats (\fBbool\fR) r\-
772 \fB\-\-enable\-stats\fR
773 was specified during build configuration\&.
776 config\&.tcache (\fBbool\fR) r\-
778 \fB\-\-disable\-tcache\fR
779 was not specified during build configuration\&.
782 config\&.tls (\fBbool\fR) r\-
784 \fB\-\-disable\-tls\fR
785 was not specified during build configuration\&.
788 config\&.utrace (\fBbool\fR) r\-
790 \fB\-\-enable\-utrace\fR
791 was specified during build configuration\&.
794 config\&.valgrind (\fBbool\fR) r\-
796 \fB\-\-enable\-valgrind\fR
797 was specified during build configuration\&.
800 config\&.xmalloc (\fBbool\fR) r\-
802 \fB\-\-enable\-xmalloc\fR
803 was specified during build configuration\&.
806 opt\&.abort (\fBbool\fR) r\-
808 Abort\-on\-warning enabled/disabled\&. If true, most warnings are fatal\&. The process will call
810 in these cases\&. This option is disabled by default unless
811 \fB\-\-enable\-debug\fR
812 is specified during configuration, in which case it is enabled by default\&.
815 opt\&.dss (\fBconst char *\fR) r\-
817 dss (\fBsbrk\fR(2)) allocation precedence as related to
819 allocation\&. The following settings are supported if
821 is supported by the operating system:
824 \(lqsecondary\(rq; otherwise only
826 is supported\&. The default is
830 is supported by the operating system;
835 opt\&.lg_chunk (\fBsize_t\fR) r\-
837 Virtual memory chunk size (log base 2)\&. If a chunk size outside the supported size range is specified, the size is silently clipped to the minimum/maximum supported size\&. The default chunk size is 2 MiB (2^21)\&.
840 opt\&.narenas (\fBunsigned\fR) r\-
842 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\&.
845 opt\&.purge (\fBconst char *\fR) r\-
847 Purge mode is \(lqratio\(rq (default) or \(lqdecay\(rq\&. See
849 for details of the ratio mode\&. See
851 for details of the decay mode\&.
854 opt\&.lg_dirty_mult (\fBssize_t\fR) r\-
856 Per\-arena minimum ratio (log base 2) of active to dirty pages\&. Some dirty unused pages may be allowed to accumulate, within the limit set by the ratio (or one chunk worth of dirty pages, whichever is greater), before informing the kernel about some of those pages via
858 or a similar system call\&. This provides the kernel with sufficient information to recycle dirty pages if physical memory becomes scarce and the pages remain unused\&. The default minimum ratio is 8:1 (2^3:1); an option value of \-1 will disable dirty page purging\&. See
859 arenas\&.lg_dirty_mult
861 arena\&.<i>\&.lg_dirty_mult
862 for related dynamic control options\&.
865 opt\&.decay_time (\fBssize_t\fR) r\-
867 Approximate time in seconds from the creation of a set of unused dirty pages until an equivalent set of unused dirty pages is purged and/or reused\&. 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
870 arena\&.<i>\&.decay_time
871 for related dynamic control options\&.
874 opt\&.stats_print (\fBbool\fR) r\-
876 Enable/disable statistics printing at exit\&. If enabled, the
878 function is called at program exit via an
881 \fB\-\-enable\-stats\fR
882 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,
884 may allocate memory during application initialization and then deadlock internally when jemalloc in turn calls
885 atexit(), so this option is not universally usable (though the application can register its own
887 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\&.
890 opt\&.junk (\fBconst char *\fR) r\- [\fB\-\-enable\-fill\fR]
892 Junk filling\&. If set to
893 \(lqalloc\(rq, each byte of uninitialized allocated memory will be initialized to
895 \(lqfree\(rq, all deallocated memory will be initialized to
897 \(lqtrue\(rq, both allocated and deallocated memory will be initialized, and if set to
898 \(lqfalse\(rq, junk filling be disabled entirely\&. This is intended for debugging and will impact performance negatively\&. This option is
901 \fB\-\-enable\-debug\fR
902 is specified during configuration, in which case it is
904 by default unless running inside
905 \m[blue]\fBValgrind\fR\m[]\&\s-2\u[3]\d\s+2\&.
908 opt\&.quarantine (\fBsize_t\fR) r\- [\fB\-\-enable\-fill\fR]
910 Per thread quarantine size in bytes\&. If non\-zero, each thread maintains a FIFO object quarantine that stores up to the specified number of bytes of memory\&. The quarantined memory is not freed until it is released from quarantine, though it is immediately junk\-filled if the
912 option is enabled\&. This feature is of particular use in combination with
913 \m[blue]\fBValgrind\fR\m[]\&\s-2\u[3]\d\s+2, which can detect attempts to access quarantined objects\&. This is intended for debugging and will impact performance negatively\&. The default quarantine size is 0 unless running inside Valgrind, in which case the default is 16 MiB\&.
916 opt\&.redzone (\fBbool\fR) r\- [\fB\-\-enable\-fill\fR]
918 Redzones enabled/disabled\&. If enabled, small allocations have redzones before and after them\&. Furthermore, if the
920 option is enabled, the redzones are checked for corruption during deallocation\&. However, the primary intended purpose of this feature is to be used in combination with
921 \m[blue]\fBValgrind\fR\m[]\&\s-2\u[3]\d\s+2, which needs redzones in order to do effective buffer overflow/underflow detection\&. This option is intended for debugging and will impact performance negatively\&. This option is disabled by default unless running inside Valgrind\&.
924 opt\&.zero (\fBbool\fR) r\- [\fB\-\-enable\-fill\fR]
926 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
930 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\&.
933 opt\&.utrace (\fBbool\fR) r\- [\fB\-\-enable\-utrace\fR]
935 Allocation tracing based on
937 enabled/disabled\&. This option is disabled by default\&.
940 opt\&.xmalloc (\fBbool\fR) r\- [\fB\-\-enable\-xmalloc\fR]
942 Abort\-on\-out\-of\-memory enabled/disabled\&. If enabled, rather than returning failure for any allocation function, display a diagnostic message on
944 and cause the program to drop core (using
945 \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:
951 malloc_conf = "xmalloc:true";
957 This option is disabled by default\&.
960 opt\&.tcache (\fBbool\fR) r\- [\fB\-\-enable\-tcache\fR]
962 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
964 option for related tuning information\&. This option is enabled by default unless running inside
965 \m[blue]\fBValgrind\fR\m[]\&\s-2\u[3]\d\s+2, in which case it is forcefully disabled\&.
968 opt\&.lg_tcache_max (\fBsize_t\fR) r\- [\fB\-\-enable\-tcache\fR]
970 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)\&.
973 opt\&.prof (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
975 Memory profiling enabled/disabled\&. If enabled, profile memory allocation activity\&. See the
977 option for on\-the\-fly activation/deactivation\&. See the
979 option for probabilistic sampling control\&. See the
981 option for control of cumulative sample reporting\&. See the
982 opt\&.lg_prof_interval
983 option for information on interval\-triggered profile dumping, the
985 option for information on high\-water\-triggered profile dumping, and the
987 option for final profile dumping\&. Profile output is compatible with the
989 command, which is based on the
991 that is developed as part of the
992 \m[blue]\fBgperftools package\fR\m[]\&\s-2\u[4]\d\s+2\&. See
994 for heap profile format documentation\&.
997 opt\&.prof_prefix (\fBconst char *\fR) r\- [\fB\-\-enable\-prof\fR]
999 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
1003 opt\&.prof_active (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
1005 Profiling activated/deactivated\&. This is a secondary control mechanism that makes it possible to start the application with profiling enabled (see the
1007 option) but inactive, then toggle profiling at any time during program execution with the
1009 mallctl\&. This option is enabled by default\&.
1012 opt\&.prof_thread_active_init (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
1015 thread\&.prof\&.active
1016 in newly created threads\&. The initial setting for newly created threads can also be changed during execution via the
1017 prof\&.thread_active_init
1018 mallctl\&. This option is enabled by default\&.
1021 opt\&.lg_prof_sample (\fBsize_t\fR) r\- [\fB\-\-enable\-prof\fR]
1023 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)\&.
1026 opt\&.prof_accum (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
1028 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\&.
1031 opt\&.lg_prof_interval (\fBssize_t\fR) r\- [\fB\-\-enable\-prof\fR]
1033 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
1034 <prefix>\&.<pid>\&.<seq>\&.i<iseq>\&.heap, where
1036 is controlled by the
1038 option\&. By default, interval\-triggered profile dumping is disabled (encoded as \-1)\&.
1041 opt\&.prof_gdump (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
1043 Set the initial state of
1044 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\&.
1047 opt\&.prof_final (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
1051 function to dump final memory usage to a file named according to the pattern
1052 <prefix>\&.<pid>\&.<seq>\&.f\&.heap, where
1054 is controlled by the
1058 may allocate memory during application initialization and then deadlock internally when jemalloc in turn calls
1059 atexit(), so this option is not universally usable (though the application can register its own
1061 function with equivalent functionality)\&. This option is disabled by default\&.
1064 opt\&.prof_leak (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
1066 Leak reporting enabled/disabled\&. If enabled, use an
1068 function to report memory leaks detected by allocation sampling\&. See the
1070 option for information on analyzing heap profile output\&. This option is disabled by default\&.
1073 thread\&.arena (\fBunsigned\fR) rw
1075 Get or set the arena associated with the calling thread\&. If the specified arena was not initialized beforehand (see the
1076 arenas\&.initialized
1077 mallctl), it will be automatically initialized as a side effect of calling this interface\&.
1080 thread\&.allocated (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1082 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\&.
1085 thread\&.allocatedp (\fBuint64_t *\fR) r\- [\fB\-\-enable\-stats\fR]
1087 Get a pointer to the the value that is returned by the
1089 mallctl\&. This is useful for avoiding the overhead of repeated
1094 thread\&.deallocated (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1096 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\&.
1099 thread\&.deallocatedp (\fBuint64_t *\fR) r\- [\fB\-\-enable\-stats\fR]
1101 Get a pointer to the the value that is returned by the
1102 thread\&.deallocated
1103 mallctl\&. This is useful for avoiding the overhead of repeated
1108 thread\&.tcache\&.enabled (\fBbool\fR) rw [\fB\-\-enable\-tcache\fR]
1110 Enable/disable calling thread\*(Aqs tcache\&. The tcache is implicitly flushed as a side effect of becoming disabled (see
1111 thread\&.tcache\&.flush)\&.
1114 thread\&.tcache\&.flush (\fBvoid\fR) \-\- [\fB\-\-enable\-tcache\fR]
1116 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\&.
1119 thread\&.prof\&.name (\fBconst char *\fR) r\- or \-w [\fB\-\-enable\-prof\fR]
1121 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
1127 thread\&.prof\&.active (\fBbool\fR) rw [\fB\-\-enable\-prof\fR]
1129 Control whether sampling is currently active for the calling thread\&. This is an activation mechanism in addition to
1130 prof\&.active; both must be active for the calling thread to sample\&. This flag is enabled by default\&.
1133 tcache\&.create (\fBunsigned\fR) r\- [\fB\-\-enable\-tcache\fR]
1135 Create an explicit thread\-specific cache (tcache) and return an identifier that can be passed to the
1136 \fBMALLOCX_TCACHE(\fR\fB\fItc\fR\fR\fB)\fR
1137 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\&.
1140 tcache\&.flush (\fBunsigned\fR) \-w [\fB\-\-enable\-tcache\fR]
1142 Flush the specified thread\-specific cache (tcache)\&. The same considerations apply to this interface as to
1143 thread\&.tcache\&.flush, except that the tcache will never be automatically discarded\&.
1146 tcache\&.destroy (\fBunsigned\fR) \-w [\fB\-\-enable\-tcache\fR]
1148 Flush the specified thread\-specific cache (tcache) and make the identifier available for use during a future tcache creation\&.
1151 arena\&.<i>\&.purge (\fBvoid\fR) \-\-
1153 Purge all unused dirty pages for arena <i>, or for all arenas if <i> equals
1157 arena\&.<i>\&.decay (\fBvoid\fR) \-\-
1159 Trigger decay\-based purging of unused dirty pages for arena <i>, or for all arenas if <i> equals
1160 arenas\&.narenas\&. The proportion of unused dirty pages to be purged depends on the current time; see
1165 arena\&.<i>\&.reset (\fBvoid\fR) \-\-
1167 Discard all of the arena\*(Aqs extant allocations\&. This interface can only be used with arenas created via
1168 arenas\&.extend\&. 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\&. This interface cannot be used if running inside Valgrind, nor if the
1170 size is non\-zero\&.
1173 arena\&.<i>\&.dss (\fBconst char *\fR) rw
1175 Set the precedence of dss allocation as related to mmap allocation for arena <i>, or for all arenas if <i> equals
1176 arenas\&.narenas\&. See
1178 for supported settings\&.
1181 arena\&.<i>\&.lg_dirty_mult (\fBssize_t\fR) rw
1183 Current per\-arena minimum ratio (log base 2) of active to dirty pages for arena <i>\&. Each time this interface is set and the ratio is increased, pages are synchronously purged as necessary to impose the new ratio\&. See
1185 for additional information\&.
1188 arena\&.<i>\&.decay_time (\fBssize_t\fR) rw
1190 Current per\-arena approximate time in seconds 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
1192 for additional information\&.
1195 arena\&.<i>\&.chunk_hooks (\fBchunk_hooks_t\fR) rw
1197 Get or set the chunk management hook functions for arena <i>\&. The functions must be capable of operating on all extant chunks associated with arena <i>, usually by passing unknown chunks to the replaced functions\&. In practice, it is feasible to control allocation for arenas created via
1199 such that all chunks originate from an application\-supplied chunk allocator (by setting custom chunk hook functions just after arena creation), but the automatically created arenas may have already created chunks prior to the application having an opportunity to take over chunk allocation\&.
1206 chunk_alloc_t *alloc;
1207 chunk_dalloc_t *dalloc;
1208 chunk_commit_t *commit;
1209 chunk_decommit_t *decommit;
1210 chunk_purge_t *purge;
1211 chunk_split_t *split;
1212 chunk_merge_t *merge;
1221 structure comprises function pointers which are described individually below\&. jemalloc uses these functions to manage chunk lifetime, which starts off with allocation of mapped committed memory, in the simplest case followed by deallocation\&. However, there are performance and platform reasons to retain chunks for later reuse\&. Cleanup attempts cascade from deallocation to decommit to purging, which gives the chunk management functions opportunities to reject the most permanent cleanup operations in favor of less permanent (and often less costly) operations\&. The chunk splitting and merging operations can also be opted out of, but this is mainly intended to support platforms on which virtual memory mappings provided by the operating system kernel do not automatically coalesce and split, e\&.g\&. Windows\&.
1222 .HP \w'typedef\ void\ *(chunk_alloc_t)('u
1223 .BI "typedef void *(chunk_alloc_t)(void\ *" "chunk" ", size_t\ " "size" ", size_t\ " "alignment" ", bool\ *" "zero" ", bool\ *" "commit" ", unsigned\ " "arena_ind" ");"
1234 A chunk allocation function conforms to the
1236 type and upon success returns a pointer to
1238 bytes of mapped memory on behalf of arena
1240 such that the chunk\*(Aqs base address is a multiple of
1241 \fIalignment\fR, as well as setting
1243 to indicate whether the chunk is zeroed and
1245 to indicate whether the chunk is committed\&. Upon error the function returns
1253 parameter is always a multiple of the chunk size\&. The
1255 parameter is always a power of two at least as large as the chunk size\&. Zeroing is mandatory if
1257 is true upon function entry\&. Committing is mandatory if
1259 is true upon function entry\&. If
1262 \fBNULL\fR, the returned pointer must be
1266 on error\&. Committed memory may be committed in absolute terms as on a system that does not overcommit, or in implicit terms as on a system that overcommits and satisfies physical memory needs on demand via soft page faults\&. Note that replacing the default chunk allocation function makes the arena\*(Aqs
1268 setting irrelevant\&.
1269 .HP \w'typedef\ bool\ (chunk_dalloc_t)('u
1270 .BI "typedef bool (chunk_dalloc_t)(void\ *" "chunk" ", size_t\ " "size" ", bool\ " "committed" ", unsigned\ " "arena_ind" ");"
1281 A chunk deallocation function conforms to the
1282 \fBchunk_dalloc_t\fR
1283 type and deallocates a
1288 \fIcommitted\fR/decommited memory as indicated, on behalf of arena
1289 \fIarena_ind\fR, returning false upon success\&. If the function returns true, this indicates opt\-out from deallocation; the virtual memory mapping associated with the chunk remains mapped, in the same commit state, and available for future use, in which case it will be automatically retained for later reuse\&.
1290 .HP \w'typedef\ bool\ (chunk_commit_t)('u
1291 .BI "typedef bool (chunk_commit_t)(void\ *" "chunk" ", size_t\ " "size" ", size_t\ " "offset" ", size_t\ " "length" ", unsigned\ " "arena_ind" ");"
1302 A chunk commit function conforms to the
1303 \fBchunk_commit_t\fR
1304 type and commits zeroed physical memory to back pages within a
1310 bytes, extending for
1313 \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\&.
1314 .HP \w'typedef\ bool\ (chunk_decommit_t)('u
1315 .BI "typedef bool (chunk_decommit_t)(void\ *" "chunk" ", size_t\ " "size" ", size_t\ " "offset" ", size_t\ " "length" ", unsigned\ " "arena_ind" ");"
1326 A chunk decommit function conforms to the
1327 \fBchunk_decommit_t\fR
1328 type and decommits any physical memory that is backing pages within a
1334 bytes, extending for
1337 \fIarena_ind\fR, returning false upon success, in which case the pages will be committed via the chunk commit function before being reused\&. If the function returns true, this indicates opt\-out from decommit; the memory remains committed and available for future use, in which case it will be automatically retained for later reuse\&.
1338 .HP \w'typedef\ bool\ (chunk_purge_t)('u
1339 .BI "typedef bool (chunk_purge_t)(void\ *" "chunk" ", size_t" "size" ", size_t\ " "offset" ", size_t\ " "length" ", unsigned\ " "arena_ind" ");"
1350 A chunk purge function conforms to the
1352 type and optionally discards physical pages within the virtual memory mapping associated with
1358 bytes, extending for
1361 \fIarena_ind\fR, returning false if pages within the purged virtual memory range will be zero\-filled the next time they are accessed\&.
1362 .HP \w'typedef\ bool\ (chunk_split_t)('u
1363 .BI "typedef bool (chunk_split_t)(void\ *" "chunk" ", size_t\ " "size" ", size_t\ " "size_a" ", size_t\ " "size_b" ", bool\ " "committed" ", unsigned\ " "arena_ind" ");"
1374 A chunk split function conforms to the
1376 type and optionally splits
1380 into two adjacent chunks, the first of
1382 bytes, and the second of
1385 \fIcommitted\fR/decommitted memory as indicated, on behalf of arena
1386 \fIarena_ind\fR, returning false upon success\&. If the function returns true, this indicates that the chunk remains unsplit and therefore should continue to be operated on as a whole\&.
1387 .HP \w'typedef\ bool\ (chunk_merge_t)('u
1388 .BI "typedef bool (chunk_merge_t)(void\ *" "chunk_a" ", size_t\ " "size_a" ", void\ *" "chunk_b" ", size_t\ " "size_b" ", bool\ " "committed" ", unsigned\ " "arena_ind" ");"
1399 A chunk merge function conforms to the
1401 type and optionally merges adjacent chunks,
1409 into one contiguous chunk, operating on
1410 \fIcommitted\fR/decommitted memory as indicated, on behalf of arena
1411 \fIarena_ind\fR, returning false upon success\&. If the function returns true, this indicates that the chunks remain distinct mappings and therefore should continue to be operated on independently\&.
1414 arenas\&.narenas (\fBunsigned\fR) r\-
1416 Current limit on number of arenas\&.
1419 arenas\&.initialized (\fBbool *\fR) r\-
1423 booleans\&. Each boolean indicates whether the corresponding arena is initialized\&.
1426 arenas\&.lg_dirty_mult (\fBssize_t\fR) rw
1428 Current default per\-arena minimum ratio (log base 2) of active to dirty pages, used to initialize
1429 arena\&.<i>\&.lg_dirty_mult
1430 during arena creation\&. See
1432 for additional information\&.
1435 arenas\&.decay_time (\fBssize_t\fR) rw
1437 Current default per\-arena approximate time in seconds 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
1438 arena\&.<i>\&.decay_time
1439 during arena creation\&. See
1441 for additional information\&.
1444 arenas\&.quantum (\fBsize_t\fR) r\-
1449 arenas\&.page (\fBsize_t\fR) r\-
1454 arenas\&.tcache_max (\fBsize_t\fR) r\- [\fB\-\-enable\-tcache\fR]
1456 Maximum thread\-cached size class\&.
1459 arenas\&.nbins (\fBunsigned\fR) r\-
1461 Number of bin size classes\&.
1464 arenas\&.nhbins (\fBunsigned\fR) r\- [\fB\-\-enable\-tcache\fR]
1466 Total number of thread cache bin size classes\&.
1469 arenas\&.bin\&.<i>\&.size (\fBsize_t\fR) r\-
1471 Maximum size supported by size class\&.
1474 arenas\&.bin\&.<i>\&.nregs (\fBuint32_t\fR) r\-
1476 Number of regions per page run\&.
1479 arenas\&.bin\&.<i>\&.run_size (\fBsize_t\fR) r\-
1481 Number of bytes per page run\&.
1484 arenas\&.nlruns (\fBunsigned\fR) r\-
1486 Total number of large size classes\&.
1489 arenas\&.lrun\&.<i>\&.size (\fBsize_t\fR) r\-
1491 Maximum size supported by this large size class\&.
1494 arenas\&.nhchunks (\fBunsigned\fR) r\-
1496 Total number of huge size classes\&.
1499 arenas\&.hchunk\&.<i>\&.size (\fBsize_t\fR) r\-
1501 Maximum size supported by this huge size class\&.
1504 arenas\&.extend (\fBunsigned\fR) r\-
1506 Extend the array of arenas by appending a new arena, and returning the new arena index\&.
1509 prof\&.thread_active_init (\fBbool\fR) rw [\fB\-\-enable\-prof\fR]
1511 Control the initial setting for
1512 thread\&.prof\&.active
1513 in newly created threads\&. See the
1514 opt\&.prof_thread_active_init
1515 option for additional information\&.
1518 prof\&.active (\fBbool\fR) rw [\fB\-\-enable\-prof\fR]
1520 Control whether sampling is currently active\&. See the
1522 option for additional information, as well as the interrelated
1523 thread\&.prof\&.active
1527 prof\&.dump (\fBconst char *\fR) \-w [\fB\-\-enable\-prof\fR]
1529 Dump a memory profile to the specified file, or if NULL is specified, to a file according to the pattern
1530 <prefix>\&.<pid>\&.<seq>\&.m<mseq>\&.heap, where
1532 is controlled by the
1537 prof\&.gdump (\fBbool\fR) rw [\fB\-\-enable\-prof\fR]
1539 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
1540 <prefix>\&.<pid>\&.<seq>\&.u<useq>\&.heap, where
1542 is controlled by the
1547 prof\&.reset (\fBsize_t\fR) \-w [\fB\-\-enable\-prof\fR]
1549 Reset all memory profile statistics, and optionally update the sample rate (see
1550 opt\&.lg_prof_sample
1552 prof\&.lg_sample)\&.
1555 prof\&.lg_sample (\fBsize_t\fR) r\- [\fB\-\-enable\-prof\fR]
1557 Get the current sample rate (see
1558 opt\&.lg_prof_sample)\&.
1561 prof\&.interval (\fBuint64_t\fR) r\- [\fB\-\-enable\-prof\fR]
1563 Average number of bytes allocated between interval\-based profile dumps\&. See the
1564 opt\&.lg_prof_interval
1565 option for additional information\&.
1568 stats\&.cactive (\fBsize_t *\fR) r\- [\fB\-\-enable\-stats\fR]
1570 Pointer to a counter that contains an approximate count of the current number of bytes in active pages\&. The estimate may be high, but never low, because each arena rounds up when computing its contribution to the counter\&. Note that the
1572 mallctl has no bearing on this counter\&. Furthermore, counter consistency is maintained via atomic operations, so it is necessary to use an atomic operation in order to guarantee a consistent read when dereferencing the pointer\&.
1575 stats\&.allocated (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1577 Total number of bytes allocated by the application\&.
1580 stats\&.active (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1582 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
1583 stats\&.allocated\&. This does not include
1584 stats\&.arenas\&.<i>\&.pdirty, nor pages entirely devoted to allocator metadata\&.
1587 stats\&.metadata (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1589 Total number of bytes dedicated to metadata, which comprise base allocations used for bootstrap\-sensitive internal allocator data structures, arena chunk headers (see
1590 stats\&.arenas\&.<i>\&.metadata\&.mapped), and internal allocations (see
1591 stats\&.arenas\&.<i>\&.metadata\&.allocated)\&.
1594 stats\&.resident (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1596 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
1600 stats\&.mapped (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1602 Total number of bytes in active chunks mapped by the allocator\&. This is a multiple of the chunk size, and is larger than
1603 stats\&.active\&. This does not include inactive chunks, even those that contain unused dirty pages, which means that there is no strict ordering between this and
1607 stats\&.retained (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1609 Total number of bytes in virtual memory mappings that were retained rather than being returned to the operating system via e\&.g\&.
1610 \fBmunmap\fR(2)\&. Retained virtual memory is typically untouched, decommitted, or purged, so it has no strongly associated physical memory (see
1612 for details)\&. Retained memory is excluded from mapped memory statistics, e\&.g\&.
1616 stats\&.arenas\&.<i>\&.dss (\fBconst char *\fR) r\-
1618 dss (\fBsbrk\fR(2)) allocation precedence as related to
1625 stats\&.arenas\&.<i>\&.lg_dirty_mult (\fBssize_t\fR) r\-
1627 Minimum ratio (log base 2) of active to dirty pages\&. See
1632 stats\&.arenas\&.<i>\&.decay_time (\fBssize_t\fR) r\-
1634 Approximate time in seconds from the creation of a set of unused dirty pages until an equivalent set of unused dirty pages is purged and/or reused\&. See
1639 stats\&.arenas\&.<i>\&.nthreads (\fBunsigned\fR) r\-
1641 Number of threads currently assigned to arena\&.
1644 stats\&.arenas\&.<i>\&.pactive (\fBsize_t\fR) r\-
1646 Number of pages in active runs\&.
1649 stats\&.arenas\&.<i>\&.pdirty (\fBsize_t\fR) r\-
1651 Number of pages within unused runs that are potentially dirty, and for which
1652 madvise\fI\&.\&.\&.\fR \fI\fBMADV_DONTNEED\fR\fR
1653 or similar has not been called\&.
1656 stats\&.arenas\&.<i>\&.mapped (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1658 Number of mapped bytes\&.
1661 stats\&.arenas\&.<i>\&.retained (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1663 Number of retained bytes\&. See
1668 stats\&.arenas\&.<i>\&.metadata\&.mapped (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1670 Number of mapped bytes in arena chunk headers, which track the states of the non\-metadata pages\&.
1673 stats\&.arenas\&.<i>\&.metadata\&.allocated (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1675 Number of bytes dedicated to internal allocations\&. Internal allocations differ from application\-originated allocations in that they are for internal use, and that they are omitted from heap profiles\&. This statistic is reported separately from
1678 stats\&.arenas\&.<i>\&.metadata\&.mapped
1679 because it overlaps with e\&.g\&. the
1683 statistics, whereas the other metadata statistics do not\&.
1686 stats\&.arenas\&.<i>\&.npurge (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1688 Number of dirty page purge sweeps performed\&.
1691 stats\&.arenas\&.<i>\&.nmadvise (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1694 madvise\fI\&.\&.\&.\fR \fI\fBMADV_DONTNEED\fR\fR
1695 or similar calls made to purge dirty pages\&.
1698 stats\&.arenas\&.<i>\&.purged (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1700 Number of pages purged\&.
1703 stats\&.arenas\&.<i>\&.small\&.allocated (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1705 Number of bytes currently allocated by small objects\&.
1708 stats\&.arenas\&.<i>\&.small\&.nmalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1710 Cumulative number of allocation requests served by small bins\&.
1713 stats\&.arenas\&.<i>\&.small\&.ndalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1715 Cumulative number of small objects returned to bins\&.
1718 stats\&.arenas\&.<i>\&.small\&.nrequests (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1720 Cumulative number of small allocation requests\&.
1723 stats\&.arenas\&.<i>\&.large\&.allocated (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1725 Number of bytes currently allocated by large objects\&.
1728 stats\&.arenas\&.<i>\&.large\&.nmalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1730 Cumulative number of large allocation requests served directly by the arena\&.
1733 stats\&.arenas\&.<i>\&.large\&.ndalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1735 Cumulative number of large deallocation requests served directly by the arena\&.
1738 stats\&.arenas\&.<i>\&.large\&.nrequests (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1740 Cumulative number of large allocation requests\&.
1743 stats\&.arenas\&.<i>\&.huge\&.allocated (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1745 Number of bytes currently allocated by huge objects\&.
1748 stats\&.arenas\&.<i>\&.huge\&.nmalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1750 Cumulative number of huge allocation requests served directly by the arena\&.
1753 stats\&.arenas\&.<i>\&.huge\&.ndalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1755 Cumulative number of huge deallocation requests served directly by the arena\&.
1758 stats\&.arenas\&.<i>\&.huge\&.nrequests (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1760 Cumulative number of huge allocation requests\&.
1763 stats\&.arenas\&.<i>\&.bins\&.<j>\&.nmalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1765 Cumulative number of allocations served by bin\&.
1768 stats\&.arenas\&.<i>\&.bins\&.<j>\&.ndalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1770 Cumulative number of allocations returned to bin\&.
1773 stats\&.arenas\&.<i>\&.bins\&.<j>\&.nrequests (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1775 Cumulative number of allocation requests\&.
1778 stats\&.arenas\&.<i>\&.bins\&.<j>\&.curregs (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1780 Current number of regions for this size class\&.
1783 stats\&.arenas\&.<i>\&.bins\&.<j>\&.nfills (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR \fB\-\-enable\-tcache\fR]
1785 Cumulative number of tcache fills\&.
1788 stats\&.arenas\&.<i>\&.bins\&.<j>\&.nflushes (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR \fB\-\-enable\-tcache\fR]
1790 Cumulative number of tcache flushes\&.
1793 stats\&.arenas\&.<i>\&.bins\&.<j>\&.nruns (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1795 Cumulative number of runs created\&.
1798 stats\&.arenas\&.<i>\&.bins\&.<j>\&.nreruns (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1800 Cumulative number of times the current run from which to allocate changed\&.
1803 stats\&.arenas\&.<i>\&.bins\&.<j>\&.curruns (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1805 Current number of runs\&.
1808 stats\&.arenas\&.<i>\&.lruns\&.<j>\&.nmalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1810 Cumulative number of allocation requests for this size class served directly by the arena\&.
1813 stats\&.arenas\&.<i>\&.lruns\&.<j>\&.ndalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1815 Cumulative number of deallocation requests for this size class served directly by the arena\&.
1818 stats\&.arenas\&.<i>\&.lruns\&.<j>\&.nrequests (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1820 Cumulative number of allocation requests for this size class\&.
1823 stats\&.arenas\&.<i>\&.lruns\&.<j>\&.curruns (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1825 Current number of runs for this size class\&.
1828 stats\&.arenas\&.<i>\&.hchunks\&.<j>\&.nmalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1830 Cumulative number of allocation requests for this size class served directly by the arena\&.
1833 stats\&.arenas\&.<i>\&.hchunks\&.<j>\&.ndalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1835 Cumulative number of deallocation requests for this size class served directly by the arena\&.
1838 stats\&.arenas\&.<i>\&.hchunks\&.<j>\&.nrequests (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1840 Cumulative number of allocation requests for this size class\&.
1843 stats\&.arenas\&.<i>\&.hchunks\&.<j>\&.curhchunks (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1845 Current number of huge allocations for this size class\&.
1847 .SH "HEAP PROFILE FORMAT"
1849 Although the heap profiling functionality was originally designed to be compatible with the
1851 command that is developed as part of the
1852 \m[blue]\fBgperftools package\fR\m[]\&\s-2\u[4]\d\s+2, the addition of per thread heap profiling functionality required a different heap profile format\&. The
1854 command is derived from
1855 \fBpprof\fR, with enhancements to support the heap profile format described here\&.
1857 In the following hypothetical heap profile,
1859 indicates elision for the sake of compactness\&.
1866 t*: 28106: 56637512 [0: 0]
1868 t3: 352: 16777344 [0: 0]
1870 t99: 17754: 29341640 [0: 0]
1872 @ 0x5f86da8 0x5f5a1dc [\&.\&.\&.] 0x29e4d4e 0xa200316 0xabb2988 [\&.\&.\&.]
1885 The following matches the above heap profile, but most tokens are replaced with
1887 to indicate descriptions of the corresponding fields\&.
1893 <heap_profile_format_version>/<mean_sample_interval>
1894 <aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
1896 <thread_3_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>]
1898 <thread_99_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>]
1900 @ <top_frame> <frame> [\&.\&.\&.] <frame> <frame> <frame> [\&.\&.\&.]
1901 <backtrace_aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
1902 <backtrace_thread_3>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
1903 <backtrace_thread_99>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
1912 .SH "DEBUGGING MALLOC PROBLEMS"
1914 When debugging, it is a good idea to configure/build jemalloc with the
1915 \fB\-\-enable\-debug\fR
1917 \fB\-\-enable\-fill\fR
1918 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\&.
1920 Programs often accidentally depend on
1921 \(lquninitialized\(rq
1922 memory actually being filled with zero bytes\&. Junk filling (see the
1924 option) tends to expose such bugs in the form of obviously incorrect results and/or coredumps\&. Conversely, zero filling (see the
1926 option) eliminates the symptoms of such bugs\&. Between these two options, it is usually possible to quickly detect, diagnose, and eliminate such bugs\&.
1928 This implementation does not provide much detail about the problems it detects, because the performance impact for storing such information would be prohibitive\&. However, jemalloc does integrate with the most excellent
1929 \m[blue]\fBValgrind\fR\m[]\&\s-2\u[3]\d\s+2
1931 \fB\-\-enable\-valgrind\fR
1932 configuration option is enabled\&.
1933 .SH "DIAGNOSTIC MESSAGES"
1935 If any of the memory allocation/deallocation functions detect an error or warning condition, a message will be printed to file descriptor
1936 \fBSTDERR_FILENO\fR\&. Errors will result in the process dumping core\&. If the
1938 option is set, most warnings are treated as errors\&.
1941 \fImalloc_message\fR
1942 variable allows the programmer to override the function which emits the text strings forming the errors and warnings if for some reason the
1944 file descriptor is not suitable for this\&.
1948 pointer argument that is
1950 unless overridden by the arguments in a call to
1951 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\&.
1953 All messages are prefixed by
1954 \(lq<jemalloc>: \(rq\&.
1962 functions return a pointer to the allocated memory if successful; otherwise a
1964 pointer is returned and
1971 function returns the value 0 if successful; otherwise it returns an error value\&. The
1973 function will fail if:
1979 parameter is not a power of 2 at least as large as
1980 sizeof(\fBvoid *\fR)\&.
1985 Memory allocation error\&.
1990 function returns a pointer to the allocated memory if successful; otherwise a
1992 pointer is returned and
1996 function will fail if:
2002 parameter is not a power of 2\&.
2007 Memory allocation error\&.
2012 function returns a pointer, possibly identical to
2013 \fIptr\fR, to the allocated memory if successful; otherwise a
2015 pointer is returned, and
2019 if the error was the result of an allocation failure\&. The
2021 function always leaves the original buffer intact when an error occurs\&.
2025 function returns no value\&.
2026 .SS "Non\-standard API"
2032 functions return a pointer to the allocated memory if successful; otherwise a
2034 pointer is returned to indicate insufficient contiguous memory was available to service the allocation request\&.
2038 function returns the real size of the resulting resized allocation pointed to by
2039 \fIptr\fR, which is a value less than
2041 if the allocation could not be adequately grown in place\&.
2045 function returns the real size of the allocation pointed to by
2050 returns the real size that would result from a successful equivalent
2052 function call, or zero if insufficient memory is available to perform the size computation\&.
2056 mallctlnametomib(), and
2058 functions return 0 on success; otherwise they return an error value\&. The functions will fail if:
2066 is too large or too small\&. Alternatively,
2068 is too large or too small; in this case as much data as possible are read despite the error\&.
2076 specifies an unknown/invalid value\&.
2081 Attempt to read or write void value, or attempt to write read\-only value\&.
2086 A memory allocation failure occurred\&.
2091 An interface with side effects failed in some way not directly related to
2093 read/write processing\&.
2097 malloc_usable_size()
2098 function returns the usable size of the allocation pointed to by
2102 The following environment variable affects the execution of the allocation functions:
2106 If the environment variable
2108 is set, the characters it contains will be interpreted as options\&.
2112 To dump core whenever a problem occurs:
2118 ln \-s \*(Aqabort:true\*(Aq /etc/malloc\&.conf
2124 To specify in the source a chunk size that is 16 MiB:
2130 malloc_conf = "lg_chunk:24";
2143 \fBgetpagesize\fR(3)
2151 functions conform to ISO/IEC 9899:1990 (\(lqISO C90\(rq)\&.
2155 function conforms to IEEE Std 1003\&.1\-2001 (\(lqPOSIX\&.1\(rq)\&.
2159 malloc_usable_size()
2162 functions first appeared in FreeBSD 7\&.0\&.
2166 malloc_stats_print(), and
2168 functions first appeared in FreeBSD 10\&.0\&.
2172 functions first appeared in FreeBSD 11\&.0\&.
2182 \%http://jemalloc.net/
2187 \%http://www.json.org/
2192 \%http://valgrind.org/
2197 \%http://code.google.com/p/gperftools/