在共享主机确定由asp.net缓存使用的内存 [英] Determine memory used by asp.net cache in shared hosting

查看:227
本文介绍了在共享主机确定由asp.net缓存使用的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据这个问题,我想知道,如果ASP。网的的System.Web.Caching.Cache是​​为我好,或者我应该使用数据库缓存?

According to this question, I want to know if asp.net's system.web.caching.cache is good for me, or I should use database caching?

所以,我需要知道多少内存正在使用的System.Web.Caching.Cache?
但自从我使用一个共享的主机服务器,我无法使用任务管理器。
有什么方法来确定使用一些code多少内存使用的System.Web.Caching.Cache?

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

推荐答案

一个快速的方法,看看您的应用程序的使用是有多少工作内存直接问垃圾回收。

One fast way to see how many working memory your application use is to direct ask the garbage collection.

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

和使用文字< ASP:文字=服务器ID =txtMemorysUsed的EnableViewState =假/>

但是你可以用得到更多的细节的PerformanceCounter ,例如,你可以得到多少虚拟内存受此code使用的池:

But you can get more details using the PerformanceCounter, for example you can get how many virtual memory the pools used by this code:

 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 this parameters to get information's 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

例如,此参数应用得到CPU的负载。

for example, this parametres get the cpu load.

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

引用:<一href=\"http://msdn.microsoft.com/en-us/library/ms972959.aspx\">http://msdn.microsoft.com/en-us/library/ms972959.aspx

相对的:<一href=\"http://stackoverflow.com/questions/586544/monitoring-asp-net-application-memory-from-within-the-application\">Monitoring从应用程序内的ASP.NET应用程序的内存

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

我测试的本地IIS和作品。

I have test that on local iis and works.

这篇关于在共享主机确定由asp.net缓存使用的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