I have been looking at ways to monitor and reduce the memory usage of a ruby script for a client in the past couple of weeks; following are some of the useful resources I came across in this context:
- Matt Aimonetti’s very useful and detailed blog post : Ruby object allocation & why you should care
- GC-stats-middleware - a rack middleware created by Matt Aimonetti (mentioned in the above blog post - which I adapted to use for my purpose.)
- Garbage Collection and the Ruby Heap - Video of the awesome talk given by Joe Damato at the 2010 RailsConf
- Slides from the same talk given by Joe Damato and Aman Gupta at LA Ruby Conf 2010
- Memprof - the ruby memory profiler created and maintained by Joe & Aman. This works only for 1.8.7 and not for 1.9.2. Since I was working on 1.9.2, I didn’t dig too much into this. There is talk about a 1.9 compliant version of memprof; hopefully it will be out soon.
- Ruby 1.9 API documentation on ObjectSpace & GC modules. Matt Aimonetti’s GC-stats-middleware code is a good example of how to use these modules.
- Article about upcoming improvements in Ruby Memory Usage & Garbage Collection : Bitmap Marking GC for Ruby improves Memory Usage