Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I use free to get the amount of free space on some of my servers. Its output is something like:

$ free -m
             total       used       free     shared    buffers     cached
Mem:           374        366          8          0         58         98
-/+ buffers/cache:        209        165
Swap:         1906        120       1785

How much free space do I really have?

share|improve this question
    
free tells you about memory usage, not storage. df tells you about storage (which is what I, at least, read into "free space on a server"). –  Michael Kjörling Mar 6 '12 at 12:21
add comment

2 Answers 2

up vote 7 down vote accepted

The first line of the free output lists:

  • total Your total, physical (assuming no virtualization) memory
  • used How much of that is currently used (by anything)
  • free How much of that is completely free (not used at all)
  • shared (never anything there, ignore that column)
  • buffers Memory used by kernel buffers
  • cached Memory used for cache

The last two items, cache and buffers, is memory that is not allocated to specific user processes. It is memory reserved by the kernel to improve performance overall, but is not "application" memory. These areas will grow or shrink depending on kernel policies with respect to caching, memory pressure, application I/O patterns, etc.

Since these two columns are not user-allocated memory, and the zones can shrink (practically to zero) if user allocations require it, they are in a sense "free" - there's RAM there that can be freed up by the kernel if your apps actively need it.

That's what the second line tells you. It removes the buffer and cache memory from the used column (that's what the - means), and adds (+) them to the free column. (Rounding issue will happen.)

(The last line shows the state of your swap space.)

share|improve this answer
    
And having no free memory is a good thing (this for people coming from the Windows world). Memory is a very expensive, limited resource. Linux uses all of it. If your applications don't, the kenrel will use it to improve performance (this is covered by @Mat's answer above). –  Alexios Mar 6 '12 at 12:53
add comment

Without swap your real free space is 165. With cache you have 8MB free space. Without cache you have 165MB free. -/+ line is without cache. first line is with cache.

share|improve this answer
    
What's the meaning of the -/+? –  Adam Matan Mar 6 '12 at 6:14
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.