当前位置首页 > IIS知识

IIS中对应用程序池的配置

阅读次数:329 次  来源:admin  发布时间:

IIS6.0以上版本,查看IIS的属性

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

lt;IIsApplicationPool Location ="/LM/W3SVC/AppPools/DefaultAppPool"

AppPoolAutoStart="TRUE"

PeriodicRestartMemory="2000" //最大虚拟内存MB

PeriodicRestartPrivateMemory="1000" //最大占用内存MB

PeriodicRestartRequests="1000" //请求数

PeriodicRestartSchedule="07:50 //自动回收时间

12:00

20:00"

gt

lt;/IIsApplicationPool>

代码

rotected void StartStopRecycleApp(string method)

{

tring AppPoolName = "DefaultAppPool"

try

{

DirectoryEntry appPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools")

DirectoryEntry findPool = appPool.Children.Find(AppPoolName, "IIsApplicationPool")

findPool.Properties["PeriodicRestartMemory"].Value = (object)512000;//设置最大虚拟内存占有

findPool.Properties["PeriodicRestartPrivateMemory"].Value = (object)200000;//设置最大物理内存占有

tring[] strPamer = { "07:50", "12:00", "20:00" }

findPool.Properties["PeriodicRestartSchedule"].Value = (object)strPamer;//设置自动回收时间

findPool.CommitChanges()

appPool.CommitChanges()

appPool.Close()

}

catch (Exception ex)

{

MessageBox.Show(ex.Message)

//lbMsg.Text = string.Format("应用程序池{0}{2}失败:{1}", AppPoolName, ex.Message, method)

}

}

上一篇:网站SEO优化、IIS日志分析工具IISLogViewerV2.0发布
下一篇:Linux(Debian)上安装tomcat并注册服务开机自启动