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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access