Why use swap when there is RAM free?

Smoot Carl-Mitchell smoot at tic.com
Thu Aug 13 21:40:04 UTC 2009


On Thu, 2009-08-13 at 21:56 +0200, Vincent Arnoux wrote:
> On Thu, Aug 13, 2009 at 16:00, Smoot Carl-Mitchell<smoot at tic.com> wrote:
> > It will when the swapped pages are needed again.  There is no reason to
> > do the I/O when it is not required.
> 
> OK, I had the impression it was smarter to put data back to RAM anyway
> as I will for sure need it at one point... Thanks for the
> explanations.

You can flush it all back to RAM if you really want to with the
following sequence:

sudo swapoff -a
sudo swapon -a

This does not work if you have the kernel parameter vm.overcommit_memory
= 2.  The default for this setting is 0.  See sysctl for details.

Normally, you are better off letting the virtual memory system manage
your memory for you and not worry about what has been paged out to swap.
-- 
Smoot Carl-Mitchell
Computer Systems and
Network Consultant
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005




More information about the ubuntu-users mailing list