Showing posts with label rails. Show all posts
Showing posts with label rails. Show all posts

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.

Friday, May 30, 2008

HTTPS with Mongrel and Apache

Recently I was trying to configure my Railsmachine server for conditional http access. I was using something similar to ssl_requirement.

In this plugin there is the following call


request.ssl?


Of course behind apache this is returning false, even when the browser is using https. This happens because of mod_proxy.

The solution is to set the X_FORWARDED_PROTO 'https' env=HTTPS

HTTPS is an environment variable set in Apache (which versions I don't know)

X_FORWARDED_PROTO makes rails understand the original protocol and request.ssl? returns true where appropriate.

In short, add the following to your httpd.conf




RequestHeader set X_FORWARDED_PROTO 'https' env=HTTPS