How to calculate used memory on Linux?

Posted February 6, 2020 2.4k views
Linux BasicsLinux Commands

Hi, wanted to get more information on how to get the real used memory value on a droplet with CentOS 7 x64.

I was reviewing how DigitalOcean calculates used memory in the monitoring graphs and they do it “used memory is calculated by subtracting free memory and memory used for caching from the total memory amount” from the information exposed in /proc/meminfo.

This is the correct way to calculate used memory on a Linux server?

I see other people calculating used memory as “dividing active memory by total memory amount” from the same information exposed in /proc/meminfo.

Any ideas on this? What do you think? As you can see I have little knowledge on this issue.

Thank you.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers
Show answer This answer has been marked as resolved by Shiroka.

This is the /proc/meminfo output:

MemTotal:        3880364 kB
MemFree:          222412 kB
MemAvailable:    2666848 kB
Buffers:              28 kB
Cached:          1536256 kB
SwapCached:            0 kB
Active:          1341356 kB
Inactive:         758104 kB
Active(anon):     654492 kB
Inactive(anon):    38632 kB
Active(file):     686864 kB
Inactive(file):   719472 kB