Maybe we are wrong on how much swap space you need....
Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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?
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.