From e1d03ad65aa69cfa4a40415cb6d44f2935749e0d Mon Sep 17 00:00:00 2001 From: zhoujunhao <18853925545@163.com> Date: Wed, 17 Oct 2018 17:25:14 +0800 Subject: [PATCH] [FIX] Fix the problem of inaccurate host memory --- node/nodem/info/info_linux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/nodem/info/info_linux.go b/node/nodem/info/info_linux.go index 03f6fd684..a4353d1df 100644 --- a/node/nodem/info/info_linux.go +++ b/node/nodem/info/info_linux.go @@ -69,10 +69,10 @@ func readOS() map[string]string { } func getMemory() (total uint64, free uint64) { - sysInfo := new(syscall.Sysinfo_t) + sysInfo := syscall.Sysinfo_t{} err := syscall.Sysinfo(sysInfo) if err == nil { - return sysInfo.Totalram * uint64(syscall.Getpagesize()), sysInfo.Freeram * uint64(syscall.Getpagesize()) + return uint64(sysInfo.Totalram) * uint64(sysInfo.Unit), sysInfo.Freeram * uint64(syscall.Getpagesize()) } return 0, 0 }