From a6cd6f803b35bd1e01cb9c85a471b0bd0514a11b Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Fri, 19 Feb 2016 23:37:43 +0100 Subject: [PATCH] Use Go's built in syscall.Getpagesize() --- mem/mem_darwin.go | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/mem/mem_darwin.go b/mem/mem_darwin.go index df997d7..5f744b8 100644 --- a/mem/mem_darwin.go +++ b/mem/mem_darwin.go @@ -10,27 +10,14 @@ import "C" import ( "fmt" - "os/exec" "strconv" "strings" + "syscall" "unsafe" "github.com/shirou/gopsutil/internal/common" ) -func getPageSize() (uint64, error) { - out, err := exec.Command("pagesize").Output() - if err != nil { - return 0, err - } - o := strings.TrimSpace(string(out)) - p, err := strconv.ParseUint(o, 10, 64) - if err != nil { - return 0, err - } - return p, nil -} - // VirtualMemory returns VirtualmemoryStat. func VirtualMemory() (*VirtualMemoryStat, error) { count := C.mach_msg_type_number_t(C.HOST_VM_INFO_COUNT) @@ -55,7 +42,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) { usedCount := totalCount - vmstat.free_count - pageSize := uint64(C.getpagesize()) + pageSize := uint64(syscall.Getpagesize()) return &VirtualMemoryStat{ Total: pageSize * uint64(totalCount), Available: pageSize * uint64(availableCount),