Re: Over used cache memory?

From: Maciej Zenczykowski
Date: Thu Nov 06 2003 - 14:58:54 EST

> On Thursday, 06 November 2003, at 17:15:33 +0800,
> Wee Teck Neo wrote:
> > procs memory swap io system
> > cpu
> > r b w swpd free buff cache si so bi bo in cs us sy id
> > 1 0 0 92744 9640 20240 801644 0 0 3 10 17 0 25 2 10
> >
> > The system is having 1GB ram and currently using 92MB as swap. Why does the
> > system use the slower swap when there are still memory available (as
> > cache). Anyway to "force" the system to use more ram instead of putting
> > into swap memory?

Why would you want to? The kernel has determined that 92MB of the stuff
in memory is less important than the disk cache. For example a program
requires 100 MB data for boot and then spends the next week using the last
5 MB. Do you expect all 100 MB to stay resident in memory for ever
(while the program is running)? Of course not, it'll get swapped out once
it is determined to be less used than the disk cache and only that last 5
MB which is actually doing something will remain in RAM, with the rest
quietly sitting in swap. Swap is slower than RAM, sure, but using RAM for
storing your dirty laundry from two weeks ago is pointless - and that's
why it's swapped out - the disk cache will likely accelerate stuff more
than keeping the odds and ends in memory.

Now, if you have lots of cache and the system is swapping like crazy -
then something is wrong, but only then.

> The obvious solution is to disable swap memory completely if those
> 90 MiB worth of idle and unused memory pages on disk bother you.
> If this "vmstat" output shows your box usual load, with 80% of RAM used
> in caches, I think you will never really need swap at all.

I wouldn't agree with that - It'll still swap via R/O text executable
pages, so you'll still have swap, just invisible.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at