Believe the hype. RMagick is an evil, memory leaking package. Do not use it. I always wondered why my Mongrels were sluggish; and why they often seemed to hang.
Of course I always knew I shouldn’t have used RMagick. But it’s just too darn handy. And it could not be that bad, right? Right?
Well, it can. It really can. RMagick eats memory like crazy and does not let go. Just shifting that stuff out is like night and day. Happy Mongrels, happy proxies, a happy front end, a happy admin and most importantly happy users.
If your Ruby/Rails app is acting slow: get rid of RMagick. Really.
joost,
I’m so sorry RMagick let you down! Can you tell me more about the problem you had? Did you report a problem to me and I overlooked it? Seriously, if a bug in RMagick is causing you a problem give me a chance to fix it. Email me at rmagick AT rubyforge DOT org.
By any chance have you seen this post on the RMagick Hints and Tips Forum? http://rubyforge.org/forum/forum.php?thread_id=1374&forum_id=1618. This post talks about using GC.start periodically to give ImageMagick a chance to give up memory that’s being used for images that are no longer referenced. Folks who are using this tip say that they can run RMagick in their Rails apps with no problems.
Uninstalling RMagick really was like night an day.
However I later discovered something that might explain the situation. As well as the gem, a source install of RMagick was also present on the system.
Ruby might have picked up the older source install instead of the gem. We’re talking 2005-era here, so definitely suspect.
I have since completely wiped RMagick. I’ll try the gem again and run with that for a while. I will definitely let you know how that goes. If it solves the leaks, I stand corrected and I will definitely post an update.
Update: using the latest gem definitely does help, but unfortunately still not without problems. When I use RMagick inside the file_column plugin, there are still leaks.
Since file_column is ancient, the problem might very well be there and not with RMagick at all. It is however very clear that the leaks only appear when I enable magick options, such as resize. The plugin by itself is fine.
Will keep y’all posted…
[...] RMagick is an image library for Ruby. If you want to “do things” with images in a Ruby on Rails app, you need it. It’s especially handy for rescaling and thumbnail generation. Good old attachment_fu uses it and so should you. Even the memory leaks are a thing of the past. [...]