RE: [PATCH] Avoiding mmap fragmentation - clean rev

linux
2005-05-25T07:30:16Z

If you want to minimize fragmentation, you could do worse than
study Doug Lea's malloc, known commonly as dlmalloc.

It's basically straight best-fit, but with one important heuristic:
FIFO use of free blocks.

This contributes enormously to minimizing fragmentation.
Any time a free block is created, it goes on the *end* of the
available list for that size.

This means that every chunk of free memory gets an approximately-equal
chance to be merged with more free chunks. The chunks that make it
to the front of the available list are the ones with stable neighbors,
which are the best ones use up.