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

Tune Up GC Settings

We can change some of Ruby GC parameters with environment variables. Let’s see what’s available.

Ruby 2.1, 2.2, and Later

RUBY_GC_HEAP_INIT_SLOTS

Initial number of object slots on the Ruby heap. Default value is 10000.

You might want to change this number if you know that your application will allocate lots of objects right from the start.

But on the other hand, we saw that Ruby is quite good at growing the heap space. It usually grows faster than we need. So there’s little need to change this parameter in practice.

RUBY_GC_HEAP_FREE_SLOTS

Minimum number of free slots that must be free after GC. If this condition is not met, Ruby might grow the heap space. Default value is 4096.

As we discussed in GC Triggered by ...

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