Reputation: 119
I have a question for MemoryCache and PhysicalMemoryLimit.
For example:
I set PhysicalMemoryLimit = 2
I have many:
List<MyObject> myObject = new List<MyObject>();
myobject can have count more 100000
I set myObject to cache with unique key.
At some point in time cache will be full and
"If the cache size exceeds the specified limit, the memory cache implementation removes cache entries."
But before cache was full, one of object was take and using in foreach a long time . When the memory cache implementation removes cache entries, what will be with this object ?
Sorry for my English.
Upvotes: 0
Views: 686
Reputation: 1083
In-memory cache keeps the reference of cached object associated with the specified key so that it can be used when required and also will not be collected by GC.
When cache size exceeds the specified limit, removing cache entries mean cache no more holds reference to that object so that it can then be disposed in next garbage collection. However if that object is being used in user's logic, like in your case in a foreach loop. it will not remain in cache but will be available in users code till referred.
Upvotes: 1