[python-win32] How to calc amount of avail RAM in a process ?

Tim Roberts timr at probo.com
Fri Jan 30 03:10:08 CET 2009


geoff wrote:
>
> There does appear to be this win32api.GlobalMemoryStatusEx().
>   

It wasn't in mine (I checked there first!), but I am a couple of
releases behind.

> 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)
>   

So, you have used 1.7GB of your 2GB.  It's likely that the remaining
350MB is so badly fragmented that you can't get a single chunk as large
as you need.

> 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.
>   

Yes, indeed.

> 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 ?
>   

I would caution you not to draw any conclusions based on the physical
numbers.  You WANT your system to be using all of its physical memory. 
Unused physical memory is just wasted money.  The operating system will
page things in and out as needed, on a demand basis, to make sure that
pages you are really USING stay in memory.  The other pages will be used
by DLLs, other processes, and disk caching.  Also remember that, if the
page file gets low, the system will allocate more.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list