Chapter 10Tune Up the Garbage Collector

Many of the optimizations so far in this book involved avoiding or postponing GC as much as possible. But we can only do so much by working around the GC’s inefficiency. Let’s instead look into the face of evil. Ruby GC is, in fact, not a black box. We can understand it. And with modern Ruby interpreters, we can control it. This means that we can tune up GC for optimal performance in our applications.

That is, of course, only possible if we know enough about Ruby and GC internals. So let’s first figure out how they work, and then talk about tuning the GC settings.

Get Ruby Performance Optimization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.