question about memory usage in linux

Gregory Hill Gregory_Hill at
Tue Nov 22 10:13:46 MST 2005

> I think you are just misinterpreting what top is telling you.  On my
> machine, for example, when I sort by memory usage ("m"), I see that X
> currently taking up 10% of my memory.  Upon inspection, I find (and
> of you will cringe at this but X is a special case) that the 10%
> only refers to the amount of *resident* memory that X is using (100m).
> X is in fact using 272m of total memory[1].

Ok, good to know.  However, in my experience, mod_perl memory leaks
dramatically affect the numbers reported by top, which is not something
I'm seeing here.  Sometimes they get up to 40MB, but the max servers is
set to 10, so 400MB shouldn't crash the box.

> The point here is that the percentage you are seeing (1%) is only the
> amount of physical RAM the process is using, not the amount of total
> memory it is using.  Thus as a process leaks memory (older LAMP setups
> do leak), swapping and thrashing increase.  On a loaded system, it's
> possible that the process is being starved out and so the resident
> footprint is forced below the working set which just makes the problem
> worse.  So if your swap is completely full, that means one of your
> processes is taking it up, regardless of the amount of resident ram it
> is using. It is *not* a kernel leak.  It's a process memory leak.

I never said 'kernel leak', nor did I imply it. I'm not sure why both
replies mention that.  I assumed a process leak, or a possible
compromise of the box with hidden processes.  I'm just trying to figure
out how to narrow it down.

> What processes had the most amount of virtual memory use at the time
> the thrashing?  I see from your recent post that mysql is currently
> using about 20 mb of RAM, and 20 mb of swap.  Apache is also using
> 23 mb of RAM and 10 mb of swap.  Watch these numbers the next time it
> starts thrashing.  I'm assuming the numbers that free is reporting to
> you are average for your system. So if swap ever rose about 200 mb or
> so, start looking.

Excuse my ignorance again, but where do you get the 10MB swap figure for
Apache and 20MB figure for mysql?  Is that in top, but I just don't see
it?  Anyway, I'll keep watching it to see if I can find a pattern.  The
problem is it usually crashes at night, when I'm asleep.  My guess is
still a mod_perl leak, but for some reason it only occurs during the
night.  Does anyone know a good memory monitoring script that can email
me details at a certain threshold?  I'll write my own if not, but if
there's something already out there, I'd love to save the hassle.

Thanks for all the input.


More information about the PLUG mailing list