[CentOS] Memory leak - how to investigate

Mon Feb 3 20:39:33 UTC 2014
Les Mikesell <lesmikesell at gmail.com>

On Mon, Feb 3, 2014 at 1:59 PM,  <m.roth at 5-cent.us> wrote:
> Kwan Lowe wrote:
>> On Mon, Feb 3, 2014 at 8:43 AM, Jussi Hirvi <listmember at greenspot.fi>
>> wrote:
>>> My web & name server runs out of memory from time to time, to the point
>>> where it's completely unresponsive to anything. At that point reset is
>>> the only alternative. (Or, as this is a virtual guest, I just say "virsh
>>> destroy").
>>> But why this happens - I would like to know.
>> Sever things could be occurring. The first thing I notice is that you have
>> many httpd processes running. This can be useful if you have many
>> simultaneous hits. If you don't, you can tune the number of processes down
> We've got a number of websites on one of our production servers, and they
> get hit moderately (it's not Amazon... but they are US gov't scientific
> research sites), and I think we've got 25 threads running, total, to
> server *all* of them.
> <snip>
>>>  From "top" (situation now):
>>> Mem:   1361564k total,  1264324k used,    97240k free,     8428k buffers
>>> Swap:  3014648k total,    64852k used,  2949796k free,   358676k cached
>> That doesn't look like a lot of memory.. Possible to add another .5G or
>> so?
> Ah! I missed that. Is it actually the case that your server doesn't even
> have 2G of RAM? That's a *real* problem. If you're not running it on a
> five year old desktop, you need to add - I'd say you shouldn't be running
> with under 4GB of real memory.
>         mark "got 8G on my home ssytem, and 6G on my workstation at work"

Yes, giving it a few dollars worth of RAM is the real fix.  If you
have to squeeze by for a while without it, try setting
MaxRequestsPerChild to some reasonable (low thousands?) number in
httpd.conf to clear out modules that have memory leaks or a lot of
internal cache sooner.   A new child process will share almost all
memory with the parent, slowly growing as values change.  This is
especially bad for mod_perl or other embedded language modules if the
language does reference counting.

   Les Mikesell
    lesmikesell at gmail.com