Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Sep 2006 14:44:50 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Pietro Cerutti <pietro.cerutti@gmail.com>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: swap
Message-ID:  <20060924194450.GD73717@dan.emsphone.com>
In-Reply-To: <e572718c0609241229w5c7439e4mb58ca4f51e252437@mail.gmail.com>
References:  <e572718c0609241229w5c7439e4mb58ca4f51e252437@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Sep 24), Pietro Cerutti said:
> 512 MB of Ram, 1024 MB of swap, 6.1-STABLE
> 
> After some time my system begins swapping, which is normal.
> The weird thing is that swapping goes on even after closing the memory
> consuming programs.
> 
> here's the output of top(1):
> 
> Mem: 103M Active, 37M Inact, 107M Wired, 6656K Cache, 60M Buf, 240M Free
> Swap: 1024M Total, 106M Used, 918M Free, 10% Inuse

I se no swapping here (that would show up as "###K In, ###K Out" on the
swap line).  You have swap space in use but not actively used.
 
> Why the swapped pages don't get recalled back to main mamory (which
> has sufficient free space for them), freeing the swap device and thus
> speeding the system up?

Once the kernel decides to swap a page, that area of swap is reserved
until the process exits, even if the kernel pulls the data back from
swap.  That way if memory gets low again, the kernel knows it can
quickly discard the in-RAM copy of the data (since there's already a
copy in swap).

Processes likely to have pages swapped out are getty&login proceses for
unused ttys, lpd, sshd and other long-running daemons, etc.  There's no
reason to pull those pages back into RAM because you're more likely to
need that RAM for something else.

-- 
	Dan Nelson
	dnelson@allantgroup.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060924194450.GD73717>