Server Fault Asked by Muahmmad Zeeshan on February 2, 2021
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?
The currently accepted answer from 2009 is out-of-date. It is important to make sure that the information you are getting is correct and matches the version of free
(distributed in the Debian package procps
or equivalent in your distribution). It is also helpful to look at the output of man free
, and also man 5 proc
, which contains information about /proc/meminfo
, the file where free
gets its data from on Linux.
By default, free
's output is in kibibytes (1 kibibyte = 1024 bytes), as you can see in the manual page. I prefer to use the -h
argument, which shows suffixes, like this:
$ free -h
total used free shared buff/cache available
Mem: 15Gi 6.1Gi 1.9Gi 301Mi 7.5Gi 8.8Gi
Swap: 979Mi 0B 979Mi
The first line Mem
means:
total
(Mem): total installed memory (that is MemTotal
from /proc/meminfo
), this all the memory in RAMused
(Mem): used memory, equal to total - free - buffers - cache
free
(Mem): unused memory (that is MemFree
), this all the memory that is unused for anything (even caches) in RAMshared
(Mem): this is the amount of memory used mainly for tmpfs
(Shmem
)buff/cache
(Mem), sum of buffers
and cache
:
buffers
: memory used by kernel buffers (Buffers
), which is memory that the kernel can take advantage ofcache
: memory used by the page cache and slabs (Cached
and SReclaimable
). The page cache contains the contents of files in the filesystem cached to RAM, and it is generally a good thing for this to be a high number. I presume "slabs" are a similar caching feature.available
(Mem): this is an estimate of how much memory is available for starting new applications, without swapping. It includes most of memory counted in the cache
field (since the page cache can be dropped to start new applications), but it does not count swap (since it is generally preferable not to use slow swap space).The second line is Swap
. This is my explanation:
total
(Swap): this is the total amount of disk space reserved for swap (SwapTotal
in proc/meminfo
). You can check by checking that this matches with the output of swapon -s
.used
(Swap): the amount of swap disk space that is currently being used. Again, you can check this by comparing it with the output of swapon -s
free
(Swap): the amount of swap disk space that is currently not being used (SwapFree
in /proc/meminfo
). It is equal to total (Swap) - used (Swap)
Answered by Flimm on February 2, 2021
The first line means:
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.used
: memory in use by the OS.free
: memory not in use.total
= used
+ free
shared
/ buffers
/ cached
: This shows memory usage for specific purposes, these values are included in the value for used
.The second line gives first line values adjusted. It gives the original value for used
minus the sum buffers+cached
and the original value for free
plus the sum buffers+cached
, hence its title. These new values are often more meaningful than those of first line.
The last line (Swap:
) gives information about swap space usage (i.e. memory contents that have been temporarily moved to disk).
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 Mem: 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:
line gets low.
For more details about the meaning of the numbers, see e.g. the questions:
Note that the output of free
was changed in procps 3.3.10 (released in 2014). The columns reported are now "total", "used", "free", "shared", "buff/cache", "available", and the meanings of some of the values changed, mainly to better account for the Linux kernel's slab cache.
See Debian Bug report #565518 for the motivation, and What do the changes in free
output from 14.04 to 16.04 mean? for more details information.
Answered by sleske on February 2, 2021
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.
Answered by womble on February 2, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP