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

mem.VirtualMemory(): wrong page size on darwin arm64
tags/v3.22.7
shirou 3 years ago committed by GitHub
commit 190dfee6b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

Loading…
Cancel
Save