There are two heaps. the eden
heap and the tomb
heap. Each heap consists of
pages
(see [ruby-heap-pages]) each page holds [rvalue] objects.
rb_heap_t tomb_heap; /* heap for zombies and ghosts */
wtf is the tomb heap for, what is a zombie and what is a ghost?
Ruby allocates objects on the eden heap, until that heap is full. When GC cleans
up all the objects on a heap page, that page gets moved to the tomb heap. When
Ruby runs out of pages on the eden heap it will check to see if there are any
pages on the tomb heap that can be resurrected before asking the operating
system to malloc
enough memory for another page to extend the eden heap (TODO:
More detail here about tomb heaps)
rb_heap_t
a struct to hold pages of RVALUE
objects
free_pages
- this is a pointer to a heap_page
. heap pages have a
free_next
pointer that turns heap pages into a singly linked list. A page is
defined as free when it has at least one slot that is free.
using_page
- this is also a pointer to a heap_page
. When
pages
- this is a list_head
. Not sure what that is or what this is for
sweeping_page
- this is a pointer to a heap_page
, the inline comment
tells me that it’s an “iterator for .pages”, not sure what this means yet.
total_pages
- ?
total_slots
- ? (how many slots fit in a page)