LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-29-2012, 03:42 AM   #1
educateme
LQ Newbie
 
Registered: Jul 2012
Posts: 11

Rep: Reputation: Disabled
Post Does the Swap>=RAM rule still hold?


It's almost 2013, and it's pretty common to get a notebook that comes with 8 GB RAM. Do I still need a Swap space >= amount of RAM, i.e. at least 8 GB of swap space as mentioned in forums of the past? And what exactly is this suspend-to-disk feature that apparently requires the Swap>=RAM rule?
 
Old 12-29-2012, 04:41 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
If your laptop goes to sleep, the whole memory will be stored in swap till you wake up the machine after which it can continue where it was. So yes, for a laptop with 8GB mem, 8GB swap is definitely recommended if you want it to sleep.

It also depends on the type of applications. E.g. video editing seems to be a memory hog so swap might still be a good idea.
 
Old 12-29-2012, 07:02 AM   #3
educateme
LQ Newbie
 
Registered: Jul 2012
Posts: 11

Original Poster
Rep: Reputation: Disabled
OK, 8 GB of swap then. Thanks!
 
Old 12-29-2012, 08:32 AM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,434

Rep: Reputation: 599Reputation: 599Reputation: 599Reputation: 599Reputation: 599Reputation: 599
Quote:
Originally Posted by Wim Sturkenboom View Post
If your laptop goes to sleep, the whole memory will be stored in swap till you wake up the machine after which it can continue where it was. So yes, for a laptop with 8GB mem, 8GB swap is definitely recommended if you want it to sleep.
The nomenclature is sometimes inconsistent, but "sleep" mode commonly refers to "suspend to RAM" and keeps the memory powered up and refreshed. It doesn't make use of swap, but does use a small amount of battery power. It's "hibernate" mode, aka "suspend to disk", that needs the swap space.

Resuming from sleep mode is very fast. Recovery from hibernation takes roughly as long as booting (the more memory you have, the longer it takes to load it from disk), but the advantage over booting is that you get your desktop and open applications back in the same state you left them.
 
2 members found this post helpful.
Old 12-29-2012, 10:37 AM   #5
jefro
Guru
 
Registered: Mar 2008
Posts: 11,516

Rep: Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403
There are still a lot of older programs that may use swap. The best choice is to use real ram if available. In most cases it doesn't hurt to have a swap. Many people just have it in case.
 
Old 12-29-2012, 11:47 AM   #6
DavidMcCann
Senior Member
 
Registered: Jul 2006
Location: London
Distribution: CentOS, Salix
Posts: 3,060

Rep: Reputation: 787Reputation: 787Reputation: 787Reputation: 787Reputation: 787Reputation: 787Reputation: 787
I've run a computer without swap and had no complaints.

As RKN says, hibernating doesn't save time these days. It used to be much quicker than booting, but as memory got bigger so recovery from hibernation got slower; meanwhile, booting got faster, with things like systemd and upstart. (Of course, our CentOS systems still do it the old way.)
 
Old 12-29-2012, 01:23 PM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 2,194

Rep: Reputation: 567Reputation: 567Reputation: 567Reputation: 567Reputation: 567Reputation: 567
systemd is overrated for start times. Slackware boots just as fast, and more reliably as systemd allows things to happen out of order.
 
Old 12-30-2012, 08:31 AM   #8
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,455

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
Quote:
Originally Posted by jefro View Post
There are still a lot of older programs that may use swap.
What? Programs don't use swap, they just ask the kernel for memory. The kernel decides when to use swap or RAM.
 
Old 12-30-2012, 10:25 AM   #9
jefro
Guru
 
Registered: Mar 2008
Posts: 11,516

Rep: Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403
Search on the subject and discover that swap may be used on some instances even if enough ram existed.
 
Old 12-30-2012, 10:53 AM   #10
Thad E Ginataom
Member
 
Registered: Mar 2011
Distribution: Ubuntu 12.04 with KXStudio, MATE & Compiz
Posts: 46

Rep: Reputation: 7
Swap is often used when there is plenty of free memory. It's a place to put stuff that has just been used and might be used again soon, but (despite not being a developer <Blush>) the wheres and hows of memory management, surely, remain a kernel function. The stability of the system depends on this.

This has been my understanding of *nix philosophy ...but hey, if I'm wrong it won't be the first time.
 
Old 12-30-2012, 12:21 PM   #11
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046Reputation: 4046
Quote:
Originally Posted by Thad E Ginataom View Post
It's a place to put stuff that has just been used and might be used again soon
Exactly that type of stuff does not get into swap. But you are right, sometimes swap is used even if you have plenty of free RAM, for a simple reason. If a program that is running was not used for a long time it may be possible that the memory of this program will be swapped out to make more room for caching. This can speed up the system, but comes with the downside of longer loading times when you want to use that application again.

Also, having swap-space can come in handy if you make excessive use of tmpfs mounts, since tmpfs can be swapped out.
 
Old 12-30-2012, 01:40 PM   #12
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,455

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
Quote:
Originally Posted by jefro View Post
Search on the subject and discover that swap may be used on some instances even if enough ram existed.
But use of swap doesn't have to do with whether it's an older program or not, right? Unless by "older program" you meant a program that started running a long time ago...
 
Old 12-30-2012, 06:10 PM   #13
jefro
Guru
 
Registered: Mar 2008
Posts: 11,516

Rep: Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403Reputation: 1403
I made a very large assumption that may not be fully correct. From what I have seen, the older programs are more likely to do that. I didn't test every program and situation so I could be wrong.
 
Old 12-30-2012, 06:17 PM   #14
NyteOwl
Member
 
Registered: Aug 2008
Location: Nova Scotia, Canada
Distribution: Slackware, OpenBSD, others periodically
Posts: 512

Rep: Reputation: 139Reputation: 139
Note that if you plan on using the machine for development and are at risk of causing a core dump, then making swap at least twice memory is a decent idea as the core dump will not only include the current memory contents but a lot of debugging info as well - and it gets dumped to the swap space. As disk space is relatively cheap, why not leave a safety margin.
 
Old 12-31-2012, 02:43 AM   #15
Thad E Ginataom
Member
 
Registered: Mar 2011
Distribution: Ubuntu 12.04 with KXStudio, MATE & Compiz
Posts: 46

Rep: Reputation: 7
Quote:
Originally Posted by TobiSGD View Post
Exactly that type of stuff does not get into swap.
It's been quite a while, so with a big If I remember correctly, the system with which I used to earn my living up to a decade ago, AIX, made extensive use of swap for keeping copies of executed programs, in case required again. It's quicker than getting it from the file system again.
Quote:
But you are right, sometimes swap is used even if you have plenty of free RAM, for a simple reason. If a program that is running was not used for a long time it may be possible that the memory of this program will be swapped out to make more room for caching. This can speed up the system, but comes with the downside of longer loading times when you want to use that application again.
And you are right that this is the more standard reason for swapping out programs.

I'm a beginner ...but for the second time around. I find revising and relearning these basics from threads such as this invaluable
 
  


Reply

Tags
memory, partitioning


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why size of swap space is 2x of RAM??? Why not 1.5x of RAM or 2.5x of RAM??? Saurav Ghosh Linux - Newbie 7 11-01-2011 03:49 AM
LXer: Rule #1: Hold On Loosely LXer Syndicated Linux News 0 10-01-2008 07:51 PM
When SWAP and RAM are out syberdave Linux - General 6 01-07-2006 12:13 AM
Use RAM as swap??? oneandoneis2 Linux - General 3 08-19-2004 04:48 AM
Swap and RAM ? mikeshn Linux - General 1 09-18-2002 09:33 PM


All times are GMT -5. The time now is 09:18 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration