Setting cache limits in ASP.NET 2.0
Since ASP.NET 2.0 you have full control over much memory the ASP.NET cache is allowed to use per application, in this example I've set it to 200MB. By looking at the performance monitor you see that the Microsoft.NET memory usage keeps itself under 300MB (including overhead from non-cached data) even though I am trying to fill up the cache by creating many thousands of pages in EPiServer CMS.
I would be very careful to set this value too low because it can cripple the performance of any site. But its great that its configurable instead of that magic 60% of whatever the process was allowed to use (which in the end caused OutOfMemoryException if you did not configure everything correctly and had lots of cached content).
<system.web>
<caching>
<cache
disableMemoryCollection="false"
disableExpiration="false"
privateBytesLimit="200000000"
percentagePhysicalMemoryUsedLimit="90"
privateBytesPollTime="00:01:00"
/>
</caching>

05 June 2008