Define memory used by asp.net cache in shared hosting

According to this question , I want to know if asp.net system.web.caching.cache suits me, or should I use database caching

So, I need to know how much memory is used by system.Web.caching.cache? But since I use a shared hosting server, I can not use the task manager. Is there a way to determine how much memory system.web.caching.cache is using with some code?

+6
source share
1 answer

One quick way to see how much working memory your application is using is to directly ask for garbage collection.

long bytes = GC.GetTotalMemory(false); txtMemoryUsed.Text = bytes.ToString(); 

and use this literal <asp:Literal runat="server" ID="txtMemorysUsed" EnableViewState="false" />

But you can get more detailed information using the PerformanceCounter , for example, you can get how much virtual memory the pools used by this code use:

  var oPerfCounter = new PerformanceCounter(); oPerfCounter.CategoryName = "Process"; oPerfCounter.CounterName = "Virtual Bytes"; oPerfCounter.InstanceName = "aspnet_wp"; txtMemorysUsed.Text = "Virtual Bytes: " + oPerfCounter.RawValue + " bytes"; 

You can use all of these parameters to get information for your pool.

 Processor(_Total)\% Processor Time Process(aspnet_wp)\% Processor Time Process(aspnet_wp)\Private Bytes Process(aspnet_wp)\Virtual Bytes Process(aspnet_wp)\Handle Count Microsoftยฎ .NET CLR Exceptions\# Exceps thrown / sec ASP.NET\Application Restarts ASP.NET\Requests Rejected ASP.NET\Worker Process Restarts (not applicable to IIS 6.0) Memory\Available Mbytes Web Service\Current Connections Web Service\ISAPI Extension Requests/sec 

for example, these parameters get the processor load.

 oPerfCounter.CategoryName = "Processor"; oPerfCounter.CounterName = "% Processor Time"; oPerfCounter.InstanceName = "_Total"; txtOutPut.Text = "Current CPU Usage: " + oPerfCounter.NextValue() + "%"; 

link: http://msdn.microsoft.com/en-us/library/ms972959.aspx

relative: Monitoring ASP.NET application memory from within the application

I have a local iis test and it works.

+6
source

All Articles