[Gc] Questions about design choices wrt mmap
erik at cq2.nl
Fri Apr 15 02:22:08 PDT 2011
I am studying the GC because I'd like to fight memory fragmentation.
It seems to me that mmap could really solve the problem of
fragmentation best. When I look at the code however, I have a few
questions, I couldn't find answers on on the site or in the code.
Unused hblks are only unmapped after they have not been used for some
time. What is the reason to not unmap them as soon as they become
Unmapped hblks are not really unmapped, but remapped as inaccessible.
(PROT_NONE). What is the reason for this?
Later, unmapped blocks might be merged with adjacent free blocks by
GC_merge_unmapped(). Why not unmap them all and map a new block when
If it were possible to just unmap blocks and use mmap for new blocks,
then the fragmentation would completely vanish, it that true?
Doing 4. would probably lead to many heap segments, as it would of
course be necessary to let mmap decide about the addresses, is that a
hard problem, to avoid at all costs?
I do have some thoughts about the answers to these questions of
course, but I might be completely wrong. To me, it seems that the
collector tries to maintain a more or less consecutive heap, reusing
blocks and filling up the gaps as efficiently as possible. So here is
6. What if one would not try to be efficient but just let mmap do its
work, at least for large blocks, how would that change the answers to
the questions above? Would it enable a solution for the fragmentation
More information about the Gc