The arena size for heap allocations
#include <stdlib.h> unsigned int _amblksiz;
The _amblksiz global variable is the size of an arena, the basic unit that's used for heap allocations to get memory from the system using mmap(). All underlying mmap() operations made by the heap allocator get memory as multiples of _amblksiz. By default, _amblksiz is set to 32 KB. Its value must be a multiple of 4 KB, and currently is limited to being less than 256 KB.
In the current implementation of the allocator, requests for memory larger than 32 KB are automatically serviced by calling mmap() directly, while smaller allocations are serviced by a split-coalesce mechanism inside the allocator.
The value of _amblksiz affects all allocations that are smaller than 32 KB and require a core allocation. Memory that has become free will eventually return to the system when all memory associated with a specific core allocation has been released back to the allocator. Even when a block has been fully released to the allocator, it's possible for the allocator, for efficiency purposes, to retain some blocks locally within the heap (without releasing memory to the system immediately). This is done to avoid thrashing behavior, when requests to allocate and free memory cause the allocator to constantly request and release memory to and from the system.
There are several ways that you can change _amblksiz:
No checking is done, but the value specified here must be a multiple of 4 KB. You can reset _amblksiz to a new value at any time, and this takes effect from that point onwards.
mallopt(MALLOC_ARENA_SIZE, size);
This sets _amblksiz to the value specified by size, rounded up to the nearest multiple of 4 KB. Values above 0x40000 (256 KB) or below 4 KB aren't accepted at this time.
If you specify size as zero, mallopt() returns the current value of _amblksiz.