How does CDM calculate memory usage on Linux

Document ID : KB000118534
Last Modified Date : 21/05/2019
Show Technical Document Details
Question:
What formula does the cdm probe use to calculate memory usage?
Answer:
Cdm reads the proc/meminfo file to obtain the memory usage qos data.

for example
# cat /proc/meminfo
MemTotal:        8175444 kB
MemFree:          154404 kB
Buffers:               4 kB
Cached:          1978176 kB
SwapTotal:       8257532 kB
SwapFree:        2962720 kB
 

The probe uses the following formulas for the different qos metrics

 
QOS_MEMORY_TOTAL (Total Memory MB) = (MemTotal + SwapTotal) / 1024
QOS_PHYSICAL_MEMORY_TOTAL (Physical Memory MB) = MemTotal / 1024
QOS_MEMORY_SWAP (SwapUsed MB) = (SwapTotal - SwapFree) / 1024
QOS_MEMORY_USAGE (Total Memory Used MB) = (MemTotal - MemFree - Buffers - Cached + SwapUsed) /1024
QOS_MEMORY_PHYSICAL (Physical Memory Used MB) = (MemTotal - MemFree - Buffers - Cached) /1024
QOS_MEMORY_PERC_USAGE (Total Memory Used %) = (Total Memory Used/Total Memory) * 100
QOS_MEMORY_PHYSICAL_PERC (Physical Memory Used %) = (Physical Memory Used/Physical Memory) * 100

Since cdm v5.40 the QOS_MEMORY_PHYSICAL metric, by default, excludes the buffer and cache.

If you follow the resolution in KB000047141 to include the buffer and cache, the calculation for the metric is
QOS_MEMORY_PHYSICAL (Physical Memory Used MB) = (MemTotal - MemFree) /1024

 
Additional Information:
  • The meminfo file reports the memory in KB and the probes reports the QOS Metric in MB hence we divide by 1024 in the above formulas.
  • You will very likley see a small difference in the values in meminfo and the QOS metric. Memory usage is a constantly shifting value and the probe will have collected at a slightly different time to when you viewed the meminfo file.