You are not logged in.

#1 2006-12-03 10:39:39

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,439
Website

Swap = 2 x RAM

In these days of 1GB RAM as standard does it really make sense to have a 2GB swap partition?

My current box has 256 and my swap was comparable in size.  I was getting poor performance in games so I upped it back to 512 and saw immediate improvements: less RAM usage and less swap space being used.  So it seems there is some benefit of having that bigger swap, even if it never gets used.

What does everyone else think?

Offline

#2 2006-12-03 10:47:47

lessthanjake
Member
From: Norway
Registered: 2005-11-09
Posts: 319
Website

Re: Swap = 2 x RAM

I rather want my prosesses to die than to swap them, so I have no swap. My machine have 1GB ram, so if all ram is used up something is wrong and the one process using the most memory is probably the cause and it deserves to die anyway. I just let the kernel do the job for me. I have not noticed any performance hit and no swap also means longer battery life on my laptop.

Offline

#3 2006-12-03 10:53:19

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Swap = 2 x RAM

Here (latest news entry) is what Con has to say about swap.

-edit-

Woo, not totally ontopic, but I've just found this and found it cool.

Offline

#4 2006-12-03 11:00:34

onearm
Member
From: Anywhere but here
Registered: 2006-07-06
Posts: 359
Website

Re: Swap = 2 x RAM

