libmtmalloc - multi-threaded memory allocator library
cc [ flag... ] file... –lmtmalloc [ library... ] #include <mtmalloc.h>
Functions in this library provide concurrent access to heap space.
The shared object libmtmalloc.so.1 provides the public interfaces defined below. See Intro(3) for additional information on shared object interfaces.
A comma separated list of options. The supported options are:
By default, libmtmalloc allocates 2*NCPUS buckets from which allocations occur. Threads share buckets based on their thread ID. If MTEXCLUSIVE is invoked, then 4*NCPUS buckets are used. Threads with thread id less than 2*NCPUS receive an exclusive bucket and thus do not need to use locks. Allocation performance for these buckets may be dramatically increased. One enabled MTEXCLUSIVE can not be disabled. This feature can be enabled by setting the MTMALLOC_OPTION MTEXCLUSIVE to “Y” or “y” or anything beginning with “y”. Alternatively it can be enabled by a call to mallocctl(3MALLOC).
By default, allocations less than 216 bytes are allocated from buckets indexed by thread id. Using this MTMALLOC_OPTION setting, variable size of the cached allocations can be increased to 217, 218, 218, 219, 220, or 221 by setting MTMAXCACHE to 17, 18, 19, 20, or 21. If MTMAXCACHE is set to less than 16 it is reset to 16. If MTMAXCACHE is set to more than 21, then it is reset to 21. This all occurs silently.
Allocation buckets are sized by the chunk size and the size of the allocation request. The default setting is 9 for 32-bit applications and 64 for 64 bit applications. For the cost of address space, performance can sometimes be enhanced by increasing this parameter. See mallocctl(3MALLOC).
If xx > 1, set the threshold for calling madvise(3C) with MADV_FREE. Calling madvise() will result in the memory associated with the allocation being returned to the kernel. When freed, allocations greater than xx*pagesize will have madvise() called. If xx is less than 2, it will be set to 2.
Writes misaligned data into the buffer after free(). When the buffer is reallocated, the contents are verified to ensure that there was no access to the buffer after the free. If the buffer has been dirtied, a SIGABRT signal is delivered to the process. The default behavior is not to write misaligned data. The pattern used is 0xdeadbeef. Use of this option results in a performance penalty.
Writes misaligned data into the newly allocated buffer. This option is useful for detecting some accesses before initialization. The default behavior is not to write misaligned data to the newly allocated buffer. The pattern used is 0xbaddcafe. Use of this option results in a performance penalty.
Allows double free of a pointer. The default behavior of double free results in a core dump.
64–bit shared object
See attributes(5) for descriptions of the following attributes: