LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-03-2009, 09:57 AM   #1
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Rep: Reputation: 77
Do We Really Need Swap?


I have noticed that since I have used Linux since 2003, I have never ever utilized Swap partitions. Maybe I am dead wrong and I have not realized I was but whenever I view system resources, I never see anything utilzing all my system RAM to the point I need to dump data into Swap. Is this an force of habit back from when 16MB's of RAM was available? Now that most people can pick up 4 + GB's on a laptop or low end PC, do we still need to create useless partitions for Swap? Perhaps I am being ignorant in thinking most modern (2001+) systems don't need to use Swap but I myself just have never seen Swap being utilized or found a need to create this partition.
 
Old 12-03-2009, 10:14 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Aargh...not another "is swap necessary" question. You've obviously been around here a while; you should know how often this topic comes up by now. I'm sure a search for past threads will turn up dozens.
 
Old 12-03-2009, 10:38 AM   #3
raju.mopidevi
Senior Member
 
Registered: Jan 2009
Location: vijayawada, India
Distribution: openSUSE 11.2, Ubuntu 9.0.4
Posts: 1,155
Blog Entries: 12

Rep: Reputation: 92
KDE system guard is bluffing me ! It also showing SWAP memory usage as ZERO.

By viewing that, I assumed that I am wasting memory by allocating to SWAP.
So once i had tried to install OS, Without SWAP. Just giving a warn it has installed OS.

Fine !!!! installed.

But problem started there. I can't run more than 2 windows.
I can't run firefox with 2 tabs opened.
I can't run graphical animation enable in desktop effects.
******* simply because of SWAP memory not available *********

so immediately i had modify , cross swapped ubuntu and openSUSE. ( both use same swap memory Partition )

Then My system was in normal condition ... But performance monitor again showing ZERO SWAP usage ... hahahahah
 
Old 12-03-2009, 10:48 AM   #4
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: OpenBSD / Debian / Ubuntu / Win7 / OpenVMS
Posts: 440

Rep: Reputation: 57
Quote:
Originally Posted by David the H. View Post
Aargh...not another "is swap necessary" question. You've obviously been around here a while; you should know how often this topic comes up by now. I'm sure a search for past threads will turn up dozens.
Here's one:
http://www.linuxquestions.org/questi...ens-if-757809/
 
Old 12-03-2009, 11:07 AM   #5
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
Quote:
Originally Posted by David the H. View Post
Aargh...not another "is swap necessary" question. You've obviously been around here a while; you should know how often this topic comes up by now. I'm sure a search for past threads will turn up dozens.
I have been here for a while but have never come across this thread as you exaggerated. I did a search assuming this was asked before and did not find any results on my 1st page so I decided to ask again...Perhaps I used the wrong search keyword criteria but regardless...

http://www.linuxquestions.org/questi...archid=3685604

Thanks for your recommendation of the search function and animated use of the emitocons...
 
Old 12-03-2009, 12:30 PM   #6
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: OpenBSD / Debian / Ubuntu / Win7 / OpenVMS
Posts: 440

Rep: Reputation: 57
Well, in all seriousness, people do have a lot of questions about swap.

Swap appears worthless on a modern high-memory server (or desktop), so the need for it is often debated at all levels of skill. What I have found in practice is that it actually is far more important than we might perceive it to be, and that the miniscule amount of disk is worth it. Well - miniscule on a desktop anyhow! I have servers with more than 100GB of RAM that use in the neighborhood of 200-300 GB of swap (and by use, I mean sometimes it's at 0%, sometimes it's at 80%).

It's especially useful on laptops for suspend to disk, which I believe the article I linked in the previous thread points out.
 
Old 12-03-2009, 12:47 PM   #7
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
Thanks!
 
Old 12-04-2009, 03:52 AM   #8
cdestiny
LQ Newbie
 
Registered: Jun 2007
Distribution: CentOS,Redhat
Posts: 25

Rep: Reputation: 15
I agree with MBybee. The swap will be very useful if you apply it to Server, especially those running test server. I have a 256GB RAM server and the user test will bomb it to 100% and nothing much left in SWAP too.

For Desktop, just good to have IMHO.
 
Old 12-04-2009, 06:44 AM   #9
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Well, I apologize for being a bit abrupt last night. I was a little short on sleep at the time.

