Reducing Memory Footprint (fcgi)


#1

I have a website up and running on TextDrive with Rails/lighttpd/fcgi.
Unfortunately, as my account is a “shared server” account on TxD, they
kill
processes that are hogging resources (quite understandably).

Unfortunately for me, my Ruby fcgi processes load up rather … large
(just
under 50mb). It doesn’t take much to push it to 50mb, at which point it
gets killed.

Does anyone have any suggestions for reducing the footprint of my app?
I
know that there is a profiler script available for benchmarking and
such,
but it seems that it focuses more on speed performance than memory
(correct
me if I am mistaken, but all the stats I see are for response time). My
app
seems rather responsive anyway (both as a qualitative observation from
just
using it, as well as browing through the logs).

Running script/console (in development mode) the process loads up around
27mb. The live server runs in production mode, but loads up to almost
50mb. But I have no clue as to go about tracking down the memory hog of
my
app. The memory usage increase quite rapidly when I start “creating”
new
content, but even aside from that it eventually grows over 50mb.

Any suggestions? Thanks!

-Matt


#2

Are you using rmagick? Rmagick uses Ruby memory ‘off the books’, this
can
cause large memory usage, but not trigger garbage collection.

After doing a set of rmagick operations (usually at the end of the
controller action), I force a garbage collection to clear out that
memory
with code that looks like this:

def run_gc

fDisabled = GC.enable

GC.start

GC.disable if fDisabled

end


From: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Belorion
Sent: Tuesday, January 03, 2006 2:31 PM
To: removed_email_address@domain.invalid
Subject: [Rails] Reducing Memory Footprint (fcgi)

I have a website up and running on TextDrive with Rails/lighttpd/fcgi.
Unfortunately, as my account is a “shared server” account on TxD, they
kill
processes that are hogging resources (quite understandably).

Unfortunately for me, my Ruby fcgi processes load up rather … large
(just
under 50mb). It doesn’t take much to push it to 50mb, at which point it
gets killed.

Does anyone have any suggestions for reducing the footprint of my app?
I
know that there is a profiler script available for benchmarking and
such,
but it seems that it focuses more on speed performance than memory
(correct
me if I am mistaken, but all the stats I see are for response time). My
app
seems rather responsive anyway (both as a qualitative observation from
just
using it, as well as browing through the logs).

Running script/console (in development mode) the process loads up around
27mb. The live server runs in production mode, but loads up to almost
50mb.
But I have no clue as to go about tracking down the memory hog of my
app.
The memory usage increase quite rapidly when I start “creating” new
content,
but even aside from that it eventually grows over 50mb.

Any suggestions? Thanks!

-Matt


#3

Hi Tom.

On 1/3/06, Tom F. removed_email_address@domain.invalid wrote:

Are you using rmagick? Rmagick uses Ruby memory ‘off the books’, this
can cause large memory usage, but not trigger garbage collection.

Why yes, yes I am using RMagick.

After doing a set of rmagick operations (usually at the end of the

controller action), I force a garbage collection to clear out that memory
with code that looks like this:
def run_gc

fDisabled = GC.enable
GC.start

GC.disable *if* fDisabled

end

Thanks for the tip! I will most certainly give that a shot.

-Matt