本文整理匯總了Golang中C.MEMORYSTATUSEX.dwLength方法的典型用法代碼示例。如果您正苦於以下問題:Golang MEMORYSTATUSEX.dwLength方法的具體用法?Golang MEMORYSTATUSEX.dwLength怎麽用?Golang MEMORYSTATUSEX.dwLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類C.MEMORYSTATUSEX
的用法示例。
在下文中一共展示了MEMORYSTATUSEX.dwLength方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Get
func (self *Mem) Get() error {
var statex C.MEMORYSTATUSEX
statex.dwLength = C.DWORD(unsafe.Sizeof(statex))
succeeded := C.GlobalMemoryStatusEx(&statex)
if succeeded == C.FALSE {
lastError := C.GetLastError()
return fmt.Errorf("GlobalMemoryStatusEx failed with error: %d", int(lastError))
}
self.Total = uint64(statex.ullTotalPhys)
return nil
}
示例2: PhysmemAvail
func PhysmemAvail() uint64 {
var msex C.MEMORYSTATUSEX
msex.dwLength = C.DWORD(unsafe.Sizeof(msex))
/* Preferable */
if C.GlobalMemoryStatusEx(&msex) != C.FALSE {
return uint64(msex.ullAvailPhys)
}
/* Fallback because it's incorrect over 4GB */
var ms C.MEMORYSTATUS
C.GlobalMemoryStatus(&ms)
return uint64(ms.dwAvailPhys)
}
示例3: Get
func (self *Mem) Get() error {
var statex C.MEMORYSTATUSEX
statex.dwLength = C.DWORD(unsafe.Sizeof(statex))
succeeded := C.GlobalMemoryStatusEx(&statex)
if succeeded == C.FALSE {
return syscall.GetLastError()
}
self.Total = uint64(statex.ullTotalPhys)
self.Free = uint64(statex.ullAvailPhys)
self.Used = self.Total - self.Free
self.ActualFree = self.Free
self.ActualUsed = self.Used
return nil
}