The GNU C Library
22.214.171.124 Efficiency Considerations for
As opposed to other versions, the
malloc in the GNU C Library
does not round up block sizes to powers of two, neither for large nor
for small sizes. Neighboring chunks can be coalesced on a
no matter what their size is. This makes the implementation suitable
for all kinds of allocation patterns without generally incurring high
memory waste through fragmentation.
Very large blocks (much larger than a page) are allocated with
mmap (anonymous or via
/dev/zero) by this implementation.
This has the great advantage that these chunks are returned to the
system immediately when they are freed. Therefore, it cannot happen
that a large chunk becomes "locked" in between smaller ones and even
free wastes memory. The size threshold for
mmap to be used can be adjusted with
mallopt. The use of
mmap can also be disabled completely.