|
|
@ -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
|
|
|
|