But I'm really not exaggerating much, if at all. In my time here I've seen, and participated in, quite a few threads dealing with this exact same topic. They really do come up quite often, at least one every two or three months, at a guess, and that's with me sticking mostly to the 0-reply thread page. That adds up to a lot of threads over the 5 years I've been here. Often enough that I'm getting sick of seeing them.

Seriously, what is it about this question that makes it such a hot topic? It seems to me to be such a simple concept that there should be no debate. Swap is for times when you need more memory than you have available in RAM, or if you need to suspend the OS, such as on a laptop. If neither of those conditions apply to you, then you don't really need it. But it never hurts to have a swap file or partition set up anyway, just in case.

All the old guidelines were just that, rules of thumb for setting up swap developed at a time when memory was at a premium. They were never meant to be set-in-stone.

Oh, and finally, AIUI, the OS can and does occasionally use swap for temporary paging out of currently-unneeded data, if it finds it available.

That's it.
 
Old 12-04-2009, 07:26 AM   #10
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by David the H. View Post
It seems to me to be such a simple concept that there should be no debate. Swap is for times when you need more memory than you have available in RAM, or if you need to suspend the OS, such as on a laptop. If neither of those conditions apply to you, then you don't really need it.
But it is actually a bit more complicated than that.

1) What does "need" more memory mean? You are trying to run something that can't run without more memory? Or you are running something that would run faster if some idle anonymous pages were swapped out allowing more ram to be used for file mapped pages or file caching.

There is a wide range in which a system might be able to do everything you want to do without any swap space, but would do it a little faster if it could use a little swap space.

Linux is pretty good at deciding when it is likely to get better performance by swapping out idle anonymous pages in favor of other ram uses.

2) Over commit: This is a complicated subject that you can read about in other places. The simplified description is: Processes often allocate large amounts of virtual address space to things that are potentially anonymous pages but not actually anonymous pages. Linux tries to limit those allocations based on crude estimates of what fraction might become real, so that if that fraction did become real there would be enough swap space.

So you run into situations where virtual allocations that take no real memory may be rejected for lack of swap space, even though allowing those allocations would not actually cause any swap space to be used.

So you can have situations in which an operation requires swap space to be available but never actually uses it.

That memory management glitch is far more common in Windows than in Linux. But it does occur in Linux.
 
Old 12-04-2009, 07:51 AM   #11
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Maybe so, but none of that really affects the main point. Swap is only necessary if you need more system memory than you have available in RAM. It's just that the definition of need is up to the operator of the system to decide. It could mean anything from "absolutely necessary" to "not truly necessary but my program runs better with it", depending on the individual circumstances.

So if you need, or think you may need, or even just want, for whatever reason, a buffer of extra memory, then create some swap. Otherwise don't. Simple. Personally, I think it's a good idea to always have at least a small swap space available "just in case", even if it's rarely ever used. Others may feel differently.
 
Old 12-04-2009, 07:53 AM   #12
~sHyLoCk~
Senior Member
 
Registered: Jul 2008
Location: /dev/null
Posts: 1,173
Blog Entries: 12

Rep: Reputation: 129Reputation: 129
I observed considerable amount of swap usage during:

1. Virtualization.
2. Using firefox + playing music + burning software all at the same time.
3. Openoffice.

I always keep 2gigs swap space and I also use suspend to disk. So, swap is very important to me.

Last edited by ~sHyLoCk~; 12-04-2009 at 07:56 AM.
 
Old 12-04-2009, 07:55 AM   #13
raju.mopidevi
Senior Member
 
Registered: Jan 2009
Location: vijayawada, India
Distribution: openSUSE 11.2, Ubuntu 9.0.4
Posts: 1,155
Blog Entries: 12

Rep: Reputation: 92
I am using high graphics and animation so i made the SWAP just double to my RAM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to swap out (to swap area) page frames a process use? entertainyou Linux - Kernel 3 03-23-2011 09:52 PM
Can swap file or a swap partition be mounted and read? Mr-Bisquit Linux - General 3 06-08-2009 02:16 PM
SWAP - having trouble with swap auto mounting at boot lostdj Linux - General 2 08-05-2008 12:47 PM
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 01:23 AM
Difference between Swap Virtrual memory and Swap Parition Nappa Slackware 4 11-27-2003 07:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration