Search code examples
c#memorycache

How do I find the size of MemoryCache, preferrably programatically?


I want to find the size of a MemoryCache.

MemoryCache _cache = MemoryCache.Default;
_cache.Add("key", "value");
FindSize(_cache);

I want to implement the FindSize() method.


Solution

  • I am afraid you can't find size of .NET object at runtime. See these answers for more details: