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