Why does my server show

            total      used      free   shared buffers    cached
    Mem: 12286456  11715372    571084        0   81912   6545228
-/+ buffers/cache:  5088232   7198224
   Swap: 24571408     54528  24516880

I have no idea on calculating the memory in linux. I think it says that 5088232 is used where as 7198224 is free, meaning it is actually consuming 5GB of RAM?

link|improve this question

30% accept rate
1  
feedback

3 Answers

up vote 26 down vote accepted

The display columns mean:

  • total: Your total (physical) RAM (excluding a small bit that the kernel permanently reserves for itself at startup); that's why it shows ca. 11.7 GiB , and not 12 GiB, which you probably have
  • use: memory in use by the OS
  • free: memory not in use

total=use+free

  • shared/buffers/cached: This shows memory usage for specific purposes; the numbers are included in the value for "use". This is why the second line gives the numbers for used/free minus the sum cached+buffers.

The first line is about your physical memory (RAM), the last line "swap" gives the same information about swap space usage (i.e. memory contents that have been temporarily moved to disk). The second line gives the numbers for used/free minus the sum cached+buffers (because that value is often more meaningful).

To actually understand what the numbers mean, you need a bit of background about the virtual memory (VM) subsystem in Linux. Just a short version: Linux (like most modern OS) will always try to use free RAM for caching stuff, so "free" will almost always be very low. Therefore the line "/+ buffers/cache:" is shown, because it shows how much memory is free when ignoring caches; caches will be freed automatically if memory gets scarce, so they do not really matter.

A Linux system is really low on memory if the free value in "/+ buffers/cache:" gets low.

For more details about the meaning of the numbers, see e.g. the questions:

http://serverfault.com/questions/23433/in-linux-what-is-the-difference-between-buffers-and-cache-reported-by-the-fr

http://serverfault.com/questions/9442/why-does-red-hat-linux-report-less-free-memory-on-the-system-than-is-actually-ava

link|improve this answer
1  
+1 Great answer. – Willie Wheeler Nov 25 '09 at 4:29
feedback

The buffers/cache line shows you how much memory is used by programs (first of those columns), and is free for programs to use (second column). It's a fairly esoteric number, and not something you'd really look at much in practice.

link|improve this answer
And what does the first line (mem line) means – Muahmmad Zeeshan Nov 17 '09 at 11:14
4  
That you've got 12GB of RAM installed in the system, 11.5GB of which is used and 0.5GB or so is currently unused. Approximately 82MB of the used memory is used for buffers (network connections, etc), whilst about 6.5GB is being used to store copies of data on disk, so that data won't have to be re-read if it's needed again. – womble Nov 17 '09 at 11:33
Let me just summarize what i understood. server have 12GB of ram installed. off which first line shows 11.5GB is used. 82MB is free. Second line shows 4.8GB is used by programs. and 6.86GB is being used to copy disk data (second row second column). Now it all means that the system has reached its limits and we have to install more memory? – Muahmmad Zeeshan Nov 17 '09 at 11:43
3  
@Muhammad: "82MB is free." - no, 57MiB is free (but that doesn't really matter, see my answer). "Now it all means that the system has reached its limits" - No, not at all. The system has 6.9GiB in use for caching, which it will readily give to applications, so there's lots of room. Also, swap usage is very low (ony ca. 50MiB). If memory starts getting tight, swap usage will rise. At present you're barely using half the RAM you have. – sleske Nov 17 '09 at 11:50
2  
Have you considered asking a new question at some point? – womble Nov 17 '09 at 13:27
show 6 more comments
feedback

For anyone needing an even more simple, step-by-step explanation, check http://thoughtsbyclayg.blogspot.com/2008/09/display-free-memory-on-linux-ubuntu.html, his explanation helped me a lot.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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