Why isn’t “Used memory MBytes” in performance counter of Azure Monitor equal to “used” got via free command?

Inquiry

Someone asked me about the following question.

Why one data is not equal to the other?

Indeed, both data are based on /proc/meminfo , but each data is derived from different equation. Therefore, one data is not equal to the other. The following screenshot is /proc/meminfo in my Linux box (Ubuntu 18.04). For comparison, output of free is also available in the same screenshot.

Performance counter (Log Analytics)

“Used Memory MBytes” is derived from the following equation.

UsedMemoryMBytes = MemTotal - MemAvailable 
UsedMemoryMBytes = 8,152,804 - 7,457,416
= 695,388 (KiB)
= 678 (MiB)

free command

Documents in each distribution elaborates data got via free command and equations to derive these data.

used = total - free - buffers - cache
= (MemTotal + SwapTotal) - (MemFree + SwapFree) - (Buffers) - (Cached + SReclaimable)
used = total - free - buffers - cache
= (MemTotal + SwapTotal) - (MemFree + SwapFree) - (Buffers) - (Cached + SReclaimable)
= (8,152,804 + 0) - (5,842,952 + 0) - 112,500 - (1,591,036 + 225,580)
= 380,736 (KiB)
= 371 (MiB)

Conclusion

Even if the same word of “used” is used, one data is different from another because each equation to derive data is not the same. Before using metric(s), you should check how to derive metric(s) carefully.

--

--

Cloud Solution Architect @ Microsoft. Passionate about Java (JVM/GraalVM) and open source technologies. All views are my own.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akihiro Nishikawa

Akihiro Nishikawa

53 Followers

Cloud Solution Architect @ Microsoft. Passionate about Java (JVM/GraalVM) and open source technologies. All views are my own.