Shrinking Ruby Hashes 0 ▲ byroot’s blog 17 hours ago · 28 min read5551 words · Tech · hide · 0 comments As you may know, one area of Ruby performance optimization that particularly interests me is memory usage. Given that most Ruby deployments rely on fork, improving Copy-on-Write performance is generally where you get the biggest bang for your buck, but that only helps with the somewhat static part of an application heap. A significant contributor to memory usage is also the transient memory that is allocated during a request or job cycle and released soon after. As such, it’s also interesting to keep an eye out for opportunities to make various Ruby objects smaller. And the Ruby object type that’s probably the biggest contributor to memory usage is likely Hash. Hash instances are extremely common in Ruby applications and libraries, from option hashes and keyword arguments to logging and API responses. They’re so convenient that they’re perhaps overused sometimes, especially since they’re really not very memory-efficient. So let’s dig into how much memory they use, a bit of history of… No comments yet. Log in to reply on the Fediverse. Comments will appear here.