O'Reilly logo

Ruby Performance Optimization by Alexander Dymo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Takeaways

Ruby GC is not a black box. Once you understand how it works, you can either change your code to put less strain on it, or you can tune GC up for better performance. Here’s what you need to keep in mind:

  • Ruby allocates objects on a dedicated heap space, which it manages itself.

  • Each object has the fixed amount of storage (40 bytes on 64-bit computers). If the object needs more memory, it allocates that on the operating system heap.

  • Ruby runs GC when it decides that it allocated too many objects or its objects allocated too much memory. Correspondingly, there are two criteria for this decision. First, Ruby heap space doesn’t have enough free slots. Second, the current memory allocation (malloc) limit has been exceeded.

  • You can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required