[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: why does it use swap?



On Wed, Mar 28, 2001 at 10:37:48AM +0200, Martin Würtele wrote:
> why does my server user swap if top givex me:
> 
>  10:36am  up 19:06,  1 user,  load average: 0.02, 0.04, 0.00
>  123 processes: 121 sleeping, 1 running, 1 zombie, 0 stopped
>  CPU states:  0.5% user,  0.9% system,  0.0% nice, 98.4% idle
>  Mem:  1029200K av, 534364K used, 494836K free,      0K shrd,   2772K buff
>  Swap: 257032K av, 255216K used,   1816K free                294632K cached
> 
> telling that 494 mb ram are free?

It's weird, and I haven't seen any answers to this question that satisfy
me.  I know that Linux is the only Unix variant I've ever used that acts
like this.  All that "free" memory really is free, as in it's not being
used for cache or buffers or anything.  It doesn't make any sense to me
that it should just be sitting there completely unused (memory is
expensive enough that you should *use* it when you have it!).

One interesting thing that I read somewhere in
/usr/src/linux/Documentation/vm.txt (I think) is that Linux actually
caches swap.  I'm not totally sure how this works or why, but if you
look at how much memory you are using for cache, you'll see that it is a
good bit more than what's swapped out.  So I bet that most, if not all,
of you swapped pages are actually cached in RAM.

I guess that kind of makes sense.  If the kernel ever needs to access
the swapped pages, it's got them cached so it can do it quickly. 
But if it ever needs a whole lot of RAM for something else¸ it can merely
re-allocate that cache.  That way the swapped data will still be
swapped.

Of course, as to the question about *why* all those pages got swapped
out to begin with is one that I can't answer.  Read
/usr/src/linux/Documentation/vm.txt, it might be meaningful to you.

noah

-- 
 _______________________________________________________
| Web: http://web.morgul.net/~frodo/
| PGP Public Key: http://web.morgul.net/~frodo/mail.html 

Attachment: pgpvqIel0huI2.pgp
Description: PGP signature


Reply to: