swap space??

Timothy A. Seufert yellowdog-general@lists.terrasoftsolutions.com
Fri Aug 23 15:23:01 2002


At 11:33 AM -0400 8/23/02, Paul Rockwell wrote:

>Most modern systems, when there's a
>memory shortfall, will attempt to "steal" least recently used pages from
>other processes - it's less I/O than forcing out an entire process image. If
>this doesn't work, then a process is selected for swap-out.

Not sure, but I think that Linux never swaps out whole processes in 
one step.  It just pages more and more.

>For most workstations (general use) the "lazy" allocation works well. You only
>allocate what you estimate will be the shortfall between memory demands and
>physical RAM. But for servers, I'd want up-front allocation to get a bit more
>deterministic behavior.
>
>Some OS's will allow you to select which behavior you want.

The Linux-specific lingo is "overcommit".  If overcommit is on, the 
kernel is allowed to allocate much more memory than just the size of 
physical memory plus available swap space.  True allocation of a page 
is not done until the owning process attempts to read or write to it. 
So long as the number of pages actually touched remains smaller than 
the number of pages available in RAM + swap, the system will keep 
working.  But if the system runs out of pages (out of memory or OOM), 
it has to start killing processes to stay alive, and you may not like 
what it selects for killing.

There is a sysctl to control whether the Linux kernel is allowed to 
overcommit memory, /proc/sys/vm/overcommit_memory.  As root, do:

echo "0" >/proc/sys/vm/overcommit_memory

to turn overcommit off, or

echo "1" >/proc/sys/vm/overcommit_memory

to turn it on.  Red Hat like systems (i.e. YDL) have a config file, 
/etc/sysctl.conf, that can be used to set sysctl variables on boot. 
For sysctl.conf, the entry would look like this:

vm.overcommit_memory = 1


(This sysctl variable is a somewhat recent thing.  I'm pretty sure 
that 2.2.x kernels don't have it, and I'm not sure where in 2.4.x it 
got introduced.)
-- 
Tim Seufert