Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I read about Linux and cachd memory at linuxatemyram but there is something that doesn't make sense to me, if the server have even a low load, instead of freeing some cached memory it starts using swap, which makes the server slow..

Even now, when the server load is load average: 0.00, 0.00, 0.00 some memory is swapped while over 85% of the memory is taken for swapping.

I read similar questions such as this and this, but it's mentioned that swapping shouldn't happen. As well, up until 3 weeks ago a much smaller part of the memory was taken by cache, and we didn't change anything that was suppose to affect the cached memory.

Could you please tell me if this values are still OK or could it be that i have a problem?

Thanks!

[root@web01 ~]# cat  /proc/meminfo
MemTotal:      5183448 kB
MemFree:        249260 kB
Buffers:        330848 kB
Cached:        4317828 kB
SwapCached:         92 kB
Active:        2883596 kB
Inactive:      1882468 kB
HighTotal:     4315324 kB
HighFree:        63516 kB
LowTotal:       868124 kB
LowFree:        185744 kB
SwapTotal:     5799928 kB
SwapFree:      5799796 kB
Dirty:             368 kB
Writeback:           0 kB
AnonPages:      117356 kB
Mapped:          21076 kB
Slab:           152668 kB
PageTables:       4184 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:   8391652 kB
Committed_AS:   268708 kB
VmallocTotal:   116728 kB
VmallocUsed:      5404 kB
VmallocChunk:   110964 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     2048 kB

[root@web01 ~]# free
             total       used       free     shared    buffers     cached
Mem:       5183448    4932936     250512          0     330840    4317340
-/+ buffers/cache:     284756    4898692
Swap:      5799928        132    5799796

[root@web01 ~]# uname -a
Linux web01 2.6.18-164.15.1.el5PAE #1 SMP Wed Mar 17 12:14:29 EDT 2010 i686 i686 i386 GNU/Linux
share|improve this question
1  
The idea that swap makes a system slow is entirely false. Your system will use swap only when it is beneficial to do so. –  David Schwartz May 26 at 2:59

2 Answers 2

up vote 9 down vote accepted

No! In your example post, effectively nothing is used for swap. You're using 92k (or 132k in the second screenshot) of swap which is incidental and trivial.

Cached memory is free memory that has been filled with the contents of blocks on disk. It will be vacated as soon as the space is needed by anything else. This is a good thing that enhances performance.

Compare your question with Server refuses to use swap partition.

As for why a server might swap data instead of releasing cache, it may be the case that your cached data was being read much more than your data stored in memory. Programs sometimes have pages that they rarely, if ever, visit. That space is better utilized by caching.

The vm.swappiness setting (also modifiable live through /proc...) will affect that, but spend some time looking closely at what's going on before adjusting it, particularly with your swap in / out counters. sar and atop are useful tools for this.

share|improve this answer
    
Thanks, after lot's of testing we found that you were right. Many thanks for your input! –  Kuf Aug 9 '12 at 15:01

Try to add vm.swappiness = 0 to /etc/sysctl.conf and run sysctl -p then, this will instruct kernel to release memory occupied by the file cache more aggressively if a user application requires a memory region from kernel.

share|improve this answer
    
Thanks for the fast answer, I will test it when the server will be idle. –  Kuf Aug 8 '12 at 15:46

Your Answer

 
discard

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.