アプリケーションが使用している作業メモリーの数をすばやく確認する方法の1つは、ガベージコレクションに直接問い合わせることです。
long bytes = GC.GetTotalMemory(false);
txtMemoryUsed.Text = bytes.ToString();
このリテラルを使用します<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";
このすべてのパラメーターを使用して、プールの情報を取得できます。
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負荷を取得します。
oPerfCounter.CategoryName = "Processor";
oPerfCounter.CounterName = "% Processor Time";
oPerfCounter.InstanceName = "_Total";
txtOutPut.Text = "Current CPU Usage: " + oPerfCounter.NextValue() + "%";
参照: http: //msdn.microsoft.com/en-us/library/ms972959.aspx
相対:アプリケーション内からASP.NETアプリケーションメモリを監視する
ローカルのIISでテストして動作します。