Skip to content

Instantly share code, notes, and snippets.

@yamahigashi
Created April 23, 2018 05:36
Show Gist options
  • Select an option

  • Save yamahigashi/b025c053922de5b28d823d891765c252 to your computer and use it in GitHub Desktop.

Select an option

Save yamahigashi/b025c053922de5b28d823d891765c252 to your computer and use it in GitHub Desktop.
import ctypes
class MEMORYSTATUSEX(ctypes.Structure):
_fields_ = [
('dwLength', ctypes.c_ulong),
('dwMemoryLoad', ctypes.c_ulong),
('ullTotalPhys', ctypes.c_ulonglong),
('ullAvailPhys', ctypes.c_ulonglong),
('ullTotalPageFile', ctypes.c_ulonglong),
('ullAvailPageFile', ctypes.c_ulonglong),
('ullTotalVirtual', ctypes.c_ulonglong),
('ullAvailVirtual', ctypes.c_ulonglong),
('ullAvailExtendedVirtual', ctypes.c_ulonglong)
]
info = MEMORYSTATUSEX()
info.dwLength = ctypes.sizeof(info)
ctypes.windll.kernel32.GlobalMemoryStatusEx(info)
print(info.ullTotalPhys/2**30)
print(info.ullAvailPhys/2**30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment