Project

General

Profile

High Memory usage

Added by Imran Ali over 15 years ago

Hey All
I have searched a lot before posting here but haven't found anything substantial yet. We just moved our project website to a new server i.e. a new Slice on Slice Host(256MB). The memory usage stats are enormous i.e. upwards of 35%. It even goes upto 60% at times.

I therefore decided to install the Enterprise edition of Ruby and haven't seen any major improvements. I have passenger installed BTW.

P.S: We were earlier on Site5 and used Fast CGI then. Could this be the reason why we faced absolutely no issues there even though it was a Shared host account?


Replies (7)

RE: High Memory usage - Added by Eric Davis over 15 years ago

Each Ruby on Rails process tends to use from 35-160MB of memory depending on the libraries used. My Redmine tends to hover between 80-120MB and I have about a dozen plugins installed (106MB and 108MB RSS right now). If you don't use the gnatt chart, turning off RMagick can save a bit of memory (RMagick is known to leak memory). Just comment out the require_library_or_gem 'RMagick' line in lib/redmine.rb.

The older version of Ruby Enterprise Edition didn't save any memory on 64-bit systems, in fact I think it used more memory than the vanilla MRI. I'm not sure if this is still the case.

Eric

RE: High Memory usage - Added by Dave Nolan over 15 years ago

If you're on a 64 bit system, you might want to look at installing a 32 bit chroot. It's not for the faint-hearted though.

http://miloping.com/content/2009/01/3/installing-32-bit-chroot-debian-etch

Dave

RE: High Memory usage - Added by Leandro Lucarella over 15 years ago

I have a similar problem, but since I upgraded from a pre-0.8.0 svn to latest svn trunk. I had to upgrade to rails 2.2 too, so I don't know if it's Redmine or Rails fault.

The process starts at ~40MB and after about a day, it's using ~120MB. Since I have "only" 256MB I eventually have to restart the Redmine process (running as fastcgi with apache2) or my kernel starts shooting other processes (usually MySQL) to give Redmine more memory.

Should I fill a bug?

RE: High Memory usage - Added by Imran Ali over 15 years ago

Leandro Lucarella wrote:

I have a similar problem, but since I upgraded from a pre-0.8.0 svn to latest svn trunk. I had to upgrade to rails 2.2 too, so I don't know if it's Redmine or Rails fault.

The process starts at ~40MB and after about a day, it's using ~120MB. Since I have "only" 256MB I eventually have to restart the Redmine process (running as fastcgi with apache2) or my kernel starts shooting other processes (usually MySQL) to give Redmine more memory.

Should I fill a bug?

Sounds exactly like the problem we are facing. It starts to shoot up after some time and then finally becomes uncontrollable.

RE: High Memory usage - Added by Giulio Turetta over 15 years ago

it seems to be a common problem with RoR.... I've same problems also with other RoR applications.
I tried memory profiling, code enchantments, any way... no success.
To use redmine without problems now I use a dedicated server with apache proxy, lighthttpd and fcgi.. it works very well but memory remains a problem on shared (outsourcing) hosting:

www-data 27901 4.0 6.5 60192 48596 ? S 00:34 0:08 ruby /home/giulio/rails/redmine-0.8/public/dispatch.fcgi

note px aux uptime...

I wrote to customer service of my hosting company (very skilled guys - they perform kernel tuning and co.) but we can't find magic solutions... some one suggested to force garbage collector on after filter of application.rb, but I didn't test.
Customer service also suggested another (more elegant) way to force GC:

You can edit dispatch.fcgi to force GC actions

form

RailsFCGIHandler.process!

to

RailsFCGIHandler.process! nil, 10

second argument represented number of request for process before call GC.
Tiny number = aggressive GC (slow down application)

can someone tests this solutions and reports about it?

Maybe it helps!

have a nice day!

RE: High Memory usage - Added by Leandro Lucarella over 15 years ago

I've done a small test (using 5 instead of 10, I have a very low traffic instance so I don't care that much about killing performance a little), and it seems to work (it's using 43MB constantly), but I didn't testing for a long time, so time will tell.

Thanks for sharing this tip!

RE: High Memory usage - Added by Leandro Lucarella over 15 years ago

I been using this trick for 4 days now and even when the memory usage grew to almost 60MB, then the process was cycled by fastcgi so it's everything under control.

    (1-7/7)