[python-win32] How to calc amount of avail RAM in a process ?
geoff
imageguy1206 at gmail.com
Fri Jan 30 02:58:36 CET 2009
> from ctypes import *
> from ctypes.wintypes import *
>
> class MEMORYSTATUSEX(Structure):
> _fields_ = [
> ('dwLength', DWORD),
> ('dwMemoryLoad', DWORD),
> ('ullTotalPhys', c_ulonglong),
> ('ullAvailPhys', c_ulonglong),
> ('ullTotalPageFile', c_ulonglong),
> ('ullAvailPageFile', c_ulonglong),
> ('ullTotalVirtual', c_ulonglong),
> ('ullAvailVirtual', c_ulonglong),
> ('ullExtendedVirtual', c_ulonglong),
> ]
>
> def GlobalMemoryStatusEx():
> x = MEMORYSTATUSEX()
> x.dwLength = sizeof(x)
> windll.kernel32.GlobalMemoryStatusEx(byref(x))
> return x
>
> z = GlobalMemoryStatusEx()
> print z.ullAvailVirtual
There does appear to be this win32api.GlobalMemoryStatusEx().
In monitoring my system before and after the process crashed, it
yielded this result below
- it is supposed to be a table, but I think the HTML is mangling the formatting.
key: start crash ( diff)
TotalPageFile: 6256201728 6256201728 ( 0)
AvailVirtual: 2068193280 346382336 ( -1721810944)
MemoryLoad: 33 73 ( 40)
TotalPhys: 4284137472 4284137472 ( 0)
AvailExtendedVirtual: 0 0 ( 0)
Length: 64 64 ( 0)
TotalVirtual: 2147352576 2147352576 ( 0)
AvailPhys: 2849738752 1146531840 ( -1703206912)
AvailPageFile: 4721647616 3014774784 ( -1706872832)
If understand your guidance above, monitoring the 'AvailVirtual'
should allow be to intelligently guess when the user is approaching
the 'cliff' as the process is running.
And I would think that examining the AvailPhys should tell me before
the process starts if there might be a problem/issue with the system
doing some sort of memory swapping/caching to the pagefile ?
More information about the python-win32
mailing list