[ale] Swap Memory usage

Greg Freemyer freemyer-ml at NorcrossGroup.com
Fri Sep 19 13:15:29 EDT 2003


On Fri, 2003-09-19 at 12:32, David Corbin wrote:
> Why does Linux use swap memory when there is RAM available?
> 
> David
Are you sure it does?

I just booted a machine and, per top, it has 0 KB swap in use.

Normally UNIX (and I assume Linux) does not swap until it is out of RAM,
or that a threshold of pain is crossed.  (i.e. Less than 1 Meg free
remaining.)

On the otherhand, once data is moved to swap it is left there until it
is deleted.

So if you have a brief period where swap is used, then that swap will
likely never be recovered because the first thing swapped is little used
apps with long life times.

The swap pages are only released from the swap device when the memory is
returned to the OS, which typically only happens if the app that owns
the memory space terminates and since the first thing swapped are long
life time apps, you basically never get it back.

fyi: Even if the swappe memory pages are accessed and those blocks of
swap are retrieved, they are still reserved on the swap device and
counted in your swap total until the memory owning app terminates.

Greg
-- 
Greg Freemyer



More information about the Ale mailing list