-
Notifications
You must be signed in to change notification settings - Fork 2
FAQ Free Lists
FAQ about the free lists.
Factor contains two different memory allocators, a bump allocator and a free list allocator. The free list allocator is used when it is unwise to move the allocated objects, for example when allocating code blocks. It's much more complicated than the bump allocator, but its big advantage is that objects in it can be freed outside of a gc cycle.
Both the code and data heap has a free list allocator. The data heaps one is an instance of tenured_space
. Each free list allocator has a free_list
tied to itself.
The state is a mark_bits
instance. It probably flags blocks as either live or garbage. Its size and start attributes has the same interpretation and value as the one in the free_list_allocator
that owns it.
- size
- Size in bytes of the allocator.
- start
- Address to the first writable byte of the segment this allocator manages.
- end
-
Should always be
start + size
, shouldn't it?
Free Lists contains 32 (free_list_count
) vectors which all empty when the object is instantiated. Then one free_heap_block
is created which encompasses the whole segment the free list works on. The heap block is placed in the large_blocks
set because it is so big.