Chapter 6Profile Memory

As we’ve seen, the 80-20 rule of Ruby application optimization says that 80% of performance improvements come from memory optimization. So now that you know profiling basics, I’ll show you how to profile memory.

Unlike with CPU profiling, you can’t simply use ruby-prof to profile memory out of the box. You’ll need to have a patched Ruby interpreter for that. An alternative is to print measurements from GC#stat or GC::Profiler yourself. We’ll discuss both approaches in this section.

Get Ruby Performance Optimization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.