microsoft / ApplicationInsights-node.js

Microsoft Application Insights SDK for Node.js
MIT License
325 stars 140 forks source link

[PerfCounters] Available memory metric does not match system values #673

Open markwolff opened 4 years ago

markwolff commented 4 years ago

https://github.com/microsoft/ApplicationInsights-node.js/blob/439bd18f74f167d903f40b2e63f872f934b8d089/AutoCollection/Performance.ts#L230

AVAILABLE_MEMORY metric is calculated with os.fremem(), which is not equivalent to available memory. An investigation should be done on how to properly measure and track this metric

xiao-lix commented 3 years ago

Did some investigation and the os.freemem() does return the equivalent value with available memory.

Available physical memory = Standby + Free Reference: link1, link2 image

os.freemem returns memory_status.ullAvailPhys = Standby + Free + Zero

What is ullAvailPhys: The amount of physical memory currently available, in bytes. This is the amount of physical memory that can be immediately reused without having to write its contents to disk first. It is the sum of the size of the standby, free, and zero lists.

xiao-lix commented 3 years ago

The above analysis is for Windows.

Adding more context to the issue : image