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:


QNX Neutrino

See also:

malloc(), mallopt(), mmap()

The Heap Analysis chapter of the Neutrino Programmer's Guide.