How does Ruby's Generational Garbage Collector work? Explain the Mark-and-Sweep process.
Last updated
Mark-and-sweep: mark every object reachable from roots (globals, stack, constants), then sweep unmarked objects back to the free list.
Generational: most objects die young, so survivors are promoted to an old generation. Frequent minor GCs scan only young objects, rare major GCs scan all, and a write barrier tracks old-to-young references.
Incremental marking shortens pauses, and
GC.compactdefragments the heap.
- https://www.turing.com/interview-questions/ruby
- https://www.youtube.com/watch?v=lkunzd5uDrw
- https://blog.jacobvosmaer.nl/0004-ruby-scheduler-interaction/
- https://wohotech.in/coding/top-java-interview-questions
- https://jetthoughts.com/blog/ruby-3-4-yjit-performance-guide/
- https://speed.ruby-lang.org/
- https://flexiple.com/python/interview-questions