1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-05-04 22:17:34 +08:00

Merge pull request #1334 from kyz/fix-darwin-pagesize

mem.VirtualMemory(): wrong page size on darwin arm64
This commit is contained in:
shirou 2022-07-29 20:58:03 +09:00 committed by GitHub
commit 190dfee6b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ package mem
/*
#include <mach/mach_host.h>
#include <mach/vm_page_size.h>
*/
import "C"
@ -12,8 +13,6 @@ import (
"context"
"fmt"
"unsafe"
"golang.org/x/sys/unix"
)
// VirtualMemory returns VirtualmemoryStat.
@ -34,7 +33,7 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
return nil, fmt.Errorf("host_statistics error=%d", status)
}
pageSize := uint64(unix.Getpagesize())
pageSize := uint64(C.vm_kernel_page_size)
total, err := getHwMemsize()
if err != nil {
return nil, err