Our product is based on a in-memory object data set that is held in a MemoryCache object.
I would like to know how much memory is consumed by the data stored in the cache.
Since we might have multiple instances of the product running on the same machine (each within it's own Application domain), it would be important to see right away who consumes what...
The class has properties like: CacheMemoryLimit and PhysicalMemoryLimit, but no property that would let me know how much memory is consumed ?
Thanks in advance!
The best way to inspect memory is to use WinDbg + SOS/Psscor. Especially, this article from Tess will give you a script to automate MemoryCache inspection.
However, if you are not familiar with these tools and .net internals structures, it's common to spend a few hours to setup the environment and understand how it works.
Another method is to use Debug Tools 2.0, available here. You just have to create a memory dump of your worker process (Task Manager/Right Clic/Create dump File) and selection Memory analysis. The report contains a section Size of Web Caches in the process.
If you want to do Live Memory inspection, you could use ClrMD from .net team. An introduction is available here.