- To: "Peter Hardy" <peter@xxxxxxxxxxxxxxxxxxxx>
- Subject: Re: [SLUG] Oddball memory usage?
- From: Zhasper <zhasper@xxxxxxxxxxx>
- Date: Thu, 22 Feb 2007 20:14:45 +1100
- Cc: slug@xxxxxxxxxxx
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=GIwW+yXij6KGKV7rzH1yCpkGddlXvhM6F4ujVlJ/TRQeQE9AxobIWSG3aSBDSoY2Cy2D5vqVATasOxqCieEgqCLet5OB7IMt1DVeHAvQhxhNRJr1ETmDMTcCnvqvDJofVNmHwZY3e7FhoT4+A7/uYJmcKTf5c//wNmM+XQif1t8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=q4mcvBd1QtRvBymFga7sASl9sWVCrE/sOS1EKnQwYftFlOQ9x3XeEooRabRXSxEg8alYvu8CWWcROciOqDV8vGK7FadaKm+MKh0EbExj/HMI1M2rORoaCqrFbInHwjIqSDqC955qHkHerUjkNYYpON2V1RiZx3eTd6re5fgfLME=
On 22/02/07, Peter Hardy <peter@xxxxxxxxxxxxxxxxxxxx> wrote:
On Thu, 2007-02-22 at 16:24 +1100, Zhasper wrote:
> On 22/02/07, Peter Hardy <peter@xxxxxxxxxxxxxxxxxxxx> wrote:
> > I'm a little puzzled by this:
> > total used free shared buffers cached
> > Mem: 5005084 4816352 188732 0 156644 3165540
> > -/+ buffers/cache: 1494168 3510916
> > Swap: 1052616 1052616 0
> > Is this sort of usage normal? Filling a gigabyte of swap space while
> > just under 1.5GB of memory is going towards buffers seems odd to me. And
> > vmstat reports no usage of this swap space over a 15 minute period.
> > What sort of utilities are around to analyse swap space? I'd like to get
> > an idea of exactly what's using all of that memory.
> You're running Linux, right?
Aye. It's a 2.4 kernel dating from somewhere before swappiness became
> This can be really great on a system with not much ram where large
> apps that you haven't used in a while (eg, OOo) will get swapped out
> when they're not being used, to make lots of space to cache all the
> pr0^H^H^Himages of your grandmother's birthday party that you're
> scanning through agressively..
In my rush to be as detailed as possible, I completely forgot to mention
what the machine in question is actually doing. Well, it's a web server
for a single (fairly high-traffic) domain. Apart from apache and the web
application software, there's nothing running on it apart from the usual
collection of processes that are essential to a well behave unix system.
init, crond, syslogd.
I'd be looking at top (or other tools which give similar output),
particular at the "RES" and "VIRT" columns. VIRT shows the total
amount of memory used by a process; RES shows the amount of that
that's located in RAM (the rest has been swapped out)
Given what you said, my two-seconds-thought-while-sitting-in-armchair
hunch is that Apache (or more likely, come CGI you're using) does have
some kind of memory leak, and is slowly gobbling ram - but the kernel
is smart enough to see that the pages, although claimed, are unused,
so it's swapping them.
I would also guess that your site either has a lot of static content
which, rather than being read from disk a lot, the kernel is caching
in ram. You mentioned web application software, so it could be files
used by that too - config files, databases, etc.
Check your RRDTool graphs to see if swap/memory usage has been growing
over time - particular that really handy graph that differentiates
between buffers/cache/actually-used-by-applications ram usage, so that
you can see if, perhaps, the amount of "used" and "buffers/cache" have
remained about the same, while swap usage has been creeping up
I think I'm agreeing with everyone else - the kernel usually does a
pretty good job of handling the balance between buffers/cache and
application ram. If you're seeing performance issues, check
sar/iostat/vmstat/similar to see if there's a lot of swapping
happening; if that's the case, you might have a problem. If there's a
lot of disk IO that's not swapping, you might have the opposite
problem - not enough swapped out to cache all the frequently used
Either way, extra ram should help a lot, and extra swap may help out
as well - allow more files to be cached, at the expense of infrequent
extreme performance issues as those files get dumped from ram as the
system frantically swaps pages back in...
The other possibility is that you actually do have a memory leak,
which is going to be a lot of fun.
As always, monitoring is your friend... Looking at the output of free
tells you what the system is like now, looking at historical trends
tells you how it got there - whether this is a normal condition,
something that has gradually arisen, or something that abruptly
This is easily the biggest system I've found myself responsible for, and
the way the memory's been allocated doesn't line up with anything else
I've seen before. Just curious as to how and why it's being used like
There is nothing more worthy of contempt than a man who quotes himself
- Zhasper, 2004