9 modkernel32 = syscall.NewLazyDLL("kernel32.dll")
11 procGlobalMemoryStatusEx = modkernel32.NewProc("GlobalMemoryStatusEx")
14 // https://msdn.microsoft.com/en-us/library/windows/desktop/aa366589(v=vs.85).aspx
15 // https://msdn.microsoft.com/en-us/library/windows/desktop/aa366770(v=vs.85).aspx
16 type memorystatusex struct {
21 ullTotalPageFile uint64
22 ullAvailPageFile uint64
23 ullTotalVirtual uint64
24 ullAvailVirtual uint64
25 ullAvailExtendedVirtual uint64
28 // ReadMemInfo retrieves memory statistics of the host system and returns a
30 func ReadMemInfo() (*MemInfo, error) {
31 msi := &memorystatusex{
34 r1, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(msi)))
36 return &MemInfo{}, nil
39 MemTotal: int64(msi.ullTotalPhys),
40 MemFree: int64(msi.ullAvailPhys),
41 SwapTotal: int64(msi.ullTotalPageFile),
42 SwapFree: int64(msi.ullAvailPageFile),