EnterpriseDB/system_stats

Inaccurate Memory Usage Reporting Due to Not Considering MemAvailable

Opened this issue · 0 comments

Environment

  • pgAdmin Version: 8.4
  • System Stats Extension Version: 2.1
  • OS: Ubuntu 22.04
  • Browser: Google Chrome

Description:

The system_stats extension seems to be reporting used memory by subtracting the 'MemFree' value from the 'MemTotal' value in /proc/meminfo. However, this does not account for the 'MemAvailable' value, which provides a more realistic figure of how much memory is truly available for new processes, as it includes cached and buffered memory that can be reallocated.

Steps to Reproduce:

  1. Open pgAdmin's dashboard to view system statistics.
  2. Compare the memory usage reported by pgAdmin with the output of cat /proc/meminfo in the terminal.

Expected behavior:

The memory usage reported by the system_stats extension should consider 'MemAvailable' to provide an accurate representation of how much memory is available for new processes, without causing swapping.

Current behavior:

The system_stats extension reports memory usage based on 'MemTotal' minus 'MemFree', leading to a potential misunderstanding of the actual available memory, especially in scenarios where a significant portion of the memory is used for caches and buffers but can be made available.

Possible Fix:

Modify the memory usage calculation in the system_stats extension to take 'MemAvailable' into account when computing available memory. This would align the reported memory usage with modern Linux memory reporting standards.

Additional context:

Here is a sample output from /proc/meminfo:

MemTotal: 131569360 kB
MemFree: 724984 kB
MemAvailable: 123998908 kB

In this example it says 124GB memory used and 802MB free, even tho it's actually only around 7.6GB used and around 123GB available (as seen in the output from /proc/meminfo/):