You are not logged in.

#1 2008-08-13 04:24:17

roost
Member
Registered: 2008-02-28
Posts: 13

Do we need SWAP Space?

Hi Folks!

I am running Archlinux 64bit on my System with 4096 Mb RAM. I use my System for Programming (Java, C), Gaming (UT2004, Enemy Territory, True Combat Elite, Doom3, ....), Distributed Computing (Boinc), Email, Surfing the Net, Watching and Converting Videos , Picture processing (Gimp) and Office work in general (Printing, Writing, ...).
There was never a lack of memory on my System and my Swap Space, which have an amount of 2000 Mb, is never used.
I would shrink it to 512 Mb, but i would not delete this partition.
By the way: i do not use the hibernate Funktion. In that case i should give at least 4096 Mb to the Swap Partition.

Here are some interesting Articles about that Problem:

http://sourcefrog.net/weblog/software/l … /swap.html
http://kerneltrap.org/node/3660
http://www.linux.com/feature/121916

What do you thing about this issue?

Greetz
roost

Offline

#2 2008-08-13 05:00:37

Megamixman
Member
Registered: 2008-05-04
Posts: 73

Re: Do we need SWAP Space?

Depends on what you do and what you have.
Most Laptop users, that I know, use Hibernate, so we need a swap.
That being said, Hard Drive densities are so large, that a small amount of swap space is not a significant burden, and it definitely doesn't deteriorate system performance.

Offline

#3 2008-08-13 05:03:45

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Do we need SWAP Space?

Yeah, like Megamixman says, it doesnt hurt, and we can generally afford the space.

But to answer the question.. no you don't _need_ it unless you're doing some high end tasks, and not even then. I don't have it on any of my systems.

Offline

#4 2008-08-13 06:28:43

roost
Member
Registered: 2008-02-28
Posts: 13

Re: Do we need SWAP Space?

Yes, I think you are right. We do not need swap at all, but in case of huge and cheap hd space it will not hurt to give some Mb to it.
But in case of bad coding (endless writing into the memory) or maybe some application wasting memory, it will be the swap giving you some more time to kill the app, before your System stops to respond.

Offline

#5 2008-08-13 06:37:06

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: Do we need SWAP Space?

This is my first install with no swap, on a 1gp laptop. It has been running fine the big majority of the time.
However, when I tried to build octave a few times, which is a pretty memory intensive task, my laptop slowed down like hell. After 30 min of compiling, I always found it totally unresponsive, worse than a fork bomb. And I had to reboot to get it back.
Not sure why the compiling processes were never killed.


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#6 2008-08-13 09:36:57

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

Re: Do we need SWAP Space?

Well, you could always, should the need arise, create a temporary swapfile for swap usage. Though I believe a dedicated swap partition is said to have better performance.


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

#7 2008-08-13 10:16:22

quetzyg
Member
From: /home/quetzyg
Registered: 2006-08-03
Posts: 130

Re: Do we need SWAP Space?

At the moment I have 5 machines running Linux, and none of them uses SWAP (I even compile my own kernel without SWAP support).
I think it's a waste of disk space, since even the slower machines (Pentium2 & AMD K6-2) with only 128MB of RAM never used the swap space when they had it.

So, if with 128MB of RAM the swap doesn't get used, the less use it's gonna get by my other machines with 512 (Pentium 3 desktop), 2048 (Core 2 Duo laptop) and 4096 (AMD X2 64 desktop) of RAM.

Regarding the laptop, I use suspend to ram, and it works flawlessly. smile


ZzZz...

Offline

#8 2008-08-13 10:25:37

Lord Illidan
Member
From: Malta
Registered: 2007-10-25
Posts: 248

Re: Do we need SWAP Space?

But 128 MB is only good enough for a minimal desktop. Definitely not GNOME, neither XFCE, perhaps openbox, at a stretch.

Offline

#9 2008-08-13 10:31:49

quetzyg
Member
From: /home/quetzyg
Registered: 2006-08-03
Posts: 130

Re: Do we need SWAP Space?

Lord Illidan wrote:

But 128 MB is only good enough for a minimal desktop. Definitely not GNOME, neither XFCE, perhaps openbox, at a stretch.

My two 128MB machines are headless servers. One running MPD+Shoutcast, the other running MLDonkey, Apache and MySQL. For what they do, it's enough. But yes, if you put them X.org, a window manager, and other X stuff, the memory wouldn't be enough.

Since the original poster, has 4096 MB of RAM, I continue to say that there is no need to have a SWAP partition (in his case) smile


ZzZz...

Offline

#10 2008-08-13 10:43:44

Lord Illidan
Member
From: Malta
Registered: 2007-10-25
Posts: 248

Re: Do we need SWAP Space?

I have 1 GB of RAM. With Gnome, compiz. firefox, eclipse, banshee/amarok, openoffice, all open it used to go into swapspace pretty often.

But 4096 MB of RAM is a good amount, I'm sure you don't really need any swap space, and in the case that you ever need some, it should be a cinch to resize your partition, or else use a swapfile.

Offline

#11 2008-08-13 10:55:49

mentallaxative
Member
From: Australia
Registered: 2008-07-14
Posts: 134
Website

Re: Do we need SWAP Space?

When I installed Arch on this 256 ram laptop I gave it a generous 800mb swap partition. At the time, I knew very little about how much swap space it would be using. After monitoring the swap through conky for a while now, I find the most I have ever used is 100mb of it.

Oh, whoops, I drifted away a little from the topic.... I suppose having some swap space could not hurt. It does not take up a whole lot of room and it is there on a 'just in case' basis. Especially with a laptop like mine.

Offline

#12 2008-08-13 11:48:49

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: Do we need SWAP Space?

I've got about 2GB of swap (if I recall correctly), and have never seen any of it in use. I'm on a laptop with 3GB RAM, running GNOME, Compiz, and all the bells and whistles. I would delete it - but I really have no need, I can easily spare the space as I store almost all my files on my portable harddrive, so it's only really programs that are stored on my computers.

Offline

#13 2008-08-13 14:57:17

cyclotomic
Member
From: New York
Registered: 2008-07-08
Posts: 52

Re: Do we need SWAP Space?

I had 512 mb of swap, and even then with 1 GB of RAM and one of the most minimal WM's out there, firefox was still a pain in the ass from time to time, when I had lots of other stuff running.  So from now on I usually just make the swap as large as the physical RAM.  Though my problems may be rooted in the fact that the flash plugin for firefox is a piece of garbage.

Offline

#14 2008-08-13 15:24:37

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

Re: Do we need SWAP Space?

roost wrote:

But in case of bad coding (endless writing into the memory) or maybe some application wasting memory, it will be the swap giving you some more time to kill the app, before your System stops to respond.

This is by far the best reason to have a swap file (along with suspend/hibernate). This machine has 4GB, so when I need swap space usually it means that there's a severe memory leak in something that's running.

Last edited by skottish (2008-08-13 15:24:53)

Offline

#15 2008-08-13 15:51:39

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: Do we need SWAP Space?

skottish wrote:
roost wrote:

But in case of bad coding (endless writing into the memory) or maybe some application wasting memory, it will be the swap giving you some more time to kill the app, before your System stops to respond.

This is by far the best reason to have a swap file (along with suspend/hibernate). This machine has 4GB, so when I need swap space usually it means that there's a severe memory leak in something that's running.

http://linux-mm.org/OOM_Killer

It is the job of the linux 'oom killer' to sacrifice one or more processes in order to free up memory for the system when all else fails.

But as I said above, I experienced a case where it apparently didn't do its job, and it was reproducible so I am confused.

In the end, I also think it is safer to have swap.
And when the oom killer indeed does its job, it could kill an app that has potentially important data, like firefox or openoffice or whatever, which often consume a lot of mem.


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#16 2008-08-13 18:47:15

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

Re: Do we need SWAP Space?

shining wrote:

snip...

http://linux-mm.org/OOM_Killer

snip...

And when the oom killer indeed does its job, it could kill an app that has potentially important data, like firefox or openoffice or whatever, which often consume a lot of mem.

Thanks for the info.

It's been a long time since I've had anything completely hose my system from memory leaks. This is mainly because I switched to Python for my GIMP scripts. It's freaky how easy it is to write Script-Fu that breaks everything. S***ty programming by me = broken Linux!

Offline

#17 2008-08-13 23:09:39

B-Con
Member
From: USA
Registered: 2007-12-17
Posts: 554
Website

Re: Do we need SWAP Space?

I've always partitioned my disks to have a swap, but I recently realized that on my desktop, out of 2GB of ram, I never used more than 500 MB of it (conky is nice), unless of course I left FX open for a long extended surfing session, but that's another story. So I've turned of swap on both my laptop and desktop. The most RAM-intensive stuff I do is compiling and, rarely, encoding. 2GB has been fine.

Offline

#18 2008-08-13 23:26:18

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: Do we need SWAP Space?

Whoever won't spare at least 1-2 GB of swap is a fool waiting for an accident to happen.


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#19 2008-08-13 23:44:24

Kknd
Member
From: Brazil, Santa Catarina
Registered: 2007-08-15
Posts: 100
Website

Re: Do we need SWAP Space?

I have 2gb of RAM and no swap smile.

I don't use hibernation, so no problem

Offline

#20 2008-08-14 00:36:22

SiC
Member
From: Liverpool, England
Registered: 2008-01-10
Posts: 430

Re: Do we need SWAP Space?

I've always worked on the principle, of taking my total RAM amount, doubling it, and using that number as swap.  I think it mostly stems from when I first started using Linux on a machine with 128MB of ram. I now have 32 times that amount, and still use the same numbers hmm Maybe it's time to reconsider, but I like having the option to do that.  I also make sure that the swap is on a different drive and channel from the main install.  I do use it all now and again, but for the most time I sit at around 500MB actual use, not including buffers and cached.

Offline

#21 2008-08-14 02:19:20

sam
Member
Registered: 2008-05-23
Posts: 82

Re: Do we need SWAP Space?

It really depends on how much hardrive you have.  If you have 4gb of ram, you probably have a good computer with plenty of hardrive space for swap.  What I would consider in your case is using part of the ram as filesystem to load libraries and programs you use frequently, this would give you considerable performance benefits.

Offline

#22 2008-08-14 09:45:30

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Do we need SWAP Space?

moljac024 wrote:

Whoever won't spare at least 1-2 GB of swap is a fool waiting for an accident to happen.

oooh, I'll bite, you called me a fool tongue

I've been running without swap for years. What sort of accident? Slip on a banana?

In the case of a regular mem leak (non forking), application using all memory situation, it's better without swap. With swap, I'm sure you've experienced the system suddenly swapping heavily, long before the app gets oom killed. Without swap, the app gets killed quickly without things going unresponsive.

In shining's case, something must have been forking off, possibly make starting new compilation processes.

Last edited by iphitus (2008-08-14 09:46:16)

Offline

#23 2008-08-14 10:10:22

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: Do we need SWAP Space?

iphitus wrote:

In shining's case, something must have been forking off, possibly make starting new compilation processes.

Actually, I just checked some old mails and here are some precisions :
1) the first time, the box was totally unresponsive, and nothing visible had been killed
2) the second time, it killed both firefox and gnome. I suspect I had the compilation running in screen, so that was still going on.
And with firefox and gnome killed, the box was much more responsive smile

Also I believe that I was using makeflags -j3 in both cases. So probably that does not help with memory usage.
And it could also indeed makes the task of oom killer more difficult.

So if I ever want to compile it again, I can do two things : running outside X to free a lot of mem, and with -j1
Besides, I have only 1gb. So people with 2gb and more probably don't need to care about this.

But I still think that it is better to have some swap space, and have the system slows down because of swap usage in extreme conditions, rather than having the oom killer kill tasks and losing potentially important data / work / whatever.
Now if you know that the maximum memory usage you can achieve doing something productive is lower than your mem, then it is fine.
Actually I have only 1gb and no swap, the only times I had problems is with this octave compilation, and I was not even using the box at this point, I just let it compile, so I did not lose anything.


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#24 2008-08-14 10:35:16

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Do we need SWAP Space?

shining wrote:

Now if you know that the maximum memory usage you can achieve doing something productive is lower than your mem, then it is fine.

That's the case with me. I thought I had swap... and then one day, more than half a year after installing I discovered it was never being enabled. Since then I've never bothered. The most 'stressing' thing I ever ran was kernel compiles, but that doesn't use nearly as much ram as you'd think.

Offline

#25 2008-08-14 10:46:53

roost
Member
Registered: 2008-02-28
Posts: 13

Re: Do we need SWAP Space?

Swap size = double the size of the ram!

This goes back to times you have less ram than 512 Mb.
In my Slackware HowTo there ist one sentence to this Topic. Swap schould be double the size of the ram but not more than 512.
Hibernating is not mentioned in this article.
By the way, it is an old howto.
In terms of virtualizing like xen, i think it will be necessary to have a swap. For example you start two or more OSs and parts of the inactive one is sent to the swap to give the active OS more Resources. It is only a idea but maybe not to far from reality.

There is also one issue we did not mentioned yet. The Performance gain or loss of the swap. The Linux, Unix, ... Swapping Technology is one of the best in this world even not the best at all. The performance loss is not that high than for example the microsoft "swap". In an Article i read about the swap that it works like a raid but only on one disk.

Greetz roost

Last edited by roost (2008-08-14 10:47:33)

Offline

Board footer

Powered by FluxBB