1
2
3In principle, this memory allocator is roughly equivalent to Doug
4Lea's dlmalloc with fine-grained locking.
5
6
7
8malloc:
9
10Uses a freelist binned by chunk size, with a bitmap to optimize
11searching for the smallest non-empty bin which can satisfy an
12allocation. If no free chunks are available, it creates a new chunk of
13the requested size and attempts to merge it with any existing free
14chunk immediately below the newly created chunk.
15
16Whether the chunk was obtained from a bin or newly created, it's
17likely to be larger than the requested allocation. malloc always
18finishes its work by passing the new chunk to realloc, which will
19split it into two chunks and free the tail portion.
20
21
22
23