memory_linux.go 239 B

123456789101112131415
  1. //go:build linux
  2. package memory
  3. import "syscall"
  4. func TotalSysMemory() uint64 {
  5. sysInfo := &syscall.Sysinfo_t{}
  6. err := syscall.Sysinfo(sysInfo)
  7. if err != nil {
  8. return 0
  9. }
  10. return uint64(sysInfo.Totalram) * uint64(sysInfo.Unit)
  11. }