Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine total size of ASP.Net cache?

I'm using the ASP.net cache in a web project, and I'm writing a "status" page for it which shows the items in the cache, and as many statistics about the cache as I can find. Is there any way that I can get the total size (in bytes) of the cached data? The size of each item would be even better. I want to display this on a web page, so I don't think I can use a performance counter.

like image 979
Mike Comstock Avatar asked Dec 05 '08 15:12

Mike Comstock


People also ask

What is the default size of cache?

The default data cache size is an absolute value, and the minimum size for the cache size is 256 times the logical page size; for 2KB, the minimum is 512KB: for 16KB, the minimum is 4MB. The default value is 8MB.

What is maximum cache size?

The maximum theoretical cache size is 2 GB.

Where is ASP.NET cache stored?

The cached data is stored in server memory. Class Caching : Web pages or web services are compiled into a page class in the assembly, when run for the first time. Then the assembly is cached in the server.


1 Answers

I am looking at my performance monitor and under the ASP.NET Apps v2.0.50727 category I have the following cache related counters:

Cache % Machine Memory Limit Used

Cache % Process Memory Limit Used

There are also a lot of other cache related metrics under this category.

These should be able to get you the percentage, then if you can get the total allowed with Cache.EffectivePrivateBytesLimit or some other call you should be able to figure it out. I do not have personal experience with these counters so you will have to do some research and testing to verify.

Here is a quick start article on reading from performance counters: http://quickstart.developerfusion.co.uk/quickstart/howto/doc/PCRead.aspx

like image 187
Ryan Cook Avatar answered Oct 11 '22 22:10

Ryan Cook