Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Feb 2002 07:43:57 +0100
From:      Cliff Sarginson <cliff@raggedclown.net>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Swap Space??????
Message-ID:  <20020207064357.GC7234@raggedclown.net>
In-Reply-To: <000201c1af9d$e2adc5d0$ab038bd8@blah>
References:  <000201c1af9d$e2adc5d0$ab038bd8@blah>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Wed, Feb 06, 2002 at 10:08:25PM -0800, Remington wrote:
> What exactly is the purpose of swap space? I heard swap space size
> should be equal to the amount of RAM so mine is 524MB, but its never
> used. I use top and it ALWAYS at around 6KB in use
> 
Mmm.. two questions in one day on O/S concepts :)

Simply put. It extends the amount of "memory" your computer has.
It is used by the O/S when there is not enough "real" memory for all of
the procesess competing for it. It then makes decisions based on fairly
complicated alogorithms on which bits of real memory to "swap" to the
disk swap area, i.e. it writes them out to swap, and re-uses the space
freed up for some other process. At a later stage, when the process
whose memory has been swapped out becomes a candidate for being run
again it will swap this memory back in.

As stated, how it decides this, and what gets swapped is complex, and
different theoretical models exist for what it should do. The fact that
you swap space is never used simply means you have never put so much
demands on the real memory of the system that the kernel has never had
to use it.

Slightly complicating this story is that even if you see some swap space
in use, it may not mean that you are permanently out of real memory, it
may have been a transient need for swap space, and that space just hangs
around so to speak.

If you have 256MB of real memory and a swap space of 512MB, and you find
that most of the swap space is in permanent use, then you probably need
to buy some more real memory if your performance is an issue.

How much swap space ? This is the perenenial question.
I always use 2x physical memory, but if you search the archives you will
come up with tons of discussion threads on what is the "right" amount.


-- 
Regards
Cliff



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20020207064357.GC7234>