LinuxQuestions.org
Register a domain and help support LQ
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
 
LinkBack Search this Thread
Old 10-14-2002, 12:37 PM   #1
MasterC
Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,611

Rep: Reputation: 61
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.

______________________________________________________

Linux eats your RAM:

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.

Cool
 
Old 10-14-2002, 01:15 PM   #2
markus1982
Senior Member
 
Registered: Aug 2002
Location: Stuttgart (Germany)
Distribution: Debian/GNU Linux
Posts: 1,467

Rep: Reputation: 45
When using a (medium large) database server you might want to have 512 MB swap lying around just to be on the safe side ...
 
Old 10-14-2002, 01:16 PM   #3
bubba169
Member
 
Registered: May 2002
Distribution: RedHat 7.2, Vector Linux 1.8, Mandrake 8.2
Posts: 174

Rep: Reputation: 30
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.

Bubba169
 
Old 10-14-2002, 02:50 PM   #4
adam_boz
Member
 
Registered: Jul 2002
Location: Santa Cruz, CA
Distribution: lfs
Posts: 538

Rep: Reputation: 30
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"?
 
Old 10-14-2002, 04:07 PM   #5
Dexatrim
LQ Newbie
 
Registered: Aug 2002
Posts: 15

Rep: Reputation: 0
While we're talking about swap:

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)?

Thanks
 
Old 01-13-2004, 06:30 AM   #6
hari_seldon99
Member
 
Registered: Jun 2003
Location: Front of PC
Distribution: Linux Mandrake
Posts: 212

Rep: Reputation: 30
Similar issue

Hi,


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)


output of top right now:

Cpu(s): 0.7% user, 0.7% system, 0.0% nice, 98.7% idle
Mem: 246920k total, 242604k used, 4316k free, 11676k buffers
Swap: 530104k total, 24k used, 530080k free, 100752k cached



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.



Regards,
AR
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mdk LE 2005 Eats ram? Damnation Linux - General 9 07-16-2005 03:31 AM
System lags and eats a lot of swap space over a few days Kremit Linux - General 4 06-27-2005 12:30 PM
telling linux to use not ram but swap ? supersucker Linux - Newbie 5 05-19-2005 05:28 PM
16 GB of RAM and Linux still uses over 1 GB of a 2 GB swap partition!? lumberjack77 Linux - Software 8 09-25-2003 01:07 PM
Swap and RAM ? mikeshn Linux - General 1 09-18-2002 09:33 PM


All times are GMT -5. The time now is 09:37 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
Open Source Consulting | Domain Registration