MCPcopy
hub / github.com/mudler/LocalAI / systemTotalMemory

Function systemTotalMemory

pkg/xsysinfo/memory.go:43–50  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

41// inflates the reported usage (see issue #8059). We instead derive the total
42// from the minimum of all available container-aware candidates.
43func 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
53func GetSystemRAMInfo() (*SystemRAMInfo, error) {

Callers 1

GetSystemRAMInfoFunction · 0.85

Calls 2

chooseTotalMemoryFunction · 0.85
readFileBestEffortFunction · 0.85

Tested by

no test coverage detected