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

Profile Memory with Ruby-Prof

We can use the ruby-prof profiler for memory optimization too. We can ask it to measure either the size or the number of memory allocations, get a profile similar to those we saw earlier, and visualize it with the same tools. Even the approach to memory profiling is going to be similar. But there’s one catch: we’ll need a patched Ruby interpreter for memory profiling to work. Why? Because Ruby doesn’t give the profiler enough information about memory allocation by default—exactly for performance reasons.

If you aren’t adventurous enough to patch and recompile Ruby, you can skip this section and go directly to the next one, where I’ll explain how to incorporate memory measurements into your code. If you’re still ...

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