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

2009-01-30 Thread Tony Cappellini
Tim While monitoring The task manager/Performance Tab It seems as though Windows XP is almost always paging, even when all of available memory is not being used. This doesn't make sense and seems to be wasteful. Why should the OS be wasting time paging, when it doesn't need to (aka when all of

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

2009-01-30 Thread Tim Roberts
Tony Cappellini wrote: While monitoring The task manager/Performance Tab It seems as though Windows XP is almost always paging, even when all of available memory is not being used. This doesn't make sense and seems to be wasteful. Why should the OS be wasting time paging, when it doesn't

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

2009-01-29 Thread Steven James
For the display of bitmaps, most apps take the approach of creating (sometimes multiple) low-res versions of the images, then swapping out so that only what you need at the moment is loaded in to memory. For instance, create a 50x50 version, a 100x100 version, and a 500x500 version. Only load the

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

2009-01-29 Thread Vernon Cole
Geoff: Congratulations, you have just provided an excellent example of Nathan's first law: *Software is a gas* Software always expands to fit whatever container it is stored in. http://www.codinghorror.com/blog/archives/000677.html -- VC On Thu, Jan 29, 2009 at 5:18 AM, Steven James

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

2009-01-29 Thread Tim Roberts
geoff wrote: I am hoping someone could steer me in the right direction on how to calculate the amount of RAM available to a process. I found the post below from Tim Roberts - a belated thanks Tim for your patient responses ! and it seems we regularly hit this limit. We have an application

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

2009-01-29 Thread geoff
There's no easy fix. Thumbnails and some kind of least-recently-used caching scheme are probably your best choices. As Steven pointed out, you could always install a Win64 system and a 64-bit Python. Then, you can get about 8TB of process space. However, that's not particularly friendly

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

2009-01-29 Thread Steven James
Not an expert on this, but googling win32 performance counters led me here: http://msdn.microsoft.com/en-us/library/aa373193(VS.85).aspx Should let you get the available physical memory in the system. Not sure that you can specify to Windows that you want physical memory when you create the image

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

2009-01-29 Thread Tim Roberts
geoff wrote: Any tips/hints on calculating the potentially available space ? Do you mean the total amount of process virtual memory space still available? You can actually get that from the GlobalMemoryStatusEx API. There's no Python wrapper for that, as far as I know, but here's a ctypes

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

2009-01-29 Thread Tim Roberts
Steven James wrote: Not an expert on this, but googling win32 performance counters led me here: http://msdn.microsoft.com/en-us/library/aa373193(VS.85).aspx http://msdn.microsoft.com/en-us/library/aa373193%28VS.85%29.aspx Should let you get the available physical memory in the system. Not

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

2009-01-29 Thread Steven James
Agreed, but PDH can give per-process statistics, too. For high-memory-usage apps, I would think that it would be nice for your app to know whether it is *likely* to need to swap out (by comparing needed memory to availably physical memory). Anyway, using the same API, you can determine how much

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

2009-01-29 Thread geoff
from ctypes import * from ctypes.wintypes import * class MEMORYSTATUSEX(Structure): _fields_ = [ ('dwLength', DWORD), ('dwMemoryLoad', DWORD), ('ullTotalPhys', c_ulonglong), ('ullAvailPhys', c_ulonglong), ('ullTotalPageFile', c_ulonglong),

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

2009-01-29 Thread Tim Roberts
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

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

2009-01-29 Thread geoff
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