Generational GC

  • A small, fixed-size minor heap where most blocks are initially allocated.
  • A larger, variable-size major heap for blocks that have been live longer.

Fast Minor Heap

Long Lived Major Heap

  • The mark phase scans the block graph and marks all live blocks by setting a bit in the tag of the block header (known as the color tag).
  • The sweep phase sequentially scans the heap chunks and identifies dead blocks that weren’t marked earlier.
  • The compact phase relocates live blocks into a freshly allocated heap to eliminate gaps in the free list. This prevents the fragmentation of heap blocks in long- running programs and normally occurs much less frequently than the mark and sweep phases.