views:

61

answers:

2

Environment.WorkingSet incorrectly reports the memory usage for a web site that runs on Windows 2003 Server.(OS Vers: Microsoft Windows NT 5.2.3790 Service Pack 2, .NET Vers: 2.0.50727.3607)

It reports memory as Working Set(Physical Mem.): 1952 MB (2047468061).

Same web site runs locally on Windows Vista with a Working Set(Physical Mem.): 49 MB (51924992).

I have limited access to the server and support is so limited :(. so i have computed the total memory by traversing with VirtualQuery. Total of pages with state: MEM_FREE is 1300 MB. (I guess server have 4 GBs of RAM and PAE is not enabled, max user mode virtual address is 0x7fff0000.)

So, i know working set is not only about virtual memory. But, is it normal to have such a high working set while its very low on another machine?

A: 

At a guess, Environment.WorkingSet is probably returning the value from GetProcessWorkingSetSize, which is basically what has been set with SetProcessWorkingSetSize. It's basically whatever the system has picked as the largest working set size it would like to see for this process, not necessarily anything to do with how much memory it's actually using. The basic effect is that when/if the process uses more memory than that, the system's working set trimmer goes to work seeing if it can get some of its memory paged out to disk.

Jerry Coffin
no, it is not using GetProcessWorkingSetSize, it uses GetProcessMemoryInfo() from psapi.dll to access process memory counter value, WorkingSetSize.
lockedscope
A: 

i think the problem is related to what is described in this article

http://www.chrisbrandsma.com/2005/05/fun-with-workingset-and-int32.html

lockedscope