Memory profiler tools for ruby05 Apr 2015
Memory profiler tools for ruby It so happened that I was need know how much ruby objects created
for each call sidekiq
That’s why I decided to create list with tools which helps you to know all required information.
1. Ruby GC
Sam Saffron has written great post, in which he talk about ruby garbage collector and wonderful
GC.start method which returns data hash:
Also author mentions a
ObjectSpace module that lets you know information about object/memory management.
For example you can easily know general number of created objects. For this you need write this code:
2. Ruby Memory Profiler
Also Sam wrote great tool (ruby-memory-profiler) which provide easily display all required information for any code in block. For this you will need call something like this (I called this code in my sidekiq reduce allocation PR):
- display different reports;
- easily profiles rails apps;
How to use:
Profiling Ruby isn’t as difficult as it seems at first glance. There are a lot of great libraries. The only thing I was missing — profiling the code from a file, but I’m sure it will soon add (maybe it will add myself ☺ ).