HttpRuntime.Cache scavenging default behavior?
When adding items using the default insert method Insert开发者_运维百科(key, value) and as such using the default behavior of HttpRuntime.Cache, when does the scavenging take place?
The limit on the application pool that hosts my application is 0 (unlimited)... but I see no way to find out how big the cache can get before scavenging occurs? The problem is I am caching a potentially very large amount of data but I have limited memory on the server and I want to avoid recycling of the app pool.
I am asking in the context of IIS6 and IIS7.
Thank you.
The short answer is that the cache begins to scavenge at Cache.EffectivePrivateBytesLimit.
The default limit is calculated using a number of factors, and generally should keep your process from excessive recycling. Ideally an application won't be affected by a recycle, but I realize there are many reasons why that isn't always possible. If needed, you should be able to set memory limits for the cache in coordination with the app pool recycle settings.
Thomas Marquardt from the asp.net team wrote a very interesting post explaining the details.
精彩评论