[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

SWAP SIZE



   Ravikant Rao had written  use a swap partition of size 2.5 * RAM SIZE.
If I have 256 MB of RAM it becomes a huge amount and if the machine is
going to be used as a desktop pc, it is an  utter waste. Linux doesn't use
swap the way BSD does. You don't have to make swap bigger than your main
memory. If you have lots of RAM, you don't need swap itself. Swap is a
general precautonary  measure. When the system runs out of memory (main
memory + swap)  , the kernel starts killing processes randomly, this is a
terrible thing. But if you are sure you don't need swap you don't have to
allocate it. In cases where you feel that you may need swap, you can
create a swap file (provided that situation is very rare). So for PC's
just ensure that you have enough memory.
    Elaborating on how BSD uses swap, when you load a program, a copy of
that program is written to swap. The pager demon uses only the pages from
swap and not the page directly from executable file. The reason is that
the page layout has to be suitable. Linux uses ELF format in which the
page in the executable is same as the page in memory. So this copying to
swap is avoided and swap doesn't get used. So in linux swap gets used only
when you need to swap some modified page (i.e not text). That is the
reason that if you try modifying/overwriting an executable which is
executing, the kernel doesn't allow you to do that.

-George Samuel	

---
Visit our home page at: www.chennailug.org
Send e-mail to 'ilugc-request@xxxxxxxxxxxxxxxxxx' with 'unsubscribe' 
in either the subject or the body to unsubscribe from this list.