Understanding the Current Memory Usage in Linux

To check the overall memory usage on your linux, we can use the command: free
This will show the memory usage in KB (default),
If you want to check your memory usage in MB, enter the command free -m, in GB free -g , and in Bytes free -b

If you’re new to linux, you will probably be wondering what does all that stuff mean, what’s a buffer, what’s a cache, what’s a swap, what’s the actual free memory on my machine…

Let’s break it down row by row:
First Row (Total): This shows the total physical memory you have no your machine.
First Row (used): This is the overall allocated memory by the system.
First Row (free): This shows the free memory.
First Row (Shared): This shows the amount consumed by shared segments of code or data.
First Row (buffers): The amount of memory used as buffers. Buffers are feasible when a large block of data is assembled or disassembled (as required by a storage device), or when data may be delivered in a different order than that in which it is produced. Buffering sometimes increases transfer performance or reduces the variation or jitter of the transfer’s latency.
First Row (cached): The amount of memory used as cache.  Cache can increase the data transfer performance because there is a good chance that the same datum will be read from cache multiple times, or that written data will soon be read. A cache’s sole purpose is to reduce accesses to the underlying slower storage. For example, imagine having a simple webpage that shows information about a person, instead of accessing this page from the hard disk everytime a user visits this page, the cache will store it and deliver it to the user, and thus reducing the transfer speed.

Second Row (used):  This shows the data in memory that is being processed by the machine. The cache and buffers in First Row are just allocated by the system waiting to be used (and can be freed without causing any troubles, but of course it’s better to keep them to increase performance).
Second Row (free): This is the free memory if the cache and buffers are deleted from the memory. You can calculate this using a simple formula:
Free (in Row 1) + buffers (row 1) + cached (row 1) = Free (row 2)
for example in the screenshot above: 962912 + 166848 + 726844 = 1856604

Third Row (total): Shows the total of swap memory or virtual memory available on the machine.
Third Row (used): Shows the amount of swap memory used, usually the swap is used when the physical memory is all allocated.
Third Row (free): Shows the free swap on the system.

Four Row (total): Total available memory on the machine.
Four Row (used): Total Memory currently in use.
Four Row (free): Total Free memory.

One thought on “Understanding the Current Memory Usage in Linux”

Leave a Reply

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