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

Measure Memory Yourself with GC#stat and GC::Profiler

You need to make manual measurements to profile memory without RailsExpress patches. We want to measure memory usage and GC statistics, print and collect them, then analyze them. That’s a lot of work, but sometimes it’s our only option. For example, a memory leak might happen in production only. We certainly don’t want to run production inside the profiler—that would slow it down. But we can insert the measurement code instead.

The first thing we want to measure is the current memory usage. As we discussed earlier, it’s less relevant than the memory usage deltas that we saw in ruby-prof, but in production, it’s the only number we can get.

The best way to measure memory is to ask the operating ...

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