A how to: How much Swap to setup/Linux eats my RAM
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.
A how to: How much Swap to setup/Linux eats my RAM
Ok, so there are LOADS of questions regarding this, and it is usually answered by the same people each time.
How much swap should I setup:
This depends on what you do with your system. If you are running a web server and plan on getting hit like a crash dummy, then you probably want to have a nice amount of swap. But if you have 2GB of RAM, then this answer would change to, not very much. Again this does depend on what else you will be doing with your system, and many other variables, so read on...
If you are running a regular desktop, and have the standard 128MB RAM, then you should probably run double the size as your swap: 256MB Swap.
If you are planning on running a game server some of the time, and a desktop the rest, and have the standard 128MB RAM, I'd increase that to ~312MB or so.
If you have a plethora of ram, meaning 512MB or more, and are just running a workstation desktop, then very liittle swap is needed, maybe ~64MB to be safe.
If you are running a server, with low traffic, and it's basically just for you and your friends to use as a file server; and you have ~256-512MB RAM, then I'd say go with maybe 1.5x the amount of RAM for SWAP, so 256x1.5 = 384MB Swap for example.
I have 640MB DDR RAM, and use my system as a fileserver; regular desktop running alot of Office apps, a web browser, and an email client; a video processing station where I transfer, compress and either email, share (via the fileserver) save back to the tape, save to disc or whatever the video; process lots of Oggs and other music things like ripping CD's converting for burning; and lots of other things.
Sometimes I'll do all these things at once, but usually it's 1 or 2 of them at a time.
I have never had swap since I got 640MB and have never had problems with speed either.
No this is not all inclusive, but if someone has something to add, feel free. This is just a short summary of my perspective of the SWAP issue that most people have problems with.
No it doesn't. Linux knows how to utilize your RAM best. You have 128MB RAM because you want more performance, but when linux uses it you get upset? I don't see the logic...
Linux uses all your RAM to do exactly what you want. It constantly consumes it, but doesn't hold onto it and not share it. It will use as much RAM to do any task that you want, therefore making the task run faster, and work better.
If you are using all your RAM all the time, then you have made a good investment. The people who have hordes of RAM and only use a small percentage of it all the time, they may have wasted money.
So if you see your RAM and only 1 or 2 MB are free, do not think that you have to free up some RAM for your programs to respond faster to, this will not help, usually.
To see how much RAM is being used, and to monitor it frequently, use the console command 'free'.
Again, this is not all inclusive, and if anyone has something to add, feel free. It's just a little go by for those who are struggling constantly with these issues.
Distribution: RedHat 7.2, Vector Linux 1.8, Mandrake 8.2
Posts: 174
Rep:
MasterC,
When I built my Linux box I used 256Mb of DDR PC2100 ram I wanted to use 512Mb but couldn't quite afford it. Anyways I was debating over how much swap to use so I finally went with 1Gb of swap (yes 4x the ram). This was because I still planning on using 512Mb & was sticking to the 1.5x - 2x your ram rule. My HD is 60Gb with 20 gigs for Win98SE, 19.5 gigs for RedHat 7.2, 19.5 gigs for Mandrake 8.2, 1 gig Linux Swap. Speed is no problem & it hasn't locked up yet but it is probably overkill for what I need but if I ever need it then I got it.
just a question.... does having too much swap space slow up your system... I mean, will the kernel only use it if it NEEDS to, or will it check out how much swap you have and say "hey, there's a lot of space there, might as well use it"?
I run 64M ram and 128M swap. I don't really need all the swap, but 128 isn't so much. I have Debian installed.
When I first log in (according to top), I have most of ram full but am using no swap. But sometimes, after running several resource-intensive processes (particularly the htdig cron or browsers), I'm using all of ram and 1/2 to 2/3 of swap. This is 1/2 to 2/3 AFTER these processes have terminated (all that's running is the GUI and some terms), and swap usage doesn't go down.
It seems as if Linux is not reclaiming the swap space of terminated processes. I suppose this would improve startup for these tasks IF they were run again. But on the downside, the system seems to start thrashing, repaints get slow and processes take a long time to start.
Anyone know if this is Linux swapping policy, or some quirk of my installation? Can anyone explain Linux swapping policy? Is there a tuning parameter I can set (maybe a swap usage threshhold)?
I just bought a gateway 310x desktop with 256mb RAM and run a dual boot with MDK 9.2 & WinXP. According to the 2x-for-less-than-512mb convention, I made a 512 mb swap partition. I ran top and saw that the swap space is barely used and almost ALL my RAM is being used. My swap space is on sector 16. This happens even when I'm doing nothing but run the X-server and the various services and daemons and things that load up at boot (I'm not running anything more than the usual stuff: APM, saslauthd, blahblah, and the giFT p2p daemon)
The reason why I find this wierd despite all that is said in the posts above is that I used to use an IBM Thinkpad 770Z until I hosed it's motherboard. I ran Linux MDK 9.1 there. It had 192Mb RAM and I put 400Mb of swap space (it was in a higher sector). Then, it used only about 1/3rd of my RAM while not doing anything other than the background stuff and seemed to adequately manage the RAM/swap allocation whenever the load got high.
This is why I am wondering if I have misconfigured my installation. IS the swap space inaccessible for some reason? Does it matter? Pleas let me know if I should do anything.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.