views:

37

answers:

0

Environment.WorkingSet returns the working set incorrectly for my asp.net application which is the only application in its application pool.

On a Windows 2003 Server SP2 with 3GBs of Ram which is a VMWare Virtual Machine, it reports working set as 2.047.468.061 bytes(1952MBs) and Process.WorkingSet value is 75.563.008 bytes(72MBs).

• Memory Status values returned by GlobalMemoryStatusEx:

AvailExtendedVirtual : 0 
AvailPageFile: 4.674.134.016 
AvailPhys: 2.140.078.080 
AvailVirtual: 1.347.272.704 
TotalPageFile: 6.319.915.008 
TotalPhys: 3.245.568.000 
TotalVirtual: 2.147.352.576  

• GetProcessMemoryInfo()

Working Set : 55.140.352 
Peak Working Set: 75.571.200 
PageFile : 94.560.256 
QuotaPagedPoolUsage : 376.012 
QuotaNonPagedPoolUsage : 33.261  

• GetProcessWorkingSetSize() - min : 204.800 - max : 1.413.120

• GetPerformanceInfo()

CommitLimit : 1.542.948 pages 6.319.915.008 bytes  
CommitPeak : 484.677 pages 1.985.236.992 bytes  
CommitTotal : 417.514 pages 1.710.137.344 bytes  
HandleCount : 57.012  
KernelNonpaged : 8.671 pages 35.516.416 bytes  
KernelPaged : 27.302 pages 111.828.992 bytes  
KernelTotal : 35.973 pages 147.345.408 bytes  
PageSize : 4.096 bytes  
PhysicalAvailable : 508.083 pages 2.081.107.968 bytes  
PhysicalTotal : 792.375 pages 3.245.568.000 bytes  
ProcessCount : 43  
SystemCache : 263.734 pages 1.080.254.464 bytes  
ThreadCount : 1.038  

After loding the new patch, http://support.microsoft.com/kb/983583/en-us, .NET Version changes to 2.0.50727.3615 and Environment.WorkingSet now returns the value: 2.047.468.141.(which is 80 bytes bigger than previous one)

On a Vista machine with 3GBs of Ram, Environment.WorkingSet and Process.WorkingSet values are similar and around 37 MBs.

So, why Environment.WorkingSet returns a fixed value? Restarting the application pool does not change anything, it always return the same magic value, 2.047.468.061.

I have also setup an .NET 1.1.4322.2443 application, and it weirdly WorkingSet is returned a number from a random set of unrelated numbers(193.654.824, 214.101.416, 57.207.080, 287.635.496) each time page refreshed while GetProcessMemoryInfo() returns the expected number.

I have also found that when the application run by impersonating "NT AUTHORITY\NetworkService" account this problem does not occur, Environment.WorkingSet returns the expected number both .net v1.1 and v2.0.

I have checked CodeAccessPermissions like EnvironmentPermission for windows user and NetworkService but could not find anything that restricts reading the WorkingSet value.

So, what could cause this? Is it a bug, some incorrect configuration or corrupt file etc.?