"James Furness" <[EMAIL PROTECTED]> writes:

> I'm looking for some help getting apache to run reliably. Apache 1.3.9 with
> mod_perl 1.21 and Perl 5.005_03 is running on a dual P500 with 1 Gb of RAM
> running Redhat 6.1. We run about 5 sites off the box, most of which are
> fairly high traffic, and use a lot of CGI and
> MySQL 3.22.25 is used with Apache::DBI.
> 
> The major problem seems to be a memory leak of some sort, identical to that
> described in the "memory leak in mod_perl" thread on this list from October
> 1997 and the "httpd, mod_perl and memory consumption (long)" thread from
> July 1997.

[snip]

I too have had this problem and haven't found a suitable solution.  In
my case, though, I think the leaks are primarily do to old perl
scripts being run under Registry and not bugs in mod_perl or perl.

The first thing to do is to try to discover if the problem is a
mod_perl problem or a bad script problem.  If your server can handle
it, you could try a binary search to find which (if any) scripts make
the problem worse.  Basically pick half your registry scripts and use
mod_cgi.  If leaks persist, you know that you have some problem
scripts in the ones you didn't make mod_cgi.  If leaks stop, then you
know the problem scripts are in the ones you made mod_cgi.  Repeat as
necessary until you have narrowed it down to a single script.  This is
tedious though and may not be practical.

Depending on how old the scripts are, I would check for non-closed
filehandles, excessive global variables, not using strict, etc.
perl-status is your friend (hopefully you have it enabled!) so you can
see the namespaces of each httpd and see if you have any candidate
variables, file handles, functions, etc that could be clogging memory.

As a last resort, you could try Apache::SizeLimit to cap the size of
each httpd daemon.  This works reasonably well for us.  Something to
the effect:

use Apache::SizeLimit;

$Apache::SizeLimit::MAX_PROCESS_SIZE = 16384; 
$Apache::SizeLimit::CHECK_EVERY_N_REQUESTS = 3;

should help cap your processes at 16meg each.  Tweak as necessary.
Read the perldoc for Apache::SizeLimit for all the info you need.

Now, let's assume the problem is in fact in mod_perl or apache or perl
itself.  In this case I'm not sure what the best way to procede is.  I
think mod_perl and perl have shown themselves to be pretty good about
not leaking memory, as has apache.  IMO it's much, much more likely a
problem concerning Registry and impolite scripts that are misbehaving
and leaving parts of themselves around.

Have you tried correlating the memory surges with any page accesses?
That may help narrow down the culprit.

Good luck!

Chip

-- 
Chip Turner                   [EMAIL PROTECTED]
                              Programmer, ZFx, Inc.  www.zfx.com
                              PGP key available at wwwkeys.us.pgp.net

Reply via email to