Return physical free memory on Windows
()
| 219 | |
| 220 | |
| 221 | def physical_free_windows(): |
| 222 | """Return physical free memory on Windows""" |
| 223 | |
| 224 | from ctypes import c_ulong, c_ulonglong, Structure, sizeof, windll, byref |
| 225 | |
| 226 | class MEMORYSTATUSEX(Structure): |
| 227 | _fields_ = [ |
| 228 | ('dwLength', c_ulong), |
| 229 | ('dwMemoryLoad', c_ulong), |
| 230 | ('ullTotalPhys', c_ulonglong), |
| 231 | ('ullAvailPhys', c_ulonglong), |
| 232 | ('ullTotalPageFile', c_ulonglong), |
| 233 | ('ullAvailPageFile', c_ulonglong), |
| 234 | ('ullTotalVirtual', c_ulonglong), |
| 235 | ('ullAvailVirtual', c_ulonglong), |
| 236 | ('ullExtendedVirtual', c_ulonglong), |
| 237 | ] |
| 238 | |
| 239 | def GlobalMemoryStatusEx(): |
| 240 | x = MEMORYSTATUSEX() |
| 241 | x.dwLength = sizeof(x) |
| 242 | windll.kernel32.GlobalMemoryStatusEx(byref(x)) |
| 243 | return x |
| 244 | |
| 245 | z = GlobalMemoryStatusEx() |
| 246 | return z.ullAvailPhys |
| 247 | |
| 248 | |
| 249 | def physical_free(): |
no test coverage detected