Free vs. Available Memory in Linux

Originally published at: Free vs. Available Memory in Linux

At times we will need to know precisely how our Linux systems use memory. This article will examine how to use the free command-line utility to view memory usage on a Linux system. In doing so, we will clearly define the difference between free vs. available memory on Linux systems.   Free vs. Available memory…

For most monitoring tools, the free memory is what is being used without considering cache/buffers. For example a server configured with 64GB and having free memory to be 5GB and available to be 30GB will be flagged as being under memory pressure. How do you think this gap can be resolved ?

1 Like

Having 5GB not in use and a healthy 30GB of cache and buffers can be further improved by tweaking the kernels cache pressure.

I’m on mobile this morning, but if I didn’t include how to tweak cache pressure to hold more data rather than swap or be removed I will edit this reply with a link to another article which details how to do so.

Oh and welcome to the community!

Edit: To make full use of memory on a system with more than adequate RAM installed. See the this article:

Quote:

Consider adjusting your server’s cache pressure and tendency to swap (vm.swappiness) by following the guide below, which is from the previous article: Linux server needs a RAM upgrade? Check with top, free, vmstat, and sar:

vfs_cache_pressure – Controls the kernel’s tendency to reclaim the memory, which is used for caching of directory and inode objects. (default = 100, recommend value 50 to 200)

swappiness – This control is used to define how aggressive the kernel will swap memory pages. Higher values will increase aggressiveness; lower values decrease the amount of swap. (default = 60, recommended values between 1 and 60) Remove your swap for 0 value, but usually not recommended in most cases.

Specific to your case:

On a healthy server with lots of available memory, use the following:

vm.swappiness=10
vm.vfs_cache_pressure=50

This will decrease the cache pressure [uses MORE memory for cache]. Since caching is good for performance, we want to keep cached data in memory longer. Since the cache will grow larger, we still want to reduce swapping to not cause increased swap I/O. [still promote opportunistic swapping]

To check current values using these commands use:

sudo cat /proc/sys/vm/swappiness
sudo cat /proc/sys/vm/vfs_cache_pressure

To enable these settings temporarily without rebooting, use the following commands:

sudo sysctl -w vm.swappiness=10
sudo sysctl -w vm.vfs_cache_pressure=50

To make these settings permanent:
Add or edit these lines in /etc/sysctl.conf file:

vm.swappiness=10 
vm.vfs_cache_pressure=50