Odd Memory Discrepency on Shared CPU Linode
Hello,
When I run free -h
I see:
root@localhost:~# free -h
total used free shared buff/cache available
Mem: 7.8Gi 1.6Gi 211Mi 0.0Ki 6.0Gi 5.9Gi
Swap: 511Mi 145Mi 366Mi
How is it possible that this Linode has total memory of 7.8G yet only has 211M free when 1.6G of 7.8G is being used? Furthermore, given that only 1.6G of 7.8G is being used, why is the server using the swap?
Do Linodes with shared CPU's have dedicated memory?
1 Reply
Hi there,
I'm happy to shed a little more light on what you are seeing. There are a few things that contribute to the outputs you've shared. First is the way that Linux allocates free memory on your system, often Linux will make use of free ram for disk caching.
Looking at the outputs you've shared this is telling us that at this moment 211M of ram is free, while 6GB is being borrowed for disk caching. Under the available column you can see that 5.9 GB worth of ram are available for the system to use that it can essentially take back from disk caching when needed. This site does a great job explaining this in more depth: Linux ate my RAM!
As for why swap is being used it may be that your system's swappiness may be tuned to be a bit overly aggressive. This Community post goes into detail about what swappiness is and how to adjust it: High swap usage in spite of low RAM usage.
Resources are shared between Linodes on the same host, the number of Linodes on a host is limited to prevent ram contention between Linodes. This is the reason that even powered down a Linode will accrue charges, resources are reserved for the Linode regardless of if it's powered on or not.
Hope that helps!