SystemMemoryBytes returns total physical memory in bytes, cached after first call. Returns 0 if the system memory cannot be detected (e.g., on non-Linux systems).
()
| 21 | // SystemMemoryBytes returns total physical memory in bytes, cached after first call. |
| 22 | // Returns 0 if the system memory cannot be detected (e.g., on non-Linux systems). |
| 23 | func SystemMemoryBytes() uint64 { |
| 24 | systemMemoryBytesOnce.Do(func() { |
| 25 | systemMemoryBytesValue = readSystemMemoryBytes() |
| 26 | }) |
| 27 | return systemMemoryBytesValue |
| 28 | } |
| 29 | |
| 30 | // readSystemMemoryBytes reads total physical memory from /proc/meminfo on Linux. |
| 31 | // Returns 0 if the file cannot be read or parsed (e.g., on non-Linux systems). |
no test coverage detected