Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Mar 2002 04:01:28 -0800
From:      Kris Kennaway <kris@obsecurity.org>
To:        Mauritz Sundell <mauritz.sundell@telia.com>
Cc:        questions@freebsd.org, dillon@freebsd.org
Subject:   Re: swap-usage
Message-ID:  <20020308040128.A27224@xor.obsecurity.org>
In-Reply-To: <20020308115843.O29414-100000@morgan.upsys.se>; from mauritz.sundell@telia.com on Fri, Mar 08, 2002 at 12:54:14PM %2B0100
References:  <20020308115843.O29414-100000@morgan.upsys.se>

next in thread | previous in thread | raw e-mail | index | archive | help

--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Fri, Mar 08, 2002 at 12:54:14PM +0100, Mauritz Sundell wrote:

> For me the swap-area is used only then the system have used
> all available physical memory and need more and as soon as
> the memory need decreases the swap is unused again.

That's more or less correct, except that swap isn't freed up until the
memory which was swapped out is actually called upon again, and the
kernel needs to load those pages back into RAM.  It's more efficient
to leave it swapped out until needed and leave RAM for future use by
other processes.

> Further I do not think that where are many applications that
> allocates more memory if there are more memory available.

You'd be surprised.

> So why should I have swap partions on each physical disk?

Efficiency.  With swap partitions on multiple disks the system can
distribute pages across the different partitions, giving better
performance because the disk I/O can occur simultaneously (under
optimal conditions).

> Why should I have 2x the swap-space as main memory?

It's a good rule of thumb, because typical system workloads need up to
that amount of swap.  i.e. if you have a workstation with a typical
amount 128MB of RAM, which is used for typical workstation tasks, then
you'll typically need more than 128MB of RAM to actually run those
tasks.

If you start to run huge jobs on this machine, they won't fit into RAM
at once, and the system performance will drop.

The 2x rule accounts for running jobs plus all of the other background
stuff which only needs to run occasionally, and so doesn't need to
stay in RAM all the time.

> A person that have a system with 64MB RAM and 128MB swap
> wants to speed up and buy another 64MB RAM, installing the
> RAM the swapping should decrease and the swap-area could
> even by decreased. Ok, now the person feel that the system
> goes smoother and tend to have more applications running
> at the same time when before. But if he felt the system
> was slow before update he probably dont want more swapping
> to be done than before so why should the swap be increased
> by an other 128MB? Why should the usage of memory suddenly
> increase from 192MB to 384MB because of an upgrade with
> 64MB?

It's a rule of thumb, not a law of nature.  A person setting up a
system will choose the amount of memory based on the kind of workload
the machine will be undertaking (you want to be able to fit all of the
frequently-executing processes in RAM so it doesn't have to swap).
But infrequently-running processes like login shells, sleeping
daemons, and transient workloads like processing a huge logfile can
demand a lot more memory, which needs to be available.

You never ever want to run out of swap, because your machine will not
be able to continue running without killing off processes, and that's
almost always bad for your system operation.

> So if I deside not to have any swap-areas what do I miss
> besides a good place for crash-dumps?

The ability to run more processes than can fit in RAM, even if not all
of them are actually active at one time.

There's really no reason you'd want to do this, unless you're building
an embedded system where the hardware physically is not available.

Kris
--vkogqOf2sHV7VnPd
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE8iKgXWry0BWjoQKURAi4UAKDzWJ0LmG8C/gh/q3abj6zuA2h+YwCg9WTt
tgQEIqrXvICV3oj3LIqslh0=
=wrfI
-----END PGP SIGNATURE-----

--vkogqOf2sHV7VnPd--

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: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020308040128.A27224>