Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running centos 5.8 with cpanel. Lately I am getting reports that my swap is full , but there is a lot of free memory to use.

top - 10:33:43 up 133 days, 17:00,  1 user,  load average: 0.05, 0.03, 0.05  
Tasks: 170 total,   1 running, 169 sleeping,   0 stopped,   0 zombie  
Cpu(s):  2.1%us,  0.5%sy,  0.0%ni, 97.2%id,  0.0%wa,  0.0%hi,  0.2%si,  0.0%st  
Mem:  24726100k total,  8255368k used, 16470732k free,   599560k buffers  
Swap:  1046520k total,   984740k used,    61780k free,  3641828k cached  

How do I solve this?
The unused ram memory should be used instead of the swap. Or should I increase the swap ( and how do I do that ? ).


share|improve this question
You forgot to tell us what the problem is! Do you have a performance problem? Is there any indication that this isn't the optimum memory usage pattern for your workload, RAM size, and swap size? – David Schwartz Apr 8 '12 at 9:37

That's rather curious... whilst the kernel will aggressively swap out pages that aren't in use to allow for more disk cache, it won't usually do that until most of the memory is actually being used for cache.

I can think of two possibilities here:

  1. The top output you've provided was taken at a time when a large memory-using process had just terminated, leaving a large amount of unused RAM. Decent sar output (of memory and swap usage) over an extended period would confirm or refute this.
  2. You've turned the swappiness knob waaaay the hell up, and so the kernel's merrily following your instructions and swapping everything out it can get it's hands on. Double-check /proc/sys/vm/swappiness (default is 60) and wind it back if it's higher than that (you can also set it even lower if you really want to, but don't blame me if your machine ends up performing like balls because it doesn't have any disk cache).

Also, I wouldn't worry that the machine has lots of pages swapped out -- just give the machine more swap and let it do it's thing. It's almost guaranteed that the kernel memory manager is smarter than you at optimising memory usage.

share|improve this answer
Swappiness is set at default (60) , top has been indicating these values for the last couple of days. How do I increase the swap then ? thank you ! – Paolo_NL_FR Apr 8 '12 at 8:58
Increase the size of the swap partition, or add a second swap partition. Best to ask a new question for that, rather than try to handle that in comments. – womble Apr 8 '12 at 9:06
Ok thank you , I am not a sysadmin , so this is new ground for me. Do you have a good tutorial or a step by step example on how to achieve this on centos ? – Paolo_NL_FR Apr 8 '12 at 9:10
If you're not a sysadmin, you're on the wrong site. Try posting a question on – womble Apr 8 '12 at 9:24
something being in swap doesen't mean its not in memory. this is called swap cache: grep SwapCached /proc/meminfo. This means that the program is in fact both, in memory and in swap. Thus when system need to free up some memory, it can just remove it instead of costly swaping it out at the moment. – Fox Apr 8 '12 at 9:28

Are you sure there is a problem to solve? Do you experience low performance? Check for instance "Optimizing memory usage" AT A lot of used swap space does not mean there actually is a problem.

share|improve this answer

I am not sure if your high swap usage is an indicator for a problem. Have a look at dstat or vmstat and watch if there is any activity in the swap area. I have seen similar situations on a server of one of my customers. The swap was almost full, but not used in any way (no I/O for the swap seen). In my case, it was not a problem at all!



followed by


will empty your swap if you have enough free RAM.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.