I have 1GB ram (soon 2GB) and only 256mb of swap (because I read somewhere that no swap wasn't good for the kernel, don't know if it's true or not). I have to say that the swap is never used unless when opening very big images in gimp, 2mb+.
I guess then that for ordinary desktop usage no or very little swap is ok


To get something done, a committee should consist of no more than three persons, two of them absent.
--
My Github

Offline

#5 2006-12-03 12:17:47

chrismortimore
Member
From: Edinburgh, UK
Registered: 2006-07-15
Posts: 655

Re: Swap = 2 x RAM

I have 2G of ram on my desktop and 4G of swap, going by the swap = 2x ram.  However, the swap partition lives on LVM2, so if I run out of space on the disc, I can always resize the swap.  But given I have ~40G free just now on the system drive and ~60G free on my music & vids drive, I'm not exactly short of space just now...


Desktop: AMD Athlon64 3800+ Venice Core, 2GB PC3200, 2x160GB Maxtor DiamondMax 10, 2x320GB WD Caviar RE, Nvidia 6600GT 256MB
Laptop: Intel Pentium M, 512MB PC2700, 60GB IBM TravelStar, Nvidia 5200Go 64MB

Offline

#6 2006-12-03 13:14:29

Borosai
Member
From: Sandy Appendix, U.S.A.
Registered: 2006-06-15
Posts: 227

Re: Swap = 2 x RAM

I decided to go with 512MB of swap (I have 4GB installed), and it will probably never be used, but whatever...I like saying "swap space."

Offline

#7 2006-12-03 14:26:42

[vEX]
Member
From: Sweden
Registered: 2006-11-23
Posts: 450

Re: Swap = 2 x RAM

I have 2GB RAM and a swap of 486MB and I've never seen the swap being used so far.


PC: Antec P182B | Asus P8Z77-V PRO | Intel i5 3570k | 16GB DDR3 | GeForce 450GTS | 4TB HDD | Pioneer BDR-207D | Asus Xonar DX | Altec Lansing CS21 | Eizo EV2736W-BK | Arch Linux x86_64
HTPC: Antec NSK2480 | ASUS M3A78-EM (AMD 780G) | AMD Athlon X3 425 | 8GB DDR2 | GeForce G210 | 2TB HDD | Arch Linux x86_64
Server: Raspberry Pi (model B) | 512MB RAM | 750GB HDD | Arch Linux ARM

Offline

#8 2006-12-03 14:39:55

Romashka
Forum Fellow
Registered: 2005-12-07
Posts: 1,054

Re: Swap = 2 x RAM

I've never seen swap used on my server with 1GB RAM and Xfce on it, though I even run few vmware machines on it sometime.
I don't remember how much swap is there, probably 1GB.


to live is to die

Offline

#9 2006-12-03 14:45:16

arox1
Member
From: Poland
Registered: 2006-07-08
Posts: 174

Re: Swap = 2 x RAM

I have 450 MB RAM and I almost never use swap

20-30 MB was max when I was using heavy DE like KDE or gnome

Offline

#10 2006-12-03 14:45:35

slackhack
Member
Registered: 2004-06-30
Posts: 738

Re: Swap = 2 x RAM

i have 1G ram and 1G swap, and like onearm says, i never see swap being used unless working with big image files. and even then it's pretty rare. on my server i see swap being used sometimes with a lot of torrents going, not sure why exactly. maybe it has something to do with network latencies and how it's writing to disk, since the target is an nfs partition.

Offline

#11 2006-12-03 16:51:04

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 816

Re: Swap = 2 x RAM

Like most of you have found, swap space is redundant for your average desktop PC with a half-decent amount of RAM. Of course if you have some app going wildy out of control with a memory leak, then it just takes a bit longer to fill up any swap file before it grinds to a crawl. Gimp will use it's own temp files.

I've run happily with 512MB or more of RAM with no swap.

As a compromise, if you really can't be without swap space then use a swap file (rather than a swap partition) which you can reduce in size over the days down to zero - like letting the air out of your water wings until you can swim wink

dd if=/dev/zero of=/waterwings bs=1024 count=65536
chmod 600 /waterwings
mkswap /waterwings
swapon /waterwings

then to make it permanent when you next boot add this line to your /etc/fstab

/waterwings swap swap defaults 0 0

Offline

#12 2006-12-03 17:15:21

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Swap = 2 x RAM

Having some decently sized swap partition has the other advantage of being able to use it for storing a suspend image (ha, I managed to create a one wicked sentence). But in that case using filewriter from suspend2 is also an option.

Offline

#13 2006-12-03 17:29:22

tardo
Member
Registered: 2006-07-15
Posts: 526

Re: Swap = 2 x RAM

echo 1 > /proc/sys/vm/swappiness
for less swappiness. works like a charm for me. (2gb ram, 512mb swap)

Offline

#14 2006-12-03 22:28:34

Alphalutra1
Member
Registered: 2006-09-16
Posts: 59

Re: Swap = 2 x RAM

The 'b' partition of your first drive automatically becomes your system swap partition -- we recommend a minimum of 32MB but if you have disk to spare make it at least 64MB. If you have lots of disk space to spare, make this 256MB, or even 512MB. On the other hand, if you are using a flash device for disk, you probably want no swap partition at all. Many people follow an old rule of thumb that your swap partition should be twice the size of your main system RAM. This rule is nonsense. On a modern system, that's a LOT of swap, most people prefer that their systems never swap. Use what is appropriate for your needs.

This is what openbsd devels think of swap.  I just use around 256 to 512 MB depending on the pc.

Cheers,

Alphalutra1

Offline

#15 2006-12-03 23:21:12

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: Swap = 2 x RAM

The only time my system goes into swap is when I do something incredibly stupid with my Gimp scripts. Unfortunately that's frequently. In fact, I botched a script earlier today that actually sent my system into swap when I still had 2 GBs of RAM still open. Now that's a memory leak!

Offline

#16 2006-12-08 14:40:41

brazzmonkey
Member
From: between keyboard and chair
Registered: 2006-03-16
Posts: 818

Re: Swap = 2 x RAM

under heavy load (multitasking + windows xp on vmware with many heavy excel files opened) my system does swap (a little).
as my rule of thumb i'd allocate at least 1xRAM as swap space. what about if swap is used for hibernation ?


what goes up must come down

Offline

#17 2006-12-08 15:41:04

Romashka
Forum Fellow
Registered: 2005-12-07
Posts: 1,054

Re: Swap = 2 x RAM

brazzmonkey wrote:

under heavy load (multitasking + windows xp on vmware with many heavy excel files opened) my system does swap (a little).

This depends on amount of RAM for host and guest system.
On my server with 1GB of RAM I run 3 vmware machines with 256 MB RAM - and no swapping (I have Xfce).

Also, VMware has 3 different policies on swapping virtual machine's memory.


to live is to die

Offline

#18 2006-12-08 16:53:11

iBertus
Member
From: Greenville, NC
Registered: 2004-11-04
Posts: 2,228

Re: Swap = 2 x RAM

My current setup is 2GB RAM and 2GB swap. I've got plans to work with some really huge uncompressed datasets and 2GB of RAM may not be enough to get the job done. Unfortunately, my Soltek mainboard only has 2 sockets, so unless I want to build a new box 2GB installed RAM is the limit.

Offline

#19 2006-12-08 16:54:29

dolby
Member
From: 1992
Registered: 2006-08-08
Posts: 1,581

Re: Swap = 2 x RAM

from my experience 1gb swap space is ok , maybe even too much for any machine no matter the amount of ram.
currently i run arch on a 128 ram machine with 1gb swap and most ive seen used is 100mb
dont know if having eg. 4gb ram with 1gb swap and not 8gb one by the 2xram "rule" , would slow things down, but i seriously doubt it. if anyone has such experience id like to know though


There shouldn't be any reason to learn more editor types than emacs or vi -- mg (1)
[You learn that sarcasm does not often work well in international forums.  That is why we avoid it. -- ewaller (arch linux forum moderator)

Offline

#20 2006-12-08 17:06:18

fk
Member
From: Germany
Registered: 2006-04-29
Posts: 524

Re: Swap = 2 x RAM

Normally I think 300Mb of swap are enough, but what is when I will Suspend to Disk the System? Do I need more Swap space? (If I use the swap partition for this)

btw: what is better Suspend to Disk with a swap partition, or with a File?


Have you tried to turn it off and on again?

Offline

#21 2006-12-12 21:49:49

Master Beef
Member
Registered: 2005-05-28
Posts: 37

Re: Swap = 2 x RAM

i run my desktop with 1gb ram and a 2gb swap. the only time i've seen it used is video encoding. the size of the partition is irrelevent to me as i have 2 80gb ide drives used for arch x86 and 64 respectivly and a 320gb sata for my home dir


"Alright it's settled. Zorak is the hammer, Moltar you suck."

Offline

#22 2006-12-13 01:51:14

skymt
Member
Registered: 2006-11-27
Posts: 443

Re: Swap = 2 x RAM

Ironically, the more RAM you have, the less swap you need. A much better guideline is to pick a number based on how much memory you think you'll need (frequently 2G on a modern KDE/Gnome desktop, 1-1.5 G on a lightweight box), add a bit (just in case), then subtract your current RAM.

Offline

#23 2006-12-13 02:46:22

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: Swap = 2 x RAM

256 MB ram plus 128 MB swap and I've never run into problems with typical desktop usage (yes, that excludes stuff like video editing).


1000

Offline

#24 2006-12-13 04:20:17

iBertus
Member
From: Greenville, NC
Registered: 2004-11-04
Posts: 2,228

Re: Swap = 2 x RAM

Master Beef wrote:

i run my desktop with 1gb ram and a 2gb swap. the only time i've seen it used is video encoding. the size of the partition is irrelevent to me as i have 2 80gb ide drives used for arch x86 and 64 respectivly and a 320gb sata for my home dir

I think this makes a very good point about swap. Almost everybody has 20+ GB drives these days and having 2GB as swap isn't really affecting your usage that much.

As stated earlier in this thread, I also use 2GB of swap. It never gets used, but I often manipulate large datasets and I cannot have apps crashing due to lack of memory when an option like swap exists.

Offline

#25 2006-12-15 23:34:57

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: Swap = 2 x RAM

skymt wrote:

Ironically, the more RAM you have, the less swap you need. A much better guideline is to pick a number based on how much memory you think you'll need (frequently 2G on a modern KDE/Gnome desktop, 1-1.5 G on a lightweight box), add a bit (just in case), then subtract your current RAM.

!!

I don't know what kind of RAM the big DEs want, but I can't imagine what kind of lightweight box would want 1-1.5 GB. My fairly lightweight systems with 512 MB RAM hardly ever touch swap at all.

Offline

Board footer

Powered by FluxBB