linux swap size


What is this stuff?

If this isn't exactly what you wanted, please try our Search (there's a LOT of techy and non-techy stuff here about Linux, Unix, Mac OS X and just computers in general!):



From: Floyd Davidson <floyd@ptialaska.net>
Subject: Re: Is this why my system hung?
Date: 29 Mar 2002 12:07:13 -0900 References: <3CA48F89.5010407@sandia.gov> <3CA4997F.9040201@web.de> <3CA4BEE0.5060207@sandia.gov>


Hate these ads?



"Christopher R. Carlen" <crcarle@sandia.gov> wrote:
>Thorsten Hirsch wrote:
>> Christopher R. Carlen wrote:
>> 
>>> Hi:
>>>
>>> I am running Suse 7.3 with 2.4.10.  I am aware that the 2.4 kernels 
>>> require that one has swap = 2 * RAM, but on this machine I hadn't set 
>>> that up properly.
>> 
>>  > [...]
>> 
>>> Did this happen because I don't have swap = 2 * RAM?
>> 
>> 
>> No, you don't need a swap when you've enough memory. My machine has 
>> 384MB RAM and no swap and I experienced no problems so far (Mandrake 8.2).
>> Perhaps your disk is full?



That is absolutely *TRUE*.














However, in fact on a machine with 384Mb of RAM it perhaps would
be of some benefit to add at least some swap.  That is because
the system will page out all or parts of programs that are never
active, and the free'd up RAM is then used for disk buffer and
cache, which does make the system faster.



>Maybe you have had no problems, but I think it is important to realize 
>that 2.4 kernels want swap=2*RAM.  I read this in an article about 



That is absolutely *FALSE*.  It is based on fact, but confuses
two issues and draws the wrong conclusions as a result.


ad



>problems people had with the 2.4 kernels when they first began to be 
>employed in servers.  They crashed all over the place.  Things improved 
>a lot after people realized the swap requirements, but 2.4.x still had 
>stability problems to make it questionable for high load servers until 
>more recently.  I don't know where this fact? is mentioned in the kernel 
>documentation.  Hopefully some knowledgeable person can point this out.



When first released the 2.4.x kernels simply had a buggy virtual
memory system which was not properly releasing allocated disk
space.  The bug was fixed.



That is often confused with the BSD derivation of that buggy virtual
memory system.  BSD 4.3 (and I'm not sure which others) required at
least a 1:1 RAM to swap ratio because in order to execute a program
it *had* to be loaded into swap as well as RAM.  Virtual memory was
not more than RAM until the swap space was more than RAM.  Hence to
have virtual memory equal to twice the RAM size, swap had to be twice
the size of RAM.  (That will provide virtual memory 3 times the size
of RAM on Linux.)









The current 2.4.x Linux kernels are not using that virtual
memory system, and it did not have that requirement even when it
was being used.



>~ $ df
>Filesystem           1k-blocks      Used Available Use% Mounted on
>/dev/hda5             10080488   3086684   6481736  33% /
>/dev/hda1               101089      4402     91468   5% /boot
>
>Doesn't look full.  I changed my swap partition to 1GB, and put in 



Clearly "df" does not show stats about either RAM or swap.  Try
running "free".



>another 256MB RAM.  I ran the konqueror search again, and watched in 
>top, that kdeinit ate up to about 450MB of the RAM in the process of the 
>search.  This time I didn't have any problems.



However, the *ratio* of RAM to swap didn't have *anything* to do
with the differences observed!



>Before, I had 256 MB and about 120MB swap.  The system thrashed to 
>pieces.  I am not sure what would have happened if I had 256MB and 512MB 
>swap.



Given what you describe, it was not thrashing to pieces.  It was
simply totally out of memory!  If you commonly run processes
that use 450Mb of virtual memory, there are some hard and fast
rules that must be followed.



You *must* have more than 450Mb of virtual memory!  Virtual
memory (VM) is equal to RAM + swap.  Of course using RAM is fast
and using swap is slow.  Hence any process that uses more VM
than the amount of RAM is necessarily going to be slow.  But if
you have 256Mb of RAM and 120Mb of swap, thats only 376Mb of VM
and a process that needs 450Mb of VM is simply not going to run
at all.



Clearly having 512Mb of RAM not only solved the out of memory
problem, but also avoided having the process run from swap too,
which would have been slow at best.  (I'm ignoring the
possibility that other processes may be running at the same
time, and the combination of all processes is what actually
counts, not just any one process.)



Think about the swap should equal two times the RAM concept for
a bit in relation to practical systems.  If you have 64Mb of
RAM, and only 128Mb of swap, the machine can't run total
processes exceeding only 192Mb.  The way to allow it, with only
64Mb of RAM, to run a process that needs 450Mb is to provide at
least 400Mb or so of swap space.  That is more than 5 times as
much swap as RAM.



On the other hand, put 1024Mb of RAM into that box, and there is
simply no requirement at all to have *any* swap space!



The  ratio rule of thumb simply does not apply to Linux.



>Still not sure what it all means.  I suppose find may be better than 
>konqueror for file searches.



-- 
Floyd L. Davidson         <http://www.ptialaska.net/~floyd>
Ukpeagvik (Barrow, Alaska)                 floyd@barrow.com





Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)

Or use any RSS reader

Delivered by FeedBurner


Views for this page
Today This Week This Month This Year  Overall
41654836 7,252

/Bofcusm/1536.html copyright 1997-2004 (various authors) All Rights Reserved

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

More:
       - Newsgroup




Unix/Linux Consultants

Your ad here - $48.00 yearly!

http://www.vss3.com SCO/Caldera OpenServer, Unixware & Linux. Tarantella & Non-stop Clustering


http://www.m3ipinc.com Security, firewalls, ids, audits, vulnerability assesments, BS7799, HIPAA, GLB, incident handling


http://bcstechnology.net Full service Linux & UNIX systems integrator; Windows to UNIX/Linux Client-Server Specialist; Secure E-Mail & Website Hosting; Thoroughbred Software Developer; Custom Industrial Automation; Hardware & Electronics Experts; In Business Since 1985.



Twitter
  • Nov 18 20:41
    I'll be out all day Wednesday the 19th, hard to reach even by phone. Leave a message and have patience.
  • Nov 18 10:07
    What am I doing? Not doing what I WANT to be doing! Oh, well, in every life a little work must fall..




card_image








Change Congress


Related Posts