views:

630

answers:

1

I am trying to get reliable information on when my C# application (Windows XP) will run out of memory. I did some research and tests on my machine and picked the most reliable perfmon counters:

Memory.Pages Output/sec
Memory.Available Bytes

I use thresholds and AND operator and it works quite well, but on the client machine (also Windows XP) both counters are useless. Available memory does not drop below 1GB and pages output is constant zero. After reading some logs I still don't see any useful counter.
Counters like committed memory give correct value, but the program runs out of memory (with paging killing the performance) after crossing 50%-60% of the 5GB available.

Any alternatives? I wouldn't like to be forced to try to allocate memory and catch OutOfMemory exceptions during the computations.

A: 

See When does a Windows process run out of memory?

Long story short, you want to be checking the Private Bytes, Virtual Bytes and/or Working Set for your process(es).

Patrick Cuff
The articles under the link were VERY helpful. The most relevant thing I've learned is that I should reserve the needed memory once on the beggining of the computations. I can easily catch OutOfMemory there.On the other hand I still don't know how to get the amount of memory *left* from perfmon.
kelebron