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 ...
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