Friday, June 06, 2008

RAM, RMagick, and You

Two days before the release, I am looking at top and trying to figure out why my mongrel instances are growing wildly in RAM. Playing with GC.start makes things a little better, but I just have some itch in me that tells me that might not be the best thing in the world to do.

After isolating the problem to something having to do with ImageMagick I discover what appears to be the problem. RMagick is not releasing the memory allocated with RMagick::ImageList.new.

Apparently what happens is RMagick holds a little tiny reference to some great big chunk of ImageMagick's memory. Well the GC only recognizes a the reference (which is very small).

Then I saw this very valuable post on RMagick

Turns out they have 'fixed' this by providing you the method .destroy!. That did the trick and life is back to mostly normal. Just thought I'd write this up quickly as memory leaks are not fun to find, especially in ruby.

1 comment:

Ian Neubert said...

Thanks for pointing this out!