Mah*_*asi 6 c# asp.net caching shared-hosting
根据这个问题,我想知道asp.net的system.web.caching.cache是否适合我,或者我应该使用数据库缓存?
所以,我需要知道system.Web.caching.cache正在使用多少内存?但由于我使用的是共享托管服务器,因此我无法使用任务管理器.有没有办法确定system.web.caching.cache使用一些代码使用了多少内存?
查看应用程序使用多少工作内存的一种快速方法是直接询问垃圾收集.
long bytes = GC.GetTotalMemory(false);
txtMemoryUsed.Text = bytes.ToString();
Run Code Online (Sandbox Code Playgroud)
并使用这个文字 <asp:Literal runat="server" ID="txtMemorysUsed" EnableViewState="false" />
但是您可以使用更多详细信息PerformanceCounter,例如,您可以获取此代码使用的池的虚拟内存量:
var oPerfCounter = new PerformanceCounter();
oPerfCounter.CategoryName = "Process";
oPerfCounter.CounterName = "Virtual Bytes";
oPerfCounter.InstanceName = "aspnet_wp";
txtMemorysUsed.Text = "Virtual Bytes: " + oPerfCounter.RawValue + " bytes";
Run Code Online (Sandbox Code Playgroud)
您可以使用所有这些参数来获取池的信息.
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
Run Code Online (Sandbox Code Playgroud)
例如,此参数获取cpu负载.
oPerfCounter.CategoryName = "Processor";
oPerfCounter.CounterName = "% Processor Time";
oPerfCounter.InstanceName = "_Total";
txtOutPut.Text = "Current CPU Usage: " + oPerfCounter.NextValue() + "%";
Run Code Online (Sandbox Code Playgroud)
参考:http://msdn.microsoft.com/en-us/library/ms972959.aspx
relative:从应用程序中监视ASP.NET应用程序内存
我在本地iis上测试并且工作.
| 归档时间: |
|
| 查看次数: |
5193 次 |
| 最近记录: |