views:

269

answers:

1

Is there any way to find the number of bytes of memory that are currently in the HttpContext.Cache?

I've found where you can get the physical memory limit using EffectivePrivateBytesLimit or EffectivePercentagePhysicalMemoryLimit, but I'm having difficulties finding the current physical memory usage.

Any ideas ?

---UPDATE---

Afer some more searching and using the first response mentioning http://aspalliance.com/cachemanager/ i went to that page, at the bottom there is a link to http://www.codeproject.com/aspnet/exploresessionandcache.asp that describes a method to calculate the size of an object that i think will be good enough to use.

Basically it serializes each object in the cache then it then finds the length of the serialized stream. Summing these values results in some information i can use.

+1  A: 

There is a third-party "Cache Manager" which provides tools and stats for the HttpRuntime cache. You can get memory info there manually, or you can use Reflector to peek inside the assembly and see how it collects the stats, and do it yourself in your app

Rex M
this answer led me to finding what i needed.
John Boker