Project Inquiry
Published on

Garbage Collectable Symbols in MRI Ruby, Round 2

MRI Ruby 2.2.0 was officially released around Christmas in 2014. Back then, I ran a few memory benchmarks to test out one of the major new features: Garbage Collectable Symbols. Unfortunately, I found that the feature didn’t work, but couldn’t explain why. Maybe a bug in the newly released Ruby 2.2.0?

A couple of days ago, I found my old benchmarking code again and decided to run it again. Ruby 2.6.3 has been released a month ago or so, but did anything change over time as far as the memory situation around Symbols is concerned?

Here is the result (x-axis = number of requests, y-axis = megabytes of memory consumption):

Graph

The employed benchmark methodology is exactly the same as in my previous article. As you can see, memory consumption in Ruby 2.1.10 and 2.2.0 is quickly increasing over time, because there is no Garbage Collection of Symbols, even though Ruby 2.2.0 should have it based on the official Release Notes. By now this bug is fixed. Specifically, all Ruby versions >= 2.2.10 are performing the expected Gargabe Collection of Symbols, which explains why memory consumption hovers around 30 MB.