The MemoryCache
class in .net
is supposed to evict items whenever the amount of memory it uses exceeds some limit.
How does it actually determine how much memory its items are using?
MemoryCache
has an internal CacheMemoryMonitor
that periodically asks its references how big they are. It utilizes an internal type in mscorlib called SizedReference
which is a reference that also keeps track of how much memory (approximately) its target uses.
It also collects various statistics from the GC to help ascertain if memory pressure should cause it to start an eviction process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With