DESIGN 687 B

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