My mongrels slowly grow as my application runs, and I have to restart
them every few days (not as bad as some, I know). I used bleak_house
and had the following conversation with Evan:
Essentially, it looks like I have no leaks, but Evan suggested that I
may be suffering from heap fragmentation. I have found a theoretical
method to overcome this here…
Does anybody have any suggestions or experience dealing with
overcoming heap fragmentation? Perhaps something else could be
causing the memory growth that I should look into? I’m glad that my
app doesn’t have memory leaks, but I’m not sure what to do to keep the
mongrels from steadily growing until I run out of RAM…
Does anybody think that Passenger/mod_rails might help? I’d just give
it a try, but the app is already in production, and I’d hate to
reconfigure it and take it down for nothing…
Does anybody have any suggestions or experience dealing with
overcoming heap fragmentation? Perhaps something else could be
causing the memory growth that I should look into? I’m glad that my
app doesn’t have memory leaks, but I’m not sure what to do to keep the
mongrels from steadily growing until I run out of RAM…
Some ideas :
I use seesaw (http://rubyforge.org/projects/rails-oceania) to restart
mongrels without impacting the users. I don’t use it for saving memory
(although at a point I did) but to restart mongrels after log rotation.
I had some pages that accessed a lot of ActiveRecord objects and used
too much memory, I rewrote some code to get at the info I needed without
creating as much model instances, it helped a lot.
One of the selling points of Jruby for me is that it is supposed to use
less memory than MRI. You might want to test it.
I don’t think passenger will save you much. It removes a lot of memory
usage associated with the initial Rails and Ruby loading but not with
the actual “run” where your problem is. They have a tuned MRI in the
works that would certainly help there tough.