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.

The server runs well but I wonder if I should get more RAM. I only have a few MB of "free" memory and 1.2GB of "cached" memory:

free:

             total       used       free     shared    buffers     cached
Mem:          3945       3893         51          0         28       1216
-/+ buffers/cache:       2648       1296
Swap:         3895        857       3038

I learned that cached memory is used while it's free and not.

Is the cached value an indicator for the need of more RAM?

cat /proc/meminfo 1 day after flushing the cache:

MemTotal:      4040048 kB
MemFree:         32844 kB
Buffers:         18956 kB
Cached:        1249092 kB
SwapCached:     161576 kB
Active:        3611328 kB
Inactive:       189104 kB
SwapTotal:     3989496 kB
SwapFree:      2894200 kB
Dirty:           20520 kB
Writeback:           0 kB
AnonPages:     2523496 kB
Mapped:         217744 kB
Slab:            70940 kB
SReclaimable:    36756 kB
SUnreclaim:      34184 kB
PageTables:      99648 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:   6009520 kB
Committed_AS:  6401716 kB
VmallocTotal: 34359738367 kB
VmallocUsed:     18852 kB
VmallocChunk: 34359719439 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
HugePages_Surp:      0
Hugepagesize:     2048 kB

top:

top - 17:20:10 up 112 days,  3:06,  1 user,  load average: 1.01, 1.62, 1.48
Tasks: 208 total,   1 running, 207 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.6%us,  0.6%sy,  0.0%ni, 97.5%id,  1.3%wa,  0.0%hi,  0.1%si,  0.0%st
Mem:   4040048k total,  3953108k used,    86940k free,    16348k buffers
Swap:  3989496k total,  1095712k used,  2893784k free,  1235436k cached
share|improve this question
    
linuxatemyram.com –  MDMarra Nov 3 '12 at 16:57
    
Check the value of /proc/sys/vm/swapiness, try setting it to 0. That should reduce the use of swap, otoh the page cache will shrink. –  ott-- Nov 3 '12 at 18:56
add comment

2 Answers

up vote 3 down vote accepted

The cached value is not an indicator that you may need more ram - free ram is wasted ram, so the system will always try to fill any otherwise unused ram with cache.

You are using a lot of swap, which could be an indicator that more ram might be useful, but you say the system runs well, so it's probably fine.

share|improve this answer
1  
A good explanation of this behavior can be found at linuxatemyram.com –  zhenech Nov 3 '12 at 16:24
    
Thanks, nice info site. –  Martin Nov 3 '12 at 16:31
add comment

You have 1296MB of memory free for your applications to use (check the -/+ buffers/cache: line).

I cannot tell you if you need more ram, you know your usage.

Linux caches files from disk to ram, to get better (faster) data access times. Linux will use all your free (unused by applications) RAM to cache data from disk - even if you have ridiculus ammounts of RAM, it will use it up by caching data from the hard drive. When that RAM is needed for application use, it will dump some old cached data, and give that ram to the application that needs it.

share|improve this answer
    
Ok so I don't need more RAM yet. But getting more wouldn't hurt, since it could cache more data which would be improve the performance. –  Martin Nov 3 '12 at 16:28
    
@Martin: To say that it will increase the performance is a bit premature. It certainly could, but if does depends on your use pattern. It's quite certain however that is won't hurt :) –  SvW Nov 3 '12 at 17:51
add comment

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.