当前位置:首页 > 网络编程 > 软件语言 > .NET > 查看主机的内存使用情况

查看主机的内存使用情况

点击次数:76 次 发布日期:2008-11-06 07:51:40 作者:源代码网
源代码网推荐
广告载入中

源代码网整理以下这个是我在国外的一个站点上看到的使用Asp.Net得到一些系统变量的程序,
大家可以看看,其实这个程序没有多大的用处,只是说明一下asp.Net 的强大功能而已。
<script language="C#" runat=server>
void Page_Load(Object sender, EventArgs ev)
{
ProcessInfo[] history = ProcessModelInfo.GetHistory(100);
for( int i=0; i<history.Length; i )
{
Response.Write("StartTime:" history[i].StartTime.ToString() "<BR>");
Response.Write("Age:" history[i].Age.ToString() "<BR>");
Response.Write("ProcessID:" history[i].ProcessID.ToString() "<BR>");
Response.Write("RequestCount:" history[i].RequestCount.ToString() "<BR>");
Response.Write("Status:" GetProcessStatus(history[i].Status ) "<BR>");
Response.Write("ShutdownReason:" GetShutdownReason(history[i].ShutdownReason) "<BR>");
Response.Write("PeakMemoryUsed:" history[i].PeakMemoryUsed.ToString() "<BR>");

源代码网整理以下}
}

源代码网整理以下public String GetProcessStatus( ProcessStatus ps )
{
String s = "Unknown";
if( ps == ProcessStatus.Alive )
s = "Alive";
else if( ps == ProcessStatus.ShuttingDown )
s = "Shutting Down";
else if( ps == ProcessStatus.ShutDown )
s = "Shutdown";
else if( ps == ProcessStatus.Terminated )
s = "Terminated";
return s;
}

软件开发网 www.mscto.com

源代码网整理以下public String GetShutdownReason( ProcessShutdownReason psr )
{
String s = "Unknown";
if( psr == ProcessShutdownReason.None )
s = "N/A";
else if( psr == ProcessShutdownReason.Unexpected )
s = "Unexpected";
else if( psr == ProcessShutdownReason.RequestsLimit )
s = "Requests Limit";
else if( psr == ProcessShutdownReason.RequestQueueLimit )
s = "Request Queue Limit";
else if( psr == ProcessShutdownReason.Timeout )
s = "Timeout";
else if( psr == ProcessShutdownReason.IdleTimeout )
s = "Idle Timeout";
else if( psr == ProcessShutdownReason.MemoryLimitExceeded )
s = "Memory Limit Exceeded";
return s;
}
</script>



源代码网推荐

源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华