LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 06-27-2007, 10:58 AM   #1
Basslord1124
Member
 
Registered: Jun 2004
Location: KY
Distribution: Debian, Mint, Puppy
Posts: 507

Rep: Reputation: 51
Red face Maybe we are wrong on how much swap space you need....


I was reading another thread here on swap space and it reminded me of a strange incident that happened to me recently.

Now the attitude tends to be that if your system has got 1GB of RAM or more you really could almost go without swap space depending on uses of course. When I configured my AMD Sempron system with 1GB of RAM I still set up an additional 1GB of swap to play it safe. From most uses I have seen it only hit about 3-4MB of swap space usage.

But one day, I decided I was going to look through some of my iptraf logs on my server (I copied em from my server to my desktop so I could view em on my desktop). One of these logs was about 70MB in size and I opened it up using Kedit and it truly bogged my system down good. When I was able to get top pulled up I was using about 40-50MB of swap at one point and I believe most of memory was already used and/or cached.

Not sure if maybe I should tweak my swap more but still I was quite surprised to see it react like that.
 
Old 06-27-2007, 12:21 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
If you have 1 gig of swap space, and only used 40-50 meg, what's the problem?

If it's the system slowdown that bothers you, maybe it's kedit doing it. Try opening the log file with different editors/viewers. Do you get the same slowdown?
 
Old 06-27-2007, 02:36 PM   #3
Basslord1124
Member
 
Registered: Jun 2004
Location: KY
Distribution: Debian, Mint, Puppy
Posts: 507

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by bigrigdriver
If you have 1 gig of swap space, and only used 40-50 meg, what's the problem?

If it's the system slowdown that bothers you, maybe it's kedit doing it. Try opening the log file with different editors/viewers. Do you get the same slowdown?
Not a problem, just found it unusual as I have found from my experiences (and I have heard from others too) that with a lot of RAM you usually end up using very little swap space for normal everyday uses. Now maybe in everyday uses people don't usually open 70MB log files but I still would've thought something like that wouldn't have made the system respond that way...it's only text. Of course maybe it's one of things where I open the application first then open the log, versus opening it all at once. I dunno, just found it kinda strange...nothing I'm gonna lose sleep over or anything.
 
Old 06-27-2007, 02:59 PM   #4
pdw_hu
Member
 
Registered: Nov 2005
Location: Budapest, Hungary
Distribution: Slackware, Gentoo
Posts: 346

Rep: Reputation: Disabled
70 MB logfiles aren't normal anyway
Use logrotate.
 
Old 06-28-2007, 09:28 PM   #5
SlowCoder
Senior Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Debian based
Posts: 1,250

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by Basslord1124
Now the attitude tends to be that if your system has got 1GB of RAM or more you really could almost go without swap space depending on uses of course. When I configured my AMD Sempron system with 1GB of RAM I still set up an additional 1GB of swap to play it safe. From most uses I have seen it only hit about 3-4MB of swap space usage.
Some say you don't need swap, but I differ on that opinion. I believe the rule of thumb is that swap should be 1.5 times RAM size. Depending on your apps, and if you see performance issues from swap thrashing, install more RAM.

I've got 2Gigs RAM, and 2 Gigs swap. Under normal load, my RAM usage is a little over 1.25 Gig, and 0 swap. But when I do video editing, it jumps into swap just a little.
 
Old 06-28-2007, 10:12 PM   #6
Junior Hacker
Senior Member
 
Registered: Jan 2005
Location: North America
Distribution: Debian testing Mandriva Ubuntu
Posts: 2,687

Rep: Reputation: 61
There are many variables to consider, for instance, when I have 8 desktops showing 2MB pictures I took with my digital camera, and toggle through or use all 8 desktops, my system will idle using 85% of ram. If I have only 4 desktops showing large .jpg photos, my system idles at 55% of ram being used.
So swap space needs to be suited to your habits/needs and usage, which can vary greatly from one person to another. If you have a habit of keeping many tabs in your browser while surfing the net, you'll use up more memory, etc..

Last edited by Junior Hacker; 06-29-2007 at 04:20 PM.
 
Old 06-28-2007, 10:20 PM   #7
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
Quote:
Originally Posted by SlowCoder
Some say you don't need swap, but I differ on that opinion. I believe the rule of thumb is that swap should be 1.5 times RAM size. Depending on your apps, and if you see performance issues from swap thrashing, install more RAM.
So, buying more RAM as a Christmas present means that you should add more swap? Sorry. I don't buy it.
 
Old 06-29-2007, 08:41 AM   #8
ak_random
Member
 
Registered: Jun 2007
Location: Silicon Valley, CA
Distribution: Xubuntu
Posts: 83

Rep: Reputation: 15
Quote:
Originally Posted by Basslord1124
When I configured my AMD Sempron system with 1GB of RAM I still set up an additional 1GB of swap to play it safe. From most uses I have seen it only hit about 3-4MB of swap space usage.
...
But one day, I decided I was going to look through some of my iptraf logs on my server (I copied em from my server to my desktop so I could view em on my desktop). One of these logs was about 70MB in size and I opened it up using Kedit and it truly bogged my system down good. When I was able to get top pulled up I was using about 40-50MB of swap at one point and I believe most of memory was already used and/or cached.
My guess is that this is merely kedit being inefficient at editing large'ish files. Remember that most text files are less than 1KB in size (think of all those configuration files on a typical Unix/Linux system). However, editing text has a different behavior than say, a 70MB video; text editing (and thus text editors) typically exhibits more random access than playing a video. If you were to edit a 70MB video using video editing software, I suspect you might see more similar behavior.
 
Old 06-29-2007, 08:43 PM   #9
SlowCoder
Senior Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Debian based
Posts: 1,250

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by Quakeboy02
So, buying more RAM as a Christmas present means that you should add more swap? Sorry. I don't buy it.
No, that's not what I said. Please reread my post. If you're swapping a lot, it's time to add more RAM. The proper mix of RAM and swap depends on how you use your system. Of course, the more RAM, the better. And the less swapping the better. But swap is a fallover for your system when RAM has been used up. The only reason I've got 2GB RAM, and 2GB swap is because my mainboard only supports 2GB RAM, so I can't install 4GB.
 
Old 06-29-2007, 09:35 PM   #10
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
Sorry I jumped on you slowcoder. Everytime I see someone saying that swap size should be some number times RAM, I kinda freak. Maybe we should change the name of swap to VSAR (Very Slow Additional RAM)

Last edited by Quakeboy02; 06-29-2007 at 09:37 PM.
 
Old 06-30-2007, 09:34 PM   #11
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
I ran for a long time with 1 gig ram, 1 gig swap. Over time, with updates and so forth, my demand for memory grew. Got to the point where the 1 gig RAM was always full, and the 1gig of swap was almost full. I added swap, but had a slow system after it had been running for awhile, with lots of paging.

I installed another gig of ram a week ago. Now my system is normally running with almost all the ram in use, and earlier today it hit 100 megs of swap in use - which I forced back into ram with a swapoff. Overall, the system performance is dramatically better. No paging slowdowns.

But, how much swap SHOULD I have? Well, recently having 2 gigs of swap was about enough, but my system was thrashing constantly. Now I have 1 gig and that looks like plenty.

Moral: You need as much swap as YOU need, not what somebody else's formula tells you you need.
 
Old 06-30-2007, 11:10 PM   #12
ak_random
Member
 
Registered: Jun 2007
Location: Silicon Valley, CA
Distribution: Xubuntu
Posts: 83

Rep: Reputation: 15
Quote:
Originally Posted by jiml8
Moral: You need as much swap as YOU need, not what somebody else's formula tells you you need.
Well said, but if one doesn't know how much one needs to begin with, that would probably cause that person to start a thread just like this one.
 
Old 07-01-2007, 09:32 AM   #13
chuckbuhler
Member
 
Registered: Oct 2005
Distribution: SuSe
Posts: 95

Rep: Reputation: 17
I look at the swap space a little differently. I see it more as a "relief valve" and a diagnostic tool, so I wouldn't want to run with no swap space at all. If your computer starts using a lot of swap, you need to figure out why, and what to do to fix the problem. If it's a new requirement, you may need to add memory (if that's an option) or if it's a buggy program, you need to fix or update the program. If it's something that very rarely happens, you can probably ignore it.

At home I have two computers the my wife and I use. One with 4gb ram and a 4gb swap (that's never used) and one with 512mb ram and a 1gb swap (that usually has a couple of mb used). Running top occasionally is one easy way to check the health of both of those computers. If I see a change in top, either we've started using something else that has larger requirements, one of us it trying to run too many things at once, or something has a memory leak.

Swap isn't the only tool to use to check out problems, but if you have the drive space you can spare, and a general idea of how the computer is going to be used, it's one clue available to help figure out what went wrong when the computer starts acting up.
 
Old 07-01-2007, 08:33 PM   #14
SlowCoder
Senior Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Debian based
Posts: 1,250

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by Quakeboy02
Sorry I jumped on you slowcoder. Everytime I see someone saying that swap size should be some number times RAM, I kinda freak. Maybe we should change the name of swap to VSAR (Very Slow Additional RAM)
No prob, and I can see what you mean, also. I generally add what I consider to be a generous amount of swap, and leave it at that. At least it's there if I need it. 2GB swap is cheap with current hard drives, though it generally sits unused on my system.

I think the 1.5x rule started with MS with NT4. Maybe other OS's had swap before that. I don't know. I also don't know why that calculation, but it's a good starting position for general applications.
 
Old 07-02-2007, 10:08 AM   #15
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
I agree. Start with plenty of swap; hard drive space has become very cheap. If you really need to add swap, and don't want to repartition, you can set up a swap file on an existing partition, mount it, and use it. This is a bit slower, but it'll keep you going.
 
  


Reply



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 reduce swap space and reclaim the space grantm Linux - Newbie 7 08-16-2012 07:05 AM
What is wrong with reiserfs? wrong free space mesh2005 Linux - General 1 05-03-2007 07:21 AM
how much swap space is needed; how to increase swap space? johnpaulodonnell Linux - Newbie 5 03-23-2007 03:20 AM
what is wrong with the swap adarsh_fj Linux - Newbie 6 10-07-2004 10:50 PM
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 01:23 AM

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

All times are GMT -5. The time now is 04:59 AM.

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