开发者

HttpContext.Cache Physical Memory Usage

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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