LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Do We Really Need Swap? (https://www.linuxquestions.org/questions/linux-general-1/do-we-really-need-swap-773218/)

carlosinfl 12-03-2009 09:57 AM

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.

David the H. 12-03-2009 10:14 AM

Aargh...not another "is swap necessary" question. :rolleyes: 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.

raju.mopidevi 12-03-2009 10:38 AM

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 :banghead:

MBybee 12-03-2009 10:48 AM

Quote:

Originally Posted by David the H. (Post 3778527)
Aargh...not another "is swap necessary" question. :rolleyes: 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/

carlosinfl 12-03-2009 11:07 AM

Quote:

Originally Posted by David the H. (Post 3778527)
Aargh...not another "is swap necessary" question. :rolleyes: 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...

MBybee 12-03-2009 12:30 PM

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! :D 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.

carlosinfl 12-03-2009 12:47 PM

Thanks!

cdestiny 12-04-2009 03:52 AM

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.

David the H. 12-04-2009 06:44 AM

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.

johnsfine 12-04-2009 07:26 AM

Quote:

Originally Posted by David the H. (Post 3779566)
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.

David the H. 12-04-2009 07:51 AM

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.

~sHyLoCk~ 12-04-2009 07:53 AM

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.

raju.mopidevi 12-04-2009 07:55 AM

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


All times are GMT -5. The time now is 06:34 PM.