The increment for the break pointer
#include <stdlib.h> unsigned int _amblksiz
The _amblksiz global variable is 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 8 × PSIZ, or 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 the allocator to constantly request and release memory to and from the system.
There are several ways that you can change _amblksiz:
- Redefine _amblksiz as a global in your code.
Doing this overrides the definition from the library:
unsigned _amblksiz = 8*PSIZ;
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.
It isn't safe for a multithreaded program to dynamically change this value. Multithreaded applications should set this value as a global at compile time, and use the below mechanisms for safely manipulating _amblksiz.
- Set the MALLOC_ARENA_SIZE environment variable to the value you want to assign to _amblksiz. This is evaluated when malloc() is first initialised, so it's done before any allocations. The value specified is rounded up to the nearest multiple of 4 KB. Values above 0x40000 (256 KB) or below 4 KB aren't accepted at this time.
- Call mallopt(MALLOC_ARENA_SIZE, size).
This sets _amblksiz to the value specified by size.
This is evaluated when you call
The value specified is 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 size is specified as zero, mallopt() returns the current value of _amblksiz.
Last modified: 2013-12-23