Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Hello, I’m trying to fully understand the way DigitalOcean is calculating memory usage.
From the docs: DigitalOcean calculates memory consumption by evaluating memory information exposed in /proc/meminfo. On DigitalOcean, used memory is calculated by subtracting free memory and memory used for caching from the total memory amount.
If I expose the numbers on my droplet:
MemTotal: 3880364 kB
MemFree: 259960 kB
MemAvailable: 2647216 kB
Buffers: 0 kB
Cached: 1432548 kB
....
Slab: 1457128 kB
SReclaimable: 1371832 kB
....
The results are 3880364 MemTotal - (259960 MemFree + 1432548 Cached) = 2187856 kB This is about 56% (the same number that is indicated on monitoring graph)
On the other side, if I compare this output with the free command:
total used free shared buff/cache available
Mem: 3880364 847548 297784 129948 2735032 2615692
Swap: 0 0 0
I see that the used memory is 847548 kB, so this would be around 21%.
You can also figure out that the value for buff/cache in free command is different from the /proc/meminfo command Cached value.
I think that DigitalOcean needs to also add the SReclaimable value from /proc/meminfo to the sum on the cache field.
SReclaimable: The part of the Slab that might be reclaimed (such as caches)
If we sum SReclaimable and Cached values we get: 2804380 kB. That’s pretty close to the buff/cache value on the free command.
After looking at some comparison charts on the Red Hat website Interpreting /proc/meminfo and free output for Red Hat Enterprise Linux 5, 6 and 7 I have found the match from the free and /proc/meminfo field:
| free output | coresponding /proc/meminfo fields |
|---|---|
| Mem: buff/cache | Buffers + Cached + Slab |
In summary, do you think that DigitalOcean needs to add the SReclaimable value? And show memory usage as subtracting free memory and memory used for caching (Cached & SReclaimable) from the total memory amount?
Maybe I’m far away wrong, I’m no linux expert… What do you think?
Erina Jones
05c643336f3a4578a0b414e11ed8fc
378226414b344d3d9ef057316f83e8
792d8c6065294b4da466a26b2a99e4
KFSys
fe9c7f1f3d29491e8c9905409bd159
LittleSeaGreenMorel
Guram Chankseliani
Wilson Karl
KFSys
KFSys
KFSys