At times we will need to know precisely how our Linux systems use memory. This article will examine how to use the Show
Free vs. Available memory explained.Ok, let’s get right to it then. What exactly 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 consider free memory as wasted memory. Once your applications/processes have launched and considerable uptime has passed, this number should almost always be small. Available memory is the amount of memory that is available for allocation to new or existing processes. Available memory is then an estimation of how much memory is available for use without swapping. The difference between free memory vs. available memory in Linux is, that free memory is not in use and sits there doing nothing. While available memory is used memory that includes but is not limited to caches and buffers, that can be freed without the performance penalty of using swap space. Free vs. Available memory compared.With this in mind, let’s look at two 60GB memory Linux servers.
Server A and Server B. We are going to use the go-to command: To view free vs. 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 also ran the Server A: Has less than 1% free (wasted memory), 13GB available memory. Server B: After 153 days of uptime, 30GB of memory is still wasted (free). Above lies the difference between free vs. available memory in Linux. When you compare both systems, even though the load averages are similar (processing the same workloads), it is evident that one server is making use of almost 100% of its memory (Server A) while the other server is wasting more than 50% of its memory (Server B). Note, that both of these servers have 12 CPU cores and swap to RAID 10 NVMe storage – thanks to StackLinux.com. Please note that the Linux Kernel will move memory pages least frequently used into swap space even if there is available memory. When analyzing these systems, a sysadmin may ask a few pertinent questions: Is swapping slowing the performance of Server A? Or, is it opportunistic swapping? Should we downgrade memory on server B? Or, is traffic/workload growth expected soon? Should Server A be upgraded with more memory? Or, during peak hours/swap, does “load average” stay well below 12.00? Can Server B be configured to use more buffers and cache? Would such a change improve performance (is it worth changing)? These are the questions that resulted in the current state of those above servers. Each admin will have to answer those questions and others, case by case, or hire an expert to do so. ConclusionDon’t be caught looking at “free” memory on your Linux system and jumping to conclusions because you should also consider available memory, buffers/caches and other factors as outlined. I’ve written some other articles on this topic that you may find helpful:
In addition to the free command, you can also use the following commands to check your Linux system’s memory usage:
Thanks for reading. I am looking forward to hearing from you! Published: September 7th, 2021 | Last updated: July 27th, 2022 Tags: commands, linux, memory, performance, server, sysadminsHow would see the amount of free memory on a Linux system?Open the command line.. Type the following command: grep MemTotal /proc/meminfo.. You should see something similar to the following as output: MemTotal: 4194304 kB.. This is your total available memory.. How do I see memory usage on Linux?Checking Memory Usage Using ps Command:. You can use the ps command to check memory usage of all the processes on Linux. ... . You can check memory of a process or a set of processes in human readable format (in KB or kilobytes) with pmap command. ... . Let's say, you want to check how much memory the process with PID 917 is using.. Which command will show you free used memory in Linux?For that, there is the free command. The free command displays: Total amount of free and used physical memory. Total amount of swap memory in the system.
What is free and available memory in Linux?The difference between free memory vs. available memory in Linux is, that free memory is not in use and sits there doing nothing. While available memory is used memory that includes but is not limited to caches and buffers, that can be freed without the performance penalty of using swap space.
|