systemTotalMemory returns the container-aware total system RAM in bytes. memory.TotalMemory() reports the HOST kernel total (syscall.Sysinfo on Linux), which lxcfs/LXD does NOT virtualize. Inside a container that over-reports physical RAM and, combined with the virtualized MemAvailable, inflates th
()
| 41 | // inflates the reported usage (see issue #8059). We instead derive the total |
| 42 | // from the minimum of all available container-aware candidates. |
| 43 | func systemTotalMemory() uint64 { |
| 44 | return chooseTotalMemory( |
| 45 | readFileBestEffort(cgroupV2MaxPath), |
| 46 | readFileBestEffort(cgroupV1LimitPath), |
| 47 | readFileBestEffort(procMemInfoPath), |
| 48 | memory.TotalMemory(), |
| 49 | ) |
| 50 | } |
| 51 | |
| 52 | // GetSystemRAMInfo returns real-time system RAM usage |
| 53 | func GetSystemRAMInfo() (*SystemRAMInfo, error) { |
no test coverage detected