Pardon if this is more serverfault vs. stackoverflow. It seems to be on the border.
We have an application that caches a large amount of product data for an e-commerce application using ASP.NET caching. This is a dictionary object with 65K elements, and our calculations put the object's size at ~10GB.
Problem:
The amount of memory the object consumes seems to be far in excess of our 10GB calculation.
BIGGEST CONCERN: We can't seem to use over 60% of the 32GB in the server.
What we've tried so far:
In machine.config/system.web (sf doesn't allow the tags, pardon the formatting):
processModel autoConfig="true" memoryLimit="80"
In web.config/system.web/caching/cache (sf doesn't allow the tags, pardon the formatting):
privateBytesLimit = "20000000000" (and 0, the default of course)
percentagePhysicalMemoryUsedLimit = "90"
Environment: Windows 2008R2 x64 32GB RAM IIS7
Nothing seems to allow us to exceed the 60% value. See screenshot of taskman.
Have you considered using a different caching strategy? The in built caching is not all that feature rich and you will struggle to get it to do much more (unless some IIS guru has some clever work about).
We spent a lot of time working on this and gave up. We actually use slimmer objects to store in the cache and get the fuller objects as needed.
When we have needed to contemplate this we investigated Memcached and Velocity but retreated from deploying them just yet. They are more feature rich though.
Also how are you storing the items in the cache through code? Are you putting them in there at application start or after the first request for each? The reason I ask is whether your cache keys are effective and that actually you are populating the cache over and over and not retrieving anything (this may be the case of just one object type). We managed to do this once by appending the time to a date specific cache key for example.
A little late but I'm having nearly the same issue. The problem with the
memoryLimit
setting on processModel is that it just seems to have no effect despite being documented as such.percentagePhysicalMemoryUsedLimit
similarly looks like it should do something but has no effect.privateBytesLimit="20000000000"
does work though. I went and debugged the process and found the CacheMemorySizePressure object and it successfully picked up the value and set it to _memoryLimit. I would double check that.Another option is setting a Private Memory Usage recycle threshold on the IIS app pool. That should also get picked up and override the default 60% limit.
A third option is using the new
MemoryCache
class and setting thePhysicalMemoryLimit
on it.