]> git.saurik.com Git - redis.git/blob - deps/jemalloc/doc/jemalloc.3
Merge pull request #63 from djanowski/tcl
[redis.git] / deps / jemalloc / doc / jemalloc.3
1 '\" t
2 .\" Title: JEMALLOC
3 .\" Author: Jason Evans
4 .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
5 .\" Date: 03/30/2011
6 .\" Manual: User Manual
7 .\" Source: jemalloc 2.2.1-0-g5ef7abf6d846720fb3fb8c737861c99b5ad1d862
8 .\" Language: English
9 .\"
10 .TH "JEMALLOC" "3" "03/30/2011" "jemalloc 2.2.1-0-g5ef7abf6d846" "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 2\&.2\&.1\-0\-g5ef7abf6d846720fb3fb8c737861c99b5ad1d862\&. More information can be found at the
35 \m[blue]\fBjemalloc website\fR\m[]\&\s-2\u[1]\d\s+2\&.
36 .SH "SYNOPSIS"
37 .sp
38 .ft B
39 .nf
40 #include <stdlib\&.h>
41 #include <jemalloc/jemalloc\&.h>
42 .fi
43 .ft
44 .SS "Standard API"
45 .HP \w'void\ *malloc('u
46 .BI "void *malloc(size_t\ " "size" ");"
47 .HP \w'void\ *calloc('u
48 .BI "void *calloc(size_t\ " "number" ", size_t\ " "size" ");"
49 .HP \w'int\ posix_memalign('u
50 .BI "int posix_memalign(void\ **" "ptr" ", size_t\ " "alignment" ", size_t\ " "size" ");"
51 .HP \w'void\ *realloc('u
52 .BI "void *realloc(void\ *" "ptr" ", size_t\ " "size" ");"
53 .HP \w'void\ free('u
54 .BI "void free(void\ *" "ptr" ");"
55 .SS "Non\-standard API"
56 .HP \w'size_t\ malloc_usable_size('u
57 .BI "size_t malloc_usable_size(const\ void\ *" "ptr" ");"
58 .HP \w'void\ malloc_stats_print('u
59 .BI "void malloc_stats_print(void\ " "(*write_cb)" "\ (void\ *,\ const\ char\ *), void\ *" "cbopaque" ", const\ char\ *" "opts" ");"
60 .HP \w'int\ mallctl('u
61 .BI "int mallctl(const\ char\ *" "name" ", void\ *" "oldp" ", size_t\ *" "oldlenp" ", void\ *" "newp" ", size_t\ " "newlen" ");"
62 .HP \w'int\ mallctlnametomib('u
63 .BI "int mallctlnametomib(const\ char\ *" "name" ", size_t\ *" "mibp" ", size_t\ *" "miblenp" ");"
64 .HP \w'int\ mallctlbymib('u
65 .BI "int mallctlbymib(const\ size_t\ *" "mib" ", size_t\ " "miblen" ", void\ *" "oldp" ", size_t\ *" "oldlenp" ", void\ *" "newp" ", size_t\ " "newlen" ");"
66 .HP \w'void\ (*malloc_message)('u
67 .BI "void (*malloc_message)(void\ *" "cbopaque" ", const\ char\ *" "s" ");"
68 .PP
69 const char *\fImalloc_conf\fR;
70 .SS "Experimental API"
71 .HP \w'int\ allocm('u
72 .BI "int allocm(void\ **" "ptr" ", size_t\ *" "rsize" ", size_t\ " "size" ", int\ " "flags" ");"
73 .HP \w'int\ rallocm('u
74 .BI "int rallocm(void\ **" "ptr" ", size_t\ *" "rsize" ", size_t\ " "size" ", size_t\ " "extra" ", int\ " "flags" ");"
75 .HP \w'int\ sallocm('u
76 .BI "int sallocm(const\ void\ *" "ptr" ", size_t\ *" "rsize" ", int\ " "flags" ");"
77 .HP \w'int\ dallocm('u
78 .BI "int dallocm(void\ *" "ptr" ", int\ " "flags" ");"
79 .SH "DESCRIPTION"
80 .SS "Standard API"
81 .PP
82 The
83 \fBmalloc\fR\fB\fR
84 function allocates
85 \fIsize\fR
86 bytes of uninitialized memory\&. The allocated space is suitably aligned (after possible pointer coercion) for storage of any type of object\&.
87 .PP
88 The
89 \fBcalloc\fR\fB\fR
90 function allocates space for
91 \fInumber\fR
92 objects, each
93 \fIsize\fR
94 bytes in length\&. The result is identical to calling
95 \fBmalloc\fR\fB\fR
96 with an argument of
97 \fInumber\fR
98 *
99 \fIsize\fR, with the exception that the allocated memory is explicitly initialized to zero bytes\&.
100 .PP
101 The
102 \fBposix_memalign\fR\fB\fR
103 function allocates
104 \fIsize\fR
105 bytes of memory such that the allocation\*(Aqs base address is an even multiple of
106 \fIalignment\fR, and returns the allocation in the value pointed to by
107 \fIptr\fR\&. The requested
108 \fIalignment\fR
109 must be a power of 2 at least as large as
110 sizeof(\fBvoid *\fR)\&.
111 .PP
112 The
113 \fBrealloc\fR\fB\fR
114 function changes the size of the previously allocated memory referenced by
115 \fIptr\fR
116 to
117 \fIsize\fR
118 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
119 \fIptr\fR
120 is freed and a pointer to the newly allocated memory is returned\&. Note that
121 \fBrealloc\fR\fB\fR
122 may move the memory allocation, resulting in a different return value than
123 \fIptr\fR\&. If
124 \fIptr\fR
125 is
126 \fBNULL\fR, the
127 \fBrealloc\fR\fB\fR
128 function behaves identically to
129 \fBmalloc\fR\fB\fR
130 for the specified size\&.
131 .PP
132 The
133 \fBfree\fR\fB\fR
134 function causes the allocated memory referenced by
135 \fIptr\fR
136 to be made available for future allocations\&. If
137 \fIptr\fR
138 is
139 \fBNULL\fR, no action occurs\&.
140 .SS "Non\-standard API"
141 .PP
142 The
143 \fBmalloc_usable_size\fR\fB\fR
144 function returns the usable size of the allocation pointed to by
145 \fIptr\fR\&. The return value may be larger than the size that was requested during allocation\&. The
146 \fBmalloc_usable_size\fR\fB\fR
147 function is not a mechanism for in\-place
148 \fBrealloc\fR\fB\fR; rather it is provided solely as a tool for introspection purposes\&. Any discrepancy between the requested allocation size and the size reported by
149 \fBmalloc_usable_size\fR\fB\fR
150 should not be depended on, since such behavior is entirely implementation\-dependent\&.
151 .PP
152 The
153 \fBmalloc_stats_print\fR\fB\fR
154 function writes human\-readable summary statistics via the
155 \fIwrite_cb\fR
156 callback function pointer and
157 \fIcbopaque\fR
158 data passed to
159 \fIwrite_cb\fR, or
160 \fBmalloc_message\fR\fB\fR
161 if
162 \fIwrite_cb\fR
163 is
164 \fBNULL\fR\&. This function can be called repeatedly\&. General information that never changes during execution can be omitted by specifying "g" as a character within the
165 \fIopts\fR
166 string\&. Note that
167 \fBmalloc_message\fR\fB\fR
168 uses the
169 \fBmallctl*\fR\fB\fR
170 functions internally, so inconsistent statistics can be reported if multiple threads use these functions simultaneously\&. If
171 \fB\-\-enable\-stats\fR
172 is specified during configuration, \(lqm\(rq and \(lqa\(rq can be specified to omit merged arena and per arena statistics, respectively; \(lqb\(rq and \(lql\(rq can be specified to omit per size class statistics for bins and large 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\&.
173 .PP
174 The
175 \fBmallctl\fR\fB\fR
176 function provides a general interface for introspecting the memory allocator, as well as setting modifiable parameters and triggering actions\&. The period\-separated
177 \fIname\fR
178 argument specifies a location in a tree\-structured namespace; see the
179 MALLCTL NAMESPACE
180 section for documentation on the tree contents\&. To read a value, pass a pointer via
181 \fIoldp\fR
182 to adequate space to contain the value, and a pointer to its length via
183 \fIoldlenp\fR; otherwise pass
184 \fBNULL\fR
185 and
186 \fBNULL\fR\&. Similarly, to write a value, pass a pointer to the value via
187 \fInewp\fR, and its length via
188 \fInewlen\fR; otherwise pass
189 \fBNULL\fR
190 and
191 \fB0\fR\&.
192 .PP
193 The
194 \fBmallctlnametomib\fR\fB\fR
195 function provides a way to avoid repeated name lookups for applications that repeatedly query the same portion of the namespace, by translating a name to a \(lqManagement Information Base\(rq (MIB) that can be passed repeatedly to
196 \fBmallctlbymib\fR\fB\fR\&. Upon successful return from
197 \fBmallctlnametomib\fR\fB\fR,
198 \fImibp\fR
199 contains an array of
200 \fI*miblenp\fR
201 integers, where
202 \fI*miblenp\fR
203 is the lesser of the number of components in
204 \fIname\fR
205 and the input value of
206 \fI*miblenp\fR\&. Thus it is possible to pass a
207 \fI*miblenp\fR
208 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
209 "arenas\&.bin\&.2\&.size"), the corresponding MIB component will always be that integer\&. Therefore, it is legitimate to construct code like the following:
210 .sp
211 .if n \{\
212 .RS 4
213 .\}
214 .nf
215 unsigned nbins, i;
216
217 int mib[4];
218 size_t len, miblen;
219
220 len = sizeof(nbins);
221 mallctl("arenas\&.nbins", &nbins, &len, NULL, 0);
222
223 miblen = 4;
224 mallnametomib("arenas\&.bin\&.0\&.size", mib, &miblen);
225 for (i = 0; i < nbins; i++) {
226 size_t bin_size;
227
228 mib[2] = i;
229 len = sizeof(bin_size);
230 mallctlbymib(mib, miblen, &bin_size, &len, NULL, 0);
231 /* Do something with bin_size\&.\&.\&. */
232 }
233 .fi
234 .if n \{\
235 .RE
236 .\}
237 .SS "Experimental API"
238 .PP
239 The experimental API is subject to change or removal without regard for backward compatibility\&.
240 .PP
241 The
242 \fBallocm\fR\fB\fR,
243 \fBrallocm\fR\fB\fR,
244 \fBsallocm\fR\fB\fR, and
245 \fBdallocm\fR\fB\fR
246 functions all have a
247 \fIflags\fR
248 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:
249 .PP
250 \fBALLOCM_LG_ALIGN(\fR\fB\fIla\fR\fR\fB) \fR
251 .RS 4
252 Align the memory allocation to start at an address that is a multiple of
253 (1 << \fIla\fR)\&. This macro does not validate that
254 \fIla\fR
255 is within the valid range\&.
256 .RE
257 .PP
258 \fBALLOCM_ALIGN(\fR\fB\fIa\fR\fR\fB) \fR
259 .RS 4
260 Align the memory allocation to start at an address that is a multiple of
261 \fIa\fR, where
262 \fIa\fR
263 is a power of two\&. This macro does not validate that
264 \fIa\fR
265 is a power of 2\&.
266 .RE
267 .PP
268 \fBALLOCM_ZERO\fR
269 .RS 4
270 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 option is absent, newly allocated memory is uninitialized\&.
271 .RE
272 .PP
273 \fBALLOCM_NO_MOVE\fR
274 .RS 4
275 For reallocation, fail rather than moving the object\&. This constraint can apply to both growth and shrinkage\&.
276 .RE
277 .PP
278 The
279 \fBallocm\fR\fB\fR
280 function allocates at least
281 \fIsize\fR
282 bytes of memory, sets
283 \fI*ptr\fR
284 to the base address of the allocation, and sets
285 \fI*rsize\fR
286 to the real size of the allocation if
287 \fIrsize\fR
288 is not
289 \fBNULL\fR\&.
290 .PP
291 The
292 \fBrallocm\fR\fB\fR
293 function resizes the allocation at
294 \fI*ptr\fR
295 to be at least
296 \fIsize\fR
297 bytes, sets
298 \fI*ptr\fR
299 to the base address of the allocation if it moved, and sets
300 \fI*rsize\fR
301 to the real size of the allocation if
302 \fIrsize\fR
303 is not
304 \fBNULL\fR\&. If
305 \fIextra\fR
306 is non\-zero, an attempt is made to resize the allocation to be at least
307 \fIsize\fR + \fIextra\fR)
308 bytes, though inability to allocate the extra byte(s) will not by itself result in failure\&. Behavior is undefined if
309 (\fIsize\fR + \fIextra\fR > \fBSIZE_T_MAX\fR)\&.
310 .PP
311 The
312 \fBsallocm\fR\fB\fR
313 function sets
314 \fI*rsize\fR
315 to the real size of the allocation\&.
316 .PP
317 The
318 \fBdallocm\fR\fB\fR
319 function causes the memory referenced by
320 \fIptr\fR
321 to be made available for future allocations\&.
322 .SH "TUNING"
323 .PP
324 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\&.
325 .PP
326 The string pointed to by the global variable
327 \fImalloc_conf\fR, the \(lqname\(rq of the file referenced by the symbolic link named
328 /etc/malloc\&.conf, and the value of the environment variable
329 \fBMALLOC_CONF\fR, will be interpreted, in that order, from left to right as options\&.
330 .PP
331 An options string is a comma\-separated list of option:value pairs\&. There is one key corresponding to each
332 "opt\&.*"
333 mallctl (see the
334 MALLCTL NAMESPACE
335 section for options documentation)\&. For example,
336 abort:true,narenas:1
337 sets the
338 "opt\&.abort"
339 and
340 "opt\&.narenas"
341 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\&.
342 .SH "IMPLEMENTATION NOTES"
343 .PP
344 Traditionally, allocators have used
345 \fBsbrk\fR(2)
346 to obtain memory, which is suboptimal for several reasons, including race conditions, increased fragmentation, and artificial limitations on maximum usable memory\&. If
347 \fB\-\-enable\-dss\fR
348 is specified during configuration, this allocator uses both
349 \fBsbrk\fR(2)
350 and
351 \fBmmap\fR(2), in that order of preference; otherwise only
352 \fBmmap\fR(2)
353 is used\&.
354 .PP
355 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\&.
356 .PP
357 In addition to multiple arenas, unless
358 \fB\-\-disable\-tcache\fR
359 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\&.
360 .PP
361 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\&.
362 .PP
363 User objects are broken into three categories according to size: small, large, and huge\&. Small objects are smaller than one page\&. Large objects are smaller than the chunk size\&. Huge objects are a multiple of the chunk size\&. Small and large objects are managed by arenas; huge objects are managed separately in a single data structure that is shared by all threads\&. Huge objects are used by applications infrequently enough that this single data structure is not a scalability issue\&.
364 .PP
365 Each chunk that is managed by an arena tracks its contents as runs of contiguous pages (unused, backing a set of small objects, or backing one large object)\&. The combination of chunk alignment and chunk page maps makes it possible to determine all metadata regarding small and large allocations in constant time\&.
366 .PP
367 Small objects are managed in groups by page runs\&. Each run maintains a frontier and free list to track which regions are in use\&. Unless
368 \fB\-\-disable\-tiny\fR
369 is specified during configuration, 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
370 sizeof(\fBvoid *\fR)\&. Allocation requests that are more than half the quantum, but no more than the minimum cacheline\-multiple size class (see the
371 "opt\&.lg_qspace_max"
372 option) are rounded up to the nearest multiple of the quantum\&. Allocation requests that are more than the minimum cacheline\-multiple size class, but no more than the minimum subpage\-multiple size class (see the
373 "opt\&.lg_cspace_max"
374 option) are rounded up to the nearest multiple of the cacheline size (64)\&. Allocation requests that are more than the minimum subpage\-multiple size class, but no more than the maximum subpage\-multiple size class are rounded up to the nearest multiple of the subpage size (256)\&. Allocation requests that are more than the maximum subpage\-multiple size class, but small enough to fit in an arena\-managed chunk (see the
375 "opt\&.lg_chunk"
376 option), are rounded up to the nearest run size\&. Allocation requests that are too large to fit in an arena\-managed chunk are rounded up to the nearest multiple of the chunk size\&.
377 .PP
378 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\&.
379 .PP
380 Assuming 4 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
381 Table 1\&.
382 .sp
383 .it 1 an-trap
384 .nr an-no-space-flag 1
385 .nr an-break-flag 1
386 .br
387 .B Table\ \&1.\ \&Size classes
388 .TS
389 allbox tab(:);
390 lB lB lB.
391 T{
392 Category
393 T}:T{
394 Subcategory
395 T}:T{
396 Size
397 T}
398 .T&
399 l l l
400 ^ l l
401 ^ l l
402 ^ l l
403 l s l
404 l s l.
405 T{
406 Small
407 T}:T{
408 Tiny
409 T}:T{
410 [8]
411 T}
412 :T{
413 Quantum\-spaced
414 T}:T{
415 [16, 32, 48, \&.\&.\&., 128]
416 T}
417 :T{
418 Cacheline\-spaced
419 T}:T{
420 [192, 256, 320, \&.\&.\&., 512]
421 T}
422 :T{
423 Subpage\-spaced
424 T}:T{
425 [768, 1024, 1280, \&.\&.\&., 3840]
426 T}
427 T{
428 Large
429 T}:T{
430 [4 KiB, 8 KiB, 12 KiB, \&.\&.\&., 4072 KiB]
431 T}
432 T{
433 Huge
434 T}:T{
435 [4 MiB, 8 MiB, 12 MiB, \&.\&.\&.]
436 T}
437 .TE
438 .sp 1
439 .SH "MALLCTL NAMESPACE"
440 .PP
441 The following names are defined in the namespace accessible via the
442 \fBmallctl*\fR\fB\fR
443 functions\&. Value types are specified in parentheses, their readable/writable statuses are encoded as
444 rw,
445 r\-,
446 \-w, or
447 \-\-, and required build configuration flags follow, if any\&. A name element encoded as
448 <i>
449 or
450 <j>
451 indicates an integer component, where the integer varies from 0 to some upper value that must be determined via introspection\&. In the case of
452 "stats\&.arenas\&.<i>\&.*",
453 <i>
454 equal to
455 "arenas\&.narenas"
456 can be used to access the summation of statistics from all arenas\&. Take special note of the
457 "epoch"
458 mallctl, which controls refreshing of cached dynamic statistics\&.
459 .PP
460 "version" (\fBconst char *\fR) r\-
461 .RS 4
462 Return the jemalloc version string\&.
463 .RE
464 .PP
465 "epoch" (\fBuint64_t\fR) rw
466 .RS 4
467 If a value is passed in, refresh the data from which the
468 \fBmallctl*\fR\fB\fR
469 functions report values, and increment the epoch\&. Return the current epoch\&. This is useful for detecting whether another thread caused a refresh\&.
470 .RE
471 .PP
472 "config\&.debug" (\fBbool\fR) r\-
473 .RS 4
474 \fB\-\-enable\-debug\fR
475 was specified during build configuration\&.
476 .RE
477 .PP
478 "config\&.dss" (\fBbool\fR) r\-
479 .RS 4
480 \fB\-\-enable\-dss\fR
481 was specified during build configuration\&.
482 .RE
483 .PP
484 "config\&.dynamic_page_shift" (\fBbool\fR) r\-
485 .RS 4
486 \fB\-\-enable\-dynamic\-page\-shift\fR
487 was specified during build configuration\&.
488 .RE
489 .PP
490 "config\&.fill" (\fBbool\fR) r\-
491 .RS 4
492 \fB\-\-enable\-fill\fR
493 was specified during build configuration\&.
494 .RE
495 .PP
496 "config\&.lazy_lock" (\fBbool\fR) r\-
497 .RS 4
498 \fB\-\-enable\-lazy\-lock\fR
499 was specified during build configuration\&.
500 .RE
501 .PP
502 "config\&.prof" (\fBbool\fR) r\-
503 .RS 4
504 \fB\-\-enable\-prof\fR
505 was specified during build configuration\&.
506 .RE
507 .PP
508 "config\&.prof_libgcc" (\fBbool\fR) r\-
509 .RS 4
510 \fB\-\-disable\-prof\-libgcc\fR
511 was not specified during build configuration\&.
512 .RE
513 .PP
514 "config\&.prof_libunwind" (\fBbool\fR) r\-
515 .RS 4
516 \fB\-\-enable\-prof\-libunwind\fR
517 was specified during build configuration\&.
518 .RE
519 .PP
520 "config\&.stats" (\fBbool\fR) r\-
521 .RS 4
522 \fB\-\-enable\-stats\fR
523 was specified during build configuration\&.
524 .RE
525 .PP
526 "config\&.swap" (\fBbool\fR) r\-
527 .RS 4
528 \fB\-\-enable\-swap\fR
529 was specified during build configuration\&.
530 .RE
531 .PP
532 "config\&.sysv" (\fBbool\fR) r\-
533 .RS 4
534 \fB\-\-enable\-sysv\fR
535 was specified during build configuration\&.
536 .RE
537 .PP
538 "config\&.tcache" (\fBbool\fR) r\-
539 .RS 4
540 \fB\-\-disable\-tcache\fR
541 was not specified during build configuration\&.
542 .RE
543 .PP
544 "config\&.tiny" (\fBbool\fR) r\-
545 .RS 4
546 \fB\-\-disable\-tiny\fR
547 was not specified during build configuration\&.
548 .RE
549 .PP
550 "config\&.tls" (\fBbool\fR) r\-
551 .RS 4
552 \fB\-\-disable\-tls\fR
553 was not specified during build configuration\&.
554 .RE
555 .PP
556 "config\&.xmalloc" (\fBbool\fR) r\-
557 .RS 4
558 \fB\-\-enable\-xmalloc\fR
559 was specified during build configuration\&.
560 .RE
561 .PP
562 "opt\&.abort" (\fBbool\fR) r\-
563 .RS 4
564 Abort\-on\-warning enabled/disabled\&. If true, most warnings are fatal\&. The process will call
565 \fBabort\fR(3)
566 in these cases\&. This option is disabled by default unless
567 \fB\-\-enable\-debug\fR
568 is specified during configuration, in which case it is enabled by default\&.
569 .RE
570 .PP
571 "opt\&.lg_qspace_max" (\fBsize_t\fR) r\-
572 .RS 4
573 Size (log base 2) of the maximum size class that is a multiple of the quantum (8 or 16 bytes, depending on architecture)\&. Above this size, cacheline spacing is used for size classes\&. The default value is 128 bytes (2^7)\&.
574 .RE
575 .PP
576 "opt\&.lg_cspace_max" (\fBsize_t\fR) r\-
577 .RS 4
578 Size (log base 2) of the maximum size class that is a multiple of the cacheline size (64)\&. Above this size, subpage spacing (256 bytes) is used for size classes\&. The default value is 512 bytes (2^9)\&.
579 .RE
580 .PP
581 "opt\&.lg_chunk" (\fBsize_t\fR) r\-
582 .RS 4
583 Virtual memory chunk size (log base 2)\&. The default chunk size is 4 MiB (2^22)\&.
584 .RE
585 .PP
586 "opt\&.narenas" (\fBsize_t\fR) r\-
587 .RS 4
588 Maximum number of arenas to use\&. The default maximum number of arenas is four times the number of CPUs, or one if there is a single CPU\&.
589 .RE
590 .PP
591 "opt\&.lg_dirty_mult" (\fBssize_t\fR) r\-
592 .RS 4
593 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
594 \fBmadvise\fR(2)
595 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 32:1 (2^5:1); an option value of \-1 will disable dirty page purging\&.
596 .RE
597 .PP
598 "opt\&.stats_print" (\fBbool\fR) r\-
599 .RS 4
600 Enable/disable statistics printing at exit\&. If enabled, the
601 \fBmalloc_stats_print\fR\fB\fR
602 function is called at program exit via an
603 \fBatexit\fR(3)
604 function\&. If
605 \fB\-\-enable\-stats\fR
606 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\&. 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\&.
607 .RE
608 .PP
609 "opt\&.junk" (\fBbool\fR) r\- [\fB\-\-enable\-fill\fR]
610 .RS 4
611 Junk filling enabled/disabled\&. If enabled, each byte of uninitialized allocated memory will be initialized to
612 0xa5\&. All deallocated memory will be initialized to
613 0x5a\&. This is intended for debugging and will impact performance negatively\&. This option is disabled by default unless
614 \fB\-\-enable\-debug\fR
615 is specified during configuration, in which case it is enabled by default\&.
616 .RE
617 .PP
618 "opt\&.zero" (\fBbool\fR) r\- [\fB\-\-enable\-fill\fR]
619 .RS 4
620 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
621 \fBrealloc\fR\fB\fR
622 and
623 \fBrallocm\fR\fB\fR
624 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\&.
625 .RE
626 .PP
627 "opt\&.sysv" (\fBbool\fR) r\- [\fB\-\-enable\-sysv\fR]
628 .RS 4
629 If enabled, attempting to allocate zero bytes will return a
630 \fBNULL\fR
631 pointer instead of a valid pointer\&. (The default behavior is to make a minimal allocation and return a pointer to it\&.) This option is provided for System V compatibility\&. This option is incompatible with the
632 "opt\&.xmalloc"
633 option\&. This option is disabled by default\&.
634 .RE
635 .PP
636 "opt\&.xmalloc" (\fBbool\fR) r\- [\fB\-\-enable\-xmalloc\fR]
637 .RS 4
638 Abort\-on\-out\-of\-memory enabled/disabled\&. If enabled, rather than returning failure for any allocation function, display a diagnostic message on
639 \fBSTDERR_FILENO\fR
640 and cause the program to drop core (using
641 \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:
642 .sp
643 .if n \{\
644 .RS 4
645 .\}
646 .nf
647 malloc_conf = "xmalloc:true";
648 .fi
649 .if n \{\
650 .RE
651 .\}
652 .sp
653 This option is disabled by default\&.
654 .RE
655 .PP
656 "opt\&.tcache" (\fBbool\fR) r\- [\fB\-\-enable\-tcache\fR]
657 .RS 4
658 Thread\-specific caching enabled/disabled\&. When there are multiple threads, each thread uses a thread\-specific cache 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
659 "opt\&.lg_tcache_gc_sweep"
660 and
661 "opt\&.lg_tcache_max"
662 options for related tuning information\&. This option is enabled by default\&.
663 .RE
664 .PP
665 "opt\&.lg_tcache_gc_sweep" (\fBssize_t\fR) r\- [\fB\-\-enable\-tcache\fR]
666 .RS 4
667 Approximate interval (log base 2) between full thread\-specific cache garbage collection sweeps, counted in terms of thread\-specific cache allocation/deallocation events\&. Garbage collection is actually performed incrementally, one size class at a time, in order to avoid large collection pauses\&. The default sweep interval is 8192 (2^13); setting this option to \-1 will disable garbage collection\&.
668 .RE
669 .PP
670 "opt\&.lg_tcache_max" (\fBsize_t\fR) r\- [\fB\-\-enable\-tcache\fR]
671 .RS 4
672 Maximum size class (log base 2) to cache in the thread\-specific cache\&. 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)\&.
673 .RE
674 .PP
675 "opt\&.prof" (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
676 .RS 4
677 Memory profiling enabled/disabled\&. If enabled, profile memory allocation activity, and use an
678 \fBatexit\fR(3)
679 function to dump final memory usage to a file named according to the pattern
680 <prefix>\&.<pid>\&.<seq>\&.f\&.heap, where
681 <prefix>
682 is controlled by the
683 "opt\&.prof_prefix"
684 option\&. See the
685 "opt\&.lg_prof_bt_max"
686 option for backtrace depth control\&. See the
687 "opt\&.prof_active"
688 option for on\-the\-fly activation/deactivation\&. See the
689 "opt\&.lg_prof_sample"
690 option for probabilistic sampling control\&. See the
691 "opt\&.prof_accum"
692 option for control of cumulative sample reporting\&. See the
693 "opt\&.lg_prof_tcmax"
694 option for control of per thread backtrace caching\&. See the
695 "opt\&.lg_prof_interval"
696 option for information on interval\-triggered profile dumping, and the
697 "opt\&.prof_gdump"
698 option for information on high\-water\-triggered profile dumping\&. Profile output is compatible with the included
699 \fBpprof\fR
700 Perl script, which originates from the
701 \m[blue]\fBgoogle\-perftools package\fR\m[]\&\s-2\u[2]\d\s+2\&.
702 .RE
703 .PP
704 "opt\&.prof_prefix" (\fBconst char *\fR) r\- [\fB\-\-enable\-prof\fR]
705 .RS 4
706 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
707 jeprof\&.
708 .RE
709 .PP
710 "opt\&.lg_prof_bt_max" (\fBsize_t\fR) r\- [\fB\-\-enable\-prof\fR]
711 .RS 4
712 Maximum backtrace depth (log base 2) when profiling memory allocation activity\&. The default is 128 (2^7)\&.
713 .RE
714 .PP
715 "opt\&.prof_active" (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
716 .RS 4
717 Profiling activated/deactivated\&. This is a secondary control mechanism that makes it possible to start the application with profiling enabled (see the
718 "opt\&.prof"
719 option) but inactive, then toggle profiling at any time during program execution with the
720 "prof\&.active"
721 mallctl\&. This option is enabled by default\&.
722 .RE
723 .PP
724 "opt\&.lg_prof_sample" (\fBssize_t\fR) r\- [\fB\-\-enable\-prof\fR]
725 .RS 4
726 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 1 (2^0) (i\&.e\&. all allocations are sampled)\&.
727 .RE
728 .PP
729 "opt\&.prof_accum" (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
730 .RS 4
731 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\&. See the
732 "opt\&.lg_prof_tcmax"
733 option for control of per thread backtrace caching, which has important interactions\&. This option is enabled by default\&.
734 .RE
735 .PP
736 "opt\&.lg_prof_tcmax" (\fBssize_t\fR) r\- [\fB\-\-enable\-prof\fR]
737 .RS 4
738 Maximum per thread backtrace cache (log base 2) used for heap profiling\&. A backtrace can only be discarded if the
739 "opt\&.prof_accum"
740 option is disabled, and no thread caches currently refer to the backtrace\&. Therefore, a backtrace cache limit should be imposed if the intention is to limit how much memory is used by backtraces\&. By default, no limit is imposed (encoded as \-1)\&.
741 .RE
742 .PP
743 "opt\&.lg_prof_interval" (\fBssize_t\fR) r\- [\fB\-\-enable\-prof\fR]
744 .RS 4
745 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
746 <prefix>\&.<pid>\&.<seq>\&.i<iseq>\&.heap, where
747 <prefix>
748 is controlled by the
749 "opt\&.prof_prefix"
750 option\&. By default, interval\-triggered profile dumping is disabled (encoded as \-1)\&.
751 .RE
752 .PP
753 "opt\&.prof_gdump" (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
754 .RS 4
755 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
756 <prefix>\&.<pid>\&.<seq>\&.u<useq>\&.heap, where
757 <prefix>
758 is controlled by the
759 "opt\&.prof_prefix"
760 option\&. This option is disabled by default\&.
761 .RE
762 .PP
763 "opt\&.prof_leak" (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
764 .RS 4
765 Leak reporting enabled/disabled\&. If enabled, use an
766 \fBatexit\fR(3)
767 function to report memory leaks detected by allocation sampling\&. See the
768 "opt\&.lg_prof_bt_max"
769 option for backtrace depth control\&. See the
770 "opt\&.prof"
771 option for information on analyzing heap profile output\&. This option is disabled by default\&.
772 .RE
773 .PP
774 "opt\&.overcommit" (\fBbool\fR) r\- [\fB\-\-enable\-swap\fR]
775 .RS 4
776 Over\-commit enabled/disabled\&. If enabled, over\-commit memory as a side effect of using anonymous
777 \fBmmap\fR(2)
778 or
779 \fBsbrk\fR(2)
780 for virtual memory allocation\&. In order for overcommit to be disabled, the
781 "swap\&.fds"
782 mallctl must have been successfully written to\&. This option is enabled by default\&.
783 .RE
784 .PP
785 "tcache\&.flush" (\fBvoid\fR) \-\- [\fB\-\-enable\-tcache\fR]
786 .RS 4
787 Flush calling thread\*(Aqs tcache\&. This interface releases all cached objects and internal data structures associated with the calling thread\*(Aqs thread\-specific cache\&. 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\&.
788 .RE
789 .PP
790 "thread\&.arena" (\fBunsigned\fR) rw
791 .RS 4
792 Get or set the arena associated with the calling thread\&. The arena index must be less than the maximum number of arenas (see the
793 "arenas\&.narenas"
794 mallctl)\&. If the specified arena was not initialized beforehand (see the
795 "arenas\&.initialized"
796 mallctl), it will be automatically initialized as a side effect of calling this interface\&.
797 .RE
798 .PP
799 "thread\&.allocated" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
800 .RS 4
801 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\&.
802 .RE
803 .PP
804 "thread\&.allocatedp" (\fBuint64_t *\fR) r\- [\fB\-\-enable\-stats\fR]
805 .RS 4
806 Get a pointer to the the value that is returned by the
807 "thread\&.allocated"
808 mallctl\&. This is useful for avoiding the overhead of repeated
809 \fBmallctl*\fR\fB\fR
810 calls\&.
811 .RE
812 .PP
813 "thread\&.deallocated" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
814 .RS 4
815 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\&.
816 .RE
817 .PP
818 "thread\&.deallocatedp" (\fBuint64_t *\fR) r\- [\fB\-\-enable\-stats\fR]
819 .RS 4
820 Get a pointer to the the value that is returned by the
821 "thread\&.deallocated"
822 mallctl\&. This is useful for avoiding the overhead of repeated
823 \fBmallctl*\fR\fB\fR
824 calls\&.
825 .RE
826 .PP
827 "arenas\&.narenas" (\fBunsigned\fR) r\-
828 .RS 4
829 Maximum number of arenas\&.
830 .RE
831 .PP
832 "arenas\&.initialized" (\fBbool *\fR) r\-
833 .RS 4
834 An array of
835 "arenas\&.narenas"
836 booleans\&. Each boolean indicates whether the corresponding arena is initialized\&.
837 .RE
838 .PP
839 "arenas\&.quantum" (\fBsize_t\fR) r\-
840 .RS 4
841 Quantum size\&.
842 .RE
843 .PP
844 "arenas\&.cacheline" (\fBsize_t\fR) r\-
845 .RS 4
846 Assumed cacheline size\&.
847 .RE
848 .PP
849 "arenas\&.subpage" (\fBsize_t\fR) r\-
850 .RS 4
851 Subpage size class interval\&.
852 .RE
853 .PP
854 "arenas\&.pagesize" (\fBsize_t\fR) r\-
855 .RS 4
856 Page size\&.
857 .RE
858 .PP
859 "arenas\&.chunksize" (\fBsize_t\fR) r\-
860 .RS 4
861 Chunk size\&.
862 .RE
863 .PP
864 "arenas\&.tspace_min" (\fBsize_t\fR) r\-
865 .RS 4
866 Minimum tiny size class\&. Tiny size classes are powers of two\&.
867 .RE
868 .PP
869 "arenas\&.tspace_max" (\fBsize_t\fR) r\-
870 .RS 4
871 Maximum tiny size class\&. Tiny size classes are powers of two\&.
872 .RE
873 .PP
874 "arenas\&.qspace_min" (\fBsize_t\fR) r\-
875 .RS 4
876 Minimum quantum\-spaced size class\&.
877 .RE
878 .PP
879 "arenas\&.qspace_max" (\fBsize_t\fR) r\-
880 .RS 4
881 Maximum quantum\-spaced size class\&.
882 .RE
883 .PP
884 "arenas\&.cspace_min" (\fBsize_t\fR) r\-
885 .RS 4
886 Minimum cacheline\-spaced size class\&.
887 .RE
888 .PP
889 "arenas\&.cspace_max" (\fBsize_t\fR) r\-
890 .RS 4
891 Maximum cacheline\-spaced size class\&.
892 .RE
893 .PP
894 "arenas\&.sspace_min" (\fBsize_t\fR) r\-
895 .RS 4
896 Minimum subpage\-spaced size class\&.
897 .RE
898 .PP
899 "arenas\&.sspace_max" (\fBsize_t\fR) r\-
900 .RS 4
901 Maximum subpage\-spaced size class\&.
902 .RE
903 .PP
904 "arenas\&.tcache_max" (\fBsize_t\fR) r\- [\fB\-\-enable\-tcache\fR]
905 .RS 4
906 Maximum thread\-cached size class\&.
907 .RE
908 .PP
909 "arenas\&.ntbins" (\fBunsigned\fR) r\-
910 .RS 4
911 Number of tiny bin size classes\&.
912 .RE
913 .PP
914 "arenas\&.nqbins" (\fBunsigned\fR) r\-
915 .RS 4
916 Number of quantum\-spaced bin size classes\&.
917 .RE
918 .PP
919 "arenas\&.ncbins" (\fBunsigned\fR) r\-
920 .RS 4
921 Number of cacheline\-spaced bin size classes\&.
922 .RE
923 .PP
924 "arenas\&.nsbins" (\fBunsigned\fR) r\-
925 .RS 4
926 Number of subpage\-spaced bin size classes\&.
927 .RE
928 .PP
929 "arenas\&.nbins" (\fBunsigned\fR) r\-
930 .RS 4
931 Total number of bin size classes\&.
932 .RE
933 .PP
934 "arenas\&.nhbins" (\fBunsigned\fR) r\- [\fB\-\-enable\-tcache\fR]
935 .RS 4
936 Total number of thread cache bin size classes\&.
937 .RE
938 .PP
939 "arenas\&.bin\&.<i>\&.size" (\fBsize_t\fR) r\-
940 .RS 4
941 Maximum size supported by size class\&.
942 .RE
943 .PP
944 "arenas\&.bin\&.<i>\&.nregs" (\fBuint32_t\fR) r\-
945 .RS 4
946 Number of regions per page run\&.
947 .RE
948 .PP
949 "arenas\&.bin\&.<i>\&.run_size" (\fBsize_t\fR) r\-
950 .RS 4
951 Number of bytes per page run\&.
952 .RE
953 .PP
954 "arenas\&.nlruns" (\fBsize_t\fR) r\-
955 .RS 4
956 Total number of large size classes\&.
957 .RE
958 .PP
959 "arenas\&.lrun\&.<i>\&.size" (\fBsize_t\fR) r\-
960 .RS 4
961 Maximum size supported by this large size class\&.
962 .RE
963 .PP
964 "arenas\&.purge" (\fBunsigned\fR) \-w
965 .RS 4
966 Purge unused dirty pages for the specified arena, or for all arenas if none is specified\&.
967 .RE
968 .PP
969 "prof\&.active" (\fBbool\fR) rw [\fB\-\-enable\-prof\fR]
970 .RS 4
971 Control whether sampling is currently active\&. See the
972 "opt\&.prof_active"
973 option for additional information\&.
974 .RE
975 .PP
976 "prof\&.dump" (\fBconst char *\fR) \-w [\fB\-\-enable\-prof\fR]
977 .RS 4
978 Dump a memory profile to the specified file, or if NULL is specified, to a file according to the pattern
979 <prefix>\&.<pid>\&.<seq>\&.m<mseq>\&.heap, where
980 <prefix>
981 is controlled by the
982 "opt\&.prof_prefix"
983 option\&.
984 .RE
985 .PP
986 "prof\&.interval" (\fBuint64_t\fR) r\- [\fB\-\-enable\-prof\fR]
987 .RS 4
988 Average number of bytes allocated between inverval\-based profile dumps\&. See the
989 "opt\&.lg_prof_interval"
990 option for additional information\&.
991 .RE
992 .PP
993 "stats\&.cactive" (\fBsize_t *\fR) r\- [\fB\-\-enable\-stats\fR]
994 .RS 4
995 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 to the nearest multiple of the chunk size when computing its contribution to the counter\&. Note that the
996 "epoch"
997 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\&.
998 .RE
999 .PP
1000 "stats\&.allocated" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1001 .RS 4
1002 Total number of bytes allocated by the application\&.
1003 .RE
1004 .PP
1005 "stats\&.active" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1006 .RS 4
1007 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
1008 "stats\&.allocated"\&.
1009 .RE
1010 .PP
1011 "stats\&.mapped" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1012 .RS 4
1013 Total number of bytes in chunks mapped on behalf of the application\&. This is a multiple of the chunk size, and is at least as large as
1014 "stats\&.active"\&. This does not include inactive chunks backed by swap files\&. his does not include inactive chunks embedded in the DSS\&.
1015 .RE
1016 .PP
1017 "stats\&.chunks\&.current" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1018 .RS 4
1019 Total number of chunks actively mapped on behalf of the application\&. This does not include inactive chunks backed by swap files\&. This does not include inactive chunks embedded in the DSS\&.
1020 .RE
1021 .PP
1022 "stats\&.chunks\&.total" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1023 .RS 4
1024 Cumulative number of chunks allocated\&.
1025 .RE
1026 .PP
1027 "stats\&.chunks\&.high" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1028 .RS 4
1029 Maximum number of active chunks at any time thus far\&.
1030 .RE
1031 .PP
1032 "stats\&.huge\&.allocated" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1033 .RS 4
1034 Number of bytes currently allocated by huge objects\&.
1035 .RE
1036 .PP
1037 "stats\&.huge\&.nmalloc" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1038 .RS 4
1039 Cumulative number of huge allocation requests\&.
1040 .RE
1041 .PP
1042 "stats\&.huge\&.ndalloc" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1043 .RS 4
1044 Cumulative number of huge deallocation requests\&.
1045 .RE
1046 .PP
1047 "stats\&.arenas\&.<i>\&.nthreads" (\fBunsigned\fR) r\-
1048 .RS 4
1049 Number of threads currently assigned to arena\&.
1050 .RE
1051 .PP
1052 "stats\&.arenas\&.<i>\&.pactive" (\fBsize_t\fR) r\-
1053 .RS 4
1054 Number of pages in active runs\&.
1055 .RE
1056 .PP
1057 "stats\&.arenas\&.<i>\&.pdirty" (\fBsize_t\fR) r\-
1058 .RS 4
1059 Number of pages within unused runs that are potentially dirty, and for which
1060 \fBmadvise\fR\fB\fI\&.\&.\&.\fR\fR\fB \fR\fB\fI\fBMADV_DONTNEED\fR\fR\fR
1061 or similar has not been called\&.
1062 .RE
1063 .PP
1064 "stats\&.arenas\&.<i>\&.mapped" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1065 .RS 4
1066 Number of mapped bytes\&.
1067 .RE
1068 .PP
1069 "stats\&.arenas\&.<i>\&.npurge" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1070 .RS 4
1071 Number of dirty page purge sweeps performed\&.
1072 .RE
1073 .PP
1074 "stats\&.arenas\&.<i>\&.nmadvise" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1075 .RS 4
1076 Number of
1077 \fBmadvise\fR\fB\fI\&.\&.\&.\fR\fR\fB \fR\fB\fI\fBMADV_DONTNEED\fR\fR\fR
1078 or similar calls made to purge dirty pages\&.
1079 .RE
1080 .PP
1081 "stats\&.arenas\&.<i>\&.npurged" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1082 .RS 4
1083 Number of pages purged\&.
1084 .RE
1085 .PP
1086 "stats\&.arenas\&.<i>\&.small\&.allocated" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1087 .RS 4
1088 Number of bytes currently allocated by small objects\&.
1089 .RE
1090 .PP
1091 "stats\&.arenas\&.<i>\&.small\&.nmalloc" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1092 .RS 4
1093 Cumulative number of allocation requests served by small bins\&.
1094 .RE
1095 .PP
1096 "stats\&.arenas\&.<i>\&.small\&.ndalloc" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1097 .RS 4
1098 Cumulative number of small objects returned to bins\&.
1099 .RE
1100 .PP
1101 "stats\&.arenas\&.<i>\&.small\&.nrequests" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1102 .RS 4
1103 Cumulative number of small allocation requests\&.
1104 .RE
1105 .PP
1106 "stats\&.arenas\&.<i>\&.large\&.allocated" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1107 .RS 4
1108 Number of bytes currently allocated by large objects\&.
1109 .RE
1110 .PP
1111 "stats\&.arenas\&.<i>\&.large\&.nmalloc" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1112 .RS 4
1113 Cumulative number of large allocation requests served directly by the arena\&.
1114 .RE
1115 .PP
1116 "stats\&.arenas\&.<i>\&.large\&.ndalloc" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1117 .RS 4
1118 Cumulative number of large deallocation requests served directly by the arena\&.
1119 .RE
1120 .PP
1121 "stats\&.arenas\&.<i>\&.large\&.nrequests" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1122 .RS 4
1123 Cumulative number of large allocation requests\&.
1124 .RE
1125 .PP
1126 "stats\&.arenas\&.<i>\&.bins\&.<j>\&.allocated" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1127 .RS 4
1128 Current number of bytes allocated by bin\&.
1129 .RE
1130 .PP
1131 "stats\&.arenas\&.<i>\&.bins\&.<j>\&.nmalloc" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1132 .RS 4
1133 Cumulative number of allocations served by bin\&.
1134 .RE
1135 .PP
1136 "stats\&.arenas\&.<i>\&.bins\&.<j>\&.ndalloc" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1137 .RS 4
1138 Cumulative number of allocations returned to bin\&.
1139 .RE
1140 .PP
1141 "stats\&.arenas\&.<i>\&.bins\&.<j>\&.nrequests" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1142 .RS 4
1143 Cumulative number of allocation requests\&.
1144 .RE
1145 .PP
1146 "stats\&.arenas\&.<i>\&.bins\&.<j>\&.nfills" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR \fB\-\-enable\-tcache\fR]
1147 .RS 4
1148 Cumulative number of tcache fills\&.
1149 .RE
1150 .PP
1151 "stats\&.arenas\&.<i>\&.bins\&.<j>\&.nflushes" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR \fB\-\-enable\-tcache\fR]
1152 .RS 4
1153 Cumulative number of tcache flushes\&.
1154 .RE
1155 .PP
1156 "stats\&.arenas\&.<i>\&.bins\&.<j>\&.nruns" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1157 .RS 4
1158 Cumulative number of runs created\&.
1159 .RE
1160 .PP
1161 "stats\&.arenas\&.<i>\&.bins\&.<j>\&.nreruns" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1162 .RS 4
1163 Cumulative number of times the current run from which to allocate changed\&.
1164 .RE
1165 .PP
1166 "stats\&.arenas\&.<i>\&.bins\&.<j>\&.highruns" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1167 .RS 4
1168 Maximum number of runs at any time thus far\&.
1169 .RE
1170 .PP
1171 "stats\&.arenas\&.<i>\&.bins\&.<j>\&.curruns" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1172 .RS 4
1173 Current number of runs\&.
1174 .RE
1175 .PP
1176 "stats\&.arenas\&.<i>\&.lruns\&.<j>\&.nmalloc" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1177 .RS 4
1178 Cumulative number of allocation requests for this size class served directly by the arena\&.
1179 .RE
1180 .PP
1181 "stats\&.arenas\&.<i>\&.lruns\&.<j>\&.ndalloc" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1182 .RS 4
1183 Cumulative number of deallocation requests for this size class served directly by the arena\&.
1184 .RE
1185 .PP
1186 "stats\&.arenas\&.<i>\&.lruns\&.<j>\&.nrequests" (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
1187 .RS 4
1188 Cumulative number of allocation requests for this size class\&.
1189 .RE
1190 .PP
1191 "stats\&.arenas\&.<i>\&.lruns\&.<j>\&.highruns" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1192 .RS 4
1193 Maximum number of runs at any time thus far for this size class\&.
1194 .RE
1195 .PP
1196 "stats\&.arenas\&.<i>\&.lruns\&.<j>\&.curruns" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
1197 .RS 4
1198 Current number of runs for this size class\&.
1199 .RE
1200 .PP
1201 "swap\&.avail" (\fBsize_t\fR) r\- [\fB\-\-enable\-stats \-\-enable\-swap\fR]
1202 .RS 4
1203 Number of swap file bytes that are currently not associated with any chunk (i\&.e\&. mapped, but otherwise completely unmanaged)\&.
1204 .RE
1205 .PP
1206 "swap\&.prezeroed" (\fBbool\fR) rw [\fB\-\-enable\-swap\fR]
1207 .RS 4
1208 If true, the allocator assumes that the swap file(s) contain nothing but nil bytes\&. If this assumption is violated, allocator behavior is undefined\&. This value becomes read\-only after
1209 "swap\&.fds"
1210 is successfully written to\&.
1211 .RE
1212 .PP
1213 "swap\&.nfds" (\fBsize_t\fR) r\- [\fB\-\-enable\-swap\fR]
1214 .RS 4
1215 Number of file descriptors in use for swap\&.
1216 .RE
1217 .PP
1218 "swap\&.fds" (\fBint *\fR) r\- [\fB\-\-enable\-swap\fR]
1219 .RS 4
1220 When written to, the files associated with the specified file descriptors are contiguously mapped via
1221 \fBmmap\fR(2)\&. The resulting virtual memory region is preferred over anonymous
1222 \fBmmap\fR(2)
1223 and
1224 \fBsbrk\fR(2)
1225 memory\&. Note that if a file\*(Aqs size is not a multiple of the page size, it is automatically truncated to the nearest page size multiple\&. See the
1226 "swap\&.prezeroed"
1227 mallctl for specifying that the files are pre\-zeroed\&.
1228 .RE
1229 .SH "DEBUGGING MALLOC PROBLEMS"
1230 .PP
1231 When debugging, it is a good idea to configure/build jemalloc with the
1232 \fB\-\-enable\-debug\fR
1233 and
1234 \fB\-\-enable\-fill\fR
1235 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\&.
1236 .PP
1237 Programs often accidentally depend on \(lquninitialized\(rq memory actually being filled with zero bytes\&. Junk filling (see the
1238 "opt\&.junk"
1239 option) tends to expose such bugs in the form of obviously incorrect results and/or coredumps\&. Conversely, zero filling (see the
1240 "opt\&.zero"
1241 option) eliminates the symptoms of such bugs\&. Between these two options, it is usually possible to quickly detect, diagnose, and eliminate such bugs\&.
1242 .PP
1243 This implementation does not provide much detail about the problems it detects, because the performance impact for storing such information would be prohibitive\&. There are a number of allocator implementations available on the Internet which focus on detecting and pinpointing problems by trading performance for extra sanity checks and detailed diagnostics\&.
1244 .SH "DIAGNOSTIC MESSAGES"
1245 .PP
1246 If any of the memory allocation/deallocation functions detect an error or warning condition, a message will be printed to file descriptor
1247 \fBSTDERR_FILENO\fR\&. Errors will result in the process dumping core\&. If the
1248 "opt\&.abort"
1249 option is set, most warnings are treated as errors\&.
1250 .PP
1251 The
1252 \fImalloc_message\fR
1253 variable allows the programmer to override the function which emits the text strings forming the errors and warnings if for some reason the
1254 \fBSTDERR_FILENO\fR
1255 file descriptor is not suitable for this\&.
1256 \fBmalloc_message\fR\fB\fR
1257 takes the
1258 \fIcbopaque\fR
1259 pointer argument that is
1260 \fBNULL\fR
1261 unless overridden by the arguments in a call to
1262 \fBmalloc_stats_print\fR\fB\fR, followed by a string pointer\&. Please note that doing anything which tries to allocate memory in this function is likely to result in a crash or deadlock\&.
1263 .PP
1264 All messages are prefixed by \(lq<jemalloc>:\(rq\&.
1265 .SH "RETURN VALUES"
1266 .SS "Standard API"
1267 .PP
1268 The
1269 \fBmalloc\fR\fB\fR
1270 and
1271 \fBcalloc\fR\fB\fR
1272 functions return a pointer to the allocated memory if successful; otherwise a
1273 \fBNULL\fR
1274 pointer is returned and
1275 \fIerrno\fR
1276 is set to
1277 ENOMEM\&.
1278 .PP
1279 The
1280 \fBposix_memalign\fR\fB\fR
1281 function returns the value 0 if successful; otherwise it returns an error value\&. The
1282 \fBposix_memalign\fR\fB\fR
1283 function will fail if:
1284 .PP
1285 EINVAL
1286 .RS 4
1287 The
1288 \fIalignment\fR
1289 parameter is not a power of 2 at least as large as
1290 sizeof(\fBvoid *\fR)\&.
1291 .RE
1292 .PP
1293 ENOMEM
1294 .RS 4
1295 Memory allocation error\&.
1296 .RE
1297 .PP
1298 The
1299 \fBrealloc\fR\fB\fR
1300 function returns a pointer, possibly identical to
1301 \fIptr\fR, to the allocated memory if successful; otherwise a
1302 \fBNULL\fR
1303 pointer is returned, and
1304 \fIerrno\fR
1305 is set to
1306 ENOMEM
1307 if the error was the result of an allocation failure\&. The
1308 \fBrealloc\fR\fB\fR
1309 function always leaves the original buffer intact when an error occurs\&.
1310 .PP
1311 The
1312 \fBfree\fR\fB\fR
1313 function returns no value\&.
1314 .SS "Non\-standard API"
1315 .PP
1316 The
1317 \fBmalloc_usable_size\fR\fB\fR
1318 function returns the usable size of the allocation pointed to by
1319 \fIptr\fR\&.
1320 .PP
1321 The
1322 \fBmallctl\fR\fB\fR,
1323 \fBmallctlnametomib\fR\fB\fR, and
1324 \fBmallctlbymib\fR\fB\fR
1325 functions return 0 on success; otherwise they return an error value\&. The functions will fail if:
1326 .PP
1327 EINVAL
1328 .RS 4
1329 \fInewp\fR
1330 is not
1331 \fBNULL\fR, and
1332 \fInewlen\fR
1333 is too large or too small\&. Alternatively,
1334 \fI*oldlenp\fR
1335 is too large or too small; in this case as much data as possible are read despite the error\&.
1336 .RE
1337 .PP
1338 ENOMEM
1339 .RS 4
1340 \fI*oldlenp\fR
1341 is too short to hold the requested value\&.
1342 .RE
1343 .PP
1344 ENOENT
1345 .RS 4
1346 \fIname\fR
1347 or
1348 \fImib\fR
1349 specifies an unknown/invalid value\&.
1350 .RE
1351 .PP
1352 EPERM
1353 .RS 4
1354 Attempt to read or write void value, or attempt to write read\-only value\&.
1355 .RE
1356 .PP
1357 EAGAIN
1358 .RS 4
1359 A memory allocation failure occurred\&.
1360 .RE
1361 .PP
1362 EFAULT
1363 .RS 4
1364 An interface with side effects failed in some way not directly related to
1365 \fBmallctl*\fR\fB\fR
1366 read/write processing\&.
1367 .RE
1368 .SS "Experimental API"
1369 .PP
1370 The
1371 \fBallocm\fR\fB\fR,
1372 \fBrallocm\fR\fB\fR,
1373 \fBsallocm\fR\fB\fR, and
1374 \fBdallocm\fR\fB\fR
1375 functions return
1376 \fBALLOCM_SUCCESS\fR
1377 on success; otherwise they return an error value\&. The
1378 \fBallocm\fR\fB\fR
1379 and
1380 \fBrallocm\fR\fB\fR
1381 functions will fail if:
1382 .PP
1383 ALLOCM_ERR_OOM
1384 .RS 4
1385 Out of memory\&. Insufficient contiguous memory was available to service the allocation request\&. The
1386 \fBallocm\fR\fB\fR
1387 function additionally sets
1388 \fI*ptr\fR
1389 to
1390 \fBNULL\fR, whereas the
1391 \fBrallocm\fR\fB\fR
1392 function leaves
1393 \fB*ptr\fR
1394 unmodified\&.
1395 .RE
1396 The
1397 \fBrallocm\fR\fB\fR
1398 function will also fail if:
1399 .PP
1400 ALLOCM_ERR_NOT_MOVED
1401 .RS 4
1402 \fBALLOCM_NO_MOVE\fR
1403 was specified, but the reallocation request could not be serviced without moving the object\&.
1404 .RE
1405 .SH "ENVIRONMENT"
1406 .PP
1407 The following environment variable affects the execution of the allocation functions:
1408 .PP
1409 \fBMALLOC_CONF\fR
1410 .RS 4
1411 If the environment variable
1412 \fBMALLOC_CONF\fR
1413 is set, the characters it contains will be interpreted as options\&.
1414 .RE
1415 .SH "EXAMPLES"
1416 .PP
1417 To dump core whenever a problem occurs:
1418 .sp
1419 .if n \{\
1420 .RS 4
1421 .\}
1422 .nf
1423 ln \-s \*(Aqabort:true\*(Aq /etc/malloc\&.conf
1424 .fi
1425 .if n \{\
1426 .RE
1427 .\}
1428 .PP
1429 To specify in the source a chunk size that is 16 MiB:
1430 .sp
1431 .if n \{\
1432 .RS 4
1433 .\}
1434 .nf
1435 malloc_conf = "lg_chunk:24";
1436 .fi
1437 .if n \{\
1438 .RE
1439 .\}
1440 .SH "SEE ALSO"
1441 .PP
1442 \fBmadvise\fR(2),
1443 \fBmmap\fR(2),
1444 \fBsbrk\fR(2),
1445 \fBalloca\fR(3),
1446 \fBatexit\fR(3),
1447 \fBgetpagesize\fR(3)
1448 .SH "STANDARDS"
1449 .PP
1450 The
1451 \fBmalloc\fR\fB\fR,
1452 \fBcalloc\fR\fB\fR,
1453 \fBrealloc\fR\fB\fR, and
1454 \fBfree\fR\fB\fR
1455 functions conform to ISO/IEC 9899:1990 (\(lqISO C90\(rq)\&.
1456 .PP
1457 The
1458 \fBposix_memalign\fR\fB\fR
1459 function conforms to IEEE Std 1003\&.1\-2001 (\(lqPOSIX\&.1\(rq)\&.
1460 .SH "AUTHOR"
1461 .PP
1462 \fBJason Evans\fR
1463 .RS 4
1464 .RE
1465 .SH "NOTES"
1466 .IP " 1." 4
1467 jemalloc website
1468 .RS 4
1469 \%http://www.canonware.com/jemalloc/
1470 .RE
1471 .IP " 2." 4
1472 google-perftools package
1473 .RS 4
1474 \%http://code.google.com/p/google-perftools/
1475 .RE