free vs available memory in linux

Sometimes we will need to know how our Linux systems use memory. This article will examine how to use it free Command-line utility for viewing memory usage on Linux systems. In doing so, we will clearly define the difference between available memory vs free memory on Linux systems.

Free vs Available memory explained.

OK, let’s fix that. What is free memory and how is it different from available memory?

free memory is the amount of memory that is currently not used for anything, For this reason, especially on servers, I like to treat free memory as memory wasted. Once your applications/processes are launched and considerable uptime has elapsed, this number should almost always be small.

available memory The amount of memory that is available for allocation to new or existing processes. Available memory is then an estimate of how much memory there is Available for use without interchange,

Difference Between Free Memory vs Available Memory in Linux The free memory is not in use and sits there doing nothing. Whereas available memory is used memory that includes but is not limited to caches and buffers, which can be freed without the performance penalty of using swap space.

Comparison of free vs available memory.

With that in mind, let’s look at two Linux servers with 60GB of memory. Server A And Server B, We are going to use the go-to command: free

To view free versus available memory in Linux, login to your server and enter the following command:

free -h

The result should look something like these two screenshots below. i ran too uptime Order it to confirm that both systems have been online for some time.

Free vs Available Memory Server A


Server A: Less than 1% free (wasted memory), 13GB of available memory.

Free vs Available Memory Server B


Server B: After 153 days of uptime, 30GB of memory is still wasted (free).

Above is the difference between free vs available memory in Linux. When you compare the two systems, even though the load average is the same (processing the same workload), it is clear that a server is using almost 100% of its memory (Server A) while the other server is wasting more than 50% of its memory (Server BNote, both of these servers have 12 CPU cores and swap in RAID 10 NVMe storage – thanks StackLinux.com,

Please note that the Linux kernel will move the least used memory pages to swap space, regardless of whether memory is available.

When analyzing these systems, a sysadmin might ask some pertinent questions: Is the swap slowing down Server A’s performance? Or, is it an opportunistic swap? Should we downgrade memory on server B? Or, is the increase in traffic/workload expected soon? Should Server A be upgraded with more memory? Or, during peak hours/swaps, does the “load average” remain below 12.00? Can Server B be configured to use more buffers and caches? Would such a change improve performance (is it worth changing)?

These are the queries that resulted in the current status of those above servers. Each administrator must answer those questions and others, case by case, or hire an expert to do so.

conclusion

Don’t get caught looking at the “free” memory on your Linux system and jumping to conclusions as you must also consider available memory, buffers/cache and other factors.

I have written some other articles on the subject that you may find helpful:

Apart from the free command, you can also use the following command to check the memory usage of your Linux system:

  • top – Shows an overall system view.
  • htop – Interactive process viewer and manager.
  • atop – For Linux server performance analysis.
  • Glances And nmon – htop and top options.
  • vmstat – Shows system memory, process, interrupt, paging, block I/O, and CPU information.
  • cat /proc/meminfo and others.

Thanks for reading. I will wait for your reply!

Published: September 7, 2021 | Last Updated: April 4, 2022

Leave a Comment