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.