Check your RAM usage with free in Linux


Running free in terminal on Leveno Edge 72z with 16GB RAM.
Running free in terminal on Leveno Edge 72z with 16GB RAM.

free show RAM usage information. It helps you to know how much RAM is used by system, buffers, and cache. But it is a little bit complex for first time user, especially line 2. I am going to explain line by line and with some example.

How to read table cells?

The sample free command execution capture useI use the above example to explain which helps you to understand more quickly. Buffer and Cache in Hard Drive and Operating System explains the SSD Cache Size of your SSHD provides a detail explain for buffer and cache.

For line Mem from left to right:

  • The total physical memory install and identified by Linux is 16,282,648 bytes.
  • There are 7,154,496 bytes used by the operating system.
  • 9,128,152 bytes are free and may be used by operating system.
  • There is nothing by shared memory. This field might be removed in the future.
  • The file system use 189,872 bytes for buffering.
  • The file system use 4,590,176 bytes for cache.

For line -/+ buffers/cache from left to right:

  • 2,374,448 bytes is used by programs. It comes from 7,154,496 – (189,872 + 4,590,176).
  • There are actually 13,908,200 bytes to be claimed by running and new programs. it comes from 9,128,152 + 189,872 + 4,590,176

For line Swap from left to right:

  • The Swap partition is 25,172,988 bytes.
  • The operating system hasn’t use any swap yet.

Table as Formula

I use the following variables and formula to explain the relationship among these numbers:

"free" output  table with variables.
“free” output table with variables.
  • a = b + c
  • f = b – ( d + e )
  • g = c + d + e

More Thoughts

If you preferred to see numbers in different unites, add -g for GB and -m for MB for easier reading.

One thing need to be remind: the free memory might be non-continuous. It means you program might fail to clam memory for equal or less than the size. Because programs need continuous memory, while the number summarize all available memory.

Reference

  1. Computer Hope: Linux and Unix free command
  2. The Linux Juggernaut: Understanding free command in Linux/Unix
  3. Buffer and Cache in Hard Drive and Operating System explains the SSD Cache Size of your SSHD

Leave a comment

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