Ruby fastcgi fun and memory leaks 0

Posted by admin

While playing with the Ajax support in Rails I detected a huge memory leak problem. Apparantly this is a known issue. Fixing it turned out to be quite interesting. The Ubuntu ruby-fcgi packages are still at 0.8.5 so first things first, remove this. Only the rubygems fcgi 0.8.6 version seems to be broken also judging from the apache error logs:

undefined method `each_cgi’ for FCGI:Class [NoMethodError]

Whoops! The correct fix currently is to just build ruby-fci 0.8.6 from source which is pretty straight forward anyway:

# cd /tmp
# wget http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz
# tar zxvf ruby-fcgi-0.8.6.tar.gz
...
# cd ruby-fcgi-0.8.6
# ruby install.rb config
...
# ruby install.rb setup
...
# ruby install.rb install
...

Unfortunately the memory leak is not really fixed. It leaks a lot less, but it still leaks, even with ruby-fcgi 0.8.6! Or perhaps it’s some kind of interaction with Apache2 + fastcgi. Anyone?

Update: the memory leak seems to happen when Rails is in development mode. Switching to production mode fixes the leak! Thanks to Daath @ #rubyonrails for this observation.

Update2: Rails 0.13.1 fixed this memory leak.

Comments

Leave a response

Comment