eightbitraptor[wiki]

Ruby Heaps

The Ruby Heap

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)