Tuesday, December 21, 2010

Tweaking ASP.NET Memory settings

Hi,
I was doing a bit of experiment on contribution of ASP.Net Memory configuration for out of memory exception.(By refering mutilple papers)At the end of my experiment i was amazed by the way how the ASP.Net engine is selecting the value for its runtime.
Here are the list of items i had added based on the findings for all of our references.1)
It basically looks at 2 entries for memory settingsa) Entry at the process model(memory limit)b) Entry at the Cache settings( private byte Memory Limit)
Lets say, if both of them are not set, then how it picks up the entry is quite interesting..Any guess...It looks at the system /OS (32 or 64 bit) ,If it is 32bit and if my virtual address space of the process is upto 2GB - it choose the limit as 800 MB
If the os is of 32 bit and If the virtual address space limit is up to 3GB - then it choose 1800 MB
If it is 64 bit, then it takes 1TB as the limit
All the above input is gathered from msdn blog...
However if the system is low in memory, lets say i have just 500 MB of physical Ram, then the memory setting value is based on the least of above conditional result and 60% of 500 MB (which ever is the least , it takes that value), you might be wondered from where did i got 60% - this is the default setting about the memory limit exist in machine config file.
Now lets say - you had set memory values both at memory and cahce level(as i had mentioned earlier) then it takes which ever is the least among.

Last but not the least, w3wp.exe can't exist alone in any machine , it has to work/exist with other process as well. Now one more interesting entry at the config which plays a major role in determing the limit for .Net memory when total system memory is low.which we can configure at Cache entry( Percentange Physical memory used Limit), based on this percentage w3wp's appdomain will get recycled....

formula for calculation of % limit = (total memory - used memory)/total memory....

I hope this helps!
Regards,
-Vinayak

No comments: