Linux Command Reference ยท Special Files and Directories
The /proc/meminfo file
Reference for /proc/meminfo: what MemTotal, MemFree, MemAvailable, Buffers, Cached and swap lines mean, the units, and how free and top calculate from it.
/proc/meminfo is the kernel's memory report. Each line is Name: value kB, generated when you read it. It is the data behind free, top and most monitoring tools. Reading it directly is handy in scripts, because the format is simple and needs no extra program.
The most important lesson is that free memory is not the number to watch. Linux uses spare RAM as a file cache, so MemFree is usually small on a healthy machine. MemAvailable estimates how much could be given to new programs without swapping, which is the figure to alert on.
grep -E '^(MemTotal|MemAvailable):' /proc/meminfo
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
All sizes are in kibibytes (1024 bytes), even though the suffix is kB. Selected lines:
| Field | Description |
|---|---|
MemTotal |
Usable RAM (less than installed: the kernel reserves some). |
MemFree |
RAM that is completely unused. |
MemAvailable |
Estimate of memory available to start applications without swapping (free plus reclaimable cache). Added in kernel 3.14. |
Buffers, Cached |
Memory used for block-device buffers and the page cache. |
SwapCached |
Swapped-out data also still in RAM. |
Active, Inactive |
Recently used and less recently used pages. |
SwapTotal, SwapFree |
Size and free part of swap. |
Dirty, Writeback |
Data waiting to be written, and being written, to disk. |
AnonPages, Shmem, Slab |
Program memory, shared and tmpfs memory, kernel object caches. |
CommitLimit, Committed_AS |
Overcommit accounting. |
HugePages_*, Hugepagesize |
Huge-page counters. |
Edge cases: some lines have no unit (HugePages_Total: 0). Inside containers the file may show the host's memory, not your cgroup limit; read /sys/fs/cgroup/memory.max for that.
Usage notes
- Used memory is best computed as
MemTotal - MemAvailable. Older tools usedMemTotal - MemFree - Buffers - Cached, which gives a similar answer on most systems. - Low
MemFreeis normal. Do not "free" the cache;echo 3 > /proc/sys/vm/drop_cachesonly slows the system down while the cache refills. - Swap use alone is not a problem. Constant swap in and out (watch
vmstat 1columnssiandso) is. - Units: divide by 1024 for MiB;
free -hdoes that for you. - Per process: use
/proc/PID/status(VmRSS) orsmem; see/proc/PID. - Parsing: the key has a trailing colon, so match
$1 == "MemTotal:"exactly, orMemFreealso matchesMemFreeSomethingin a loose regular expression. - OOM killer: when
MemAvailablereaches zero and swap is full, the kernel kills a process to recover; checkdmesgor the journal.