After some memory problems on a server, I started to look into it: what do all those number in the output of free actually mean? And, I found the answer in a forum:

bf@tbwb-dt-bf:~> free -m
             total       used       free     shared    buffers     cached
Mem:          3978       3848        130          0         28       1985
-/+ buffers/cache:       1834       2144
Swap:         2055          0       2055

What do these numbers mean? Well, the first row is your physical RAM. That is, what is actually in chips on the motherboard of your computer. And, of that, the command shows what is actually exactly in use. In applications, buffers, caches, kernel, etc. (In this case in megabytes, because of the -m option with free.)

But, as we all know, Linux loves to cache everything. All that is read and received gets a place in the buffer memory. Most the time, there is more than enough memory available to do that. Those are the ‘buffers’ and ‘cached’ numbers. They really are in use in the system’s memory, but when an application needs RAM, the kernel will release those buffers. And the result of that, is in the line below. Following schematic shows how it works:

bf@tbwb-dt-bf:~> free -m
             total       used       free     shared    buffers     cached
Mem:             T          U          F          S          B          C
-/+ buffers/cache:      U-B-C      F+B+C
Swap:           TS         US         FS

The numbers in the second row are the used and free RAM for applications. ‘used’ minus ‘buffers’ minus ‘cached’ is in use by applications; ‘free’ plus ‘buffers’ plus ‘cached’ is available for new ones. And if the kernel runs out of that, the OOM-killer steps in. But I won’t discuss that further here.

Categories: Opinie

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.