我正在处理一个存在内存泄漏的遗留.NET应用程序。 为了尝试减轻内存崩溃的情况,我将应用程序池内存限制设置在500KB到500000KB之间(500MB),但是应用程序池似乎并不尊重设置,因为我可以login和查看物理它的内存(5GB及以上无论什么价值)。 这个应用程序正在查杀服务器,我似乎无法确定如何调整应用程序池。 你推荐什么设置来确保这个应用程序池不超过500MB的内存。
这里是一个例子,应用程序池是使用3.5GB的


所以,服务器又崩溃了,这是为什么:

具有低内存限制的同一个应用程序池,1000个回收请求,每两三分钟就会导致一次回收事件,但有时候只会逃跑。
我也对任何可以监控这个过程的工具(每30秒作为一个任务或服务运行)开放,并且可以在超过某个限制时杀死它。
我发现这篇文章,因为我正在努力回答类似的限制不受限制。 请参阅IIS WebLimits不被尊重 。
不过,我可以刺你的问题。 尝试下面的C#代码。 你可以用PowerShell做同样的事情。 您需要使用pipe理员权限运行它。
static void Main(string[] args) { string appPoolName = args[0]; int memLimitMegs = Int32.Parse(args[1]); var regex = new System.Text.RegularExpressions.Regex(".*w3wp.exe \\-ap \"(.*?)\".*"); //find w3wp procs.... foreach (var p in Process.GetProcessesByName("w3wp")) { string thisAppPoolName = null; try { //Have to use WMI objects to get the command line params... using (var searcher = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + p.Id)) { StringBuilder commandLine = new StringBuilder(); foreach (ManagementObject @object in searcher.Get()) { commandLine.Append(@object["CommandLine"] + " "); } //extract the app pool name from those. var r = regex.Match(commandLine.ToString()); if (r.Success) { thisAppPoolName = r.Groups[1].Value; } if (thisAppPoolName == appPoolName) { //Found the one we're looking for. if (p.PrivateMemorySize64 > memLimitMegs*1024*1024) { //it exceeds limit, recycle it using appcmd. Process.Start(Path.Combine(System.Environment.SystemDirectory , "inetsrv", "appcmd.exe"), "recycle apppool /apppool.name:" + appPoolName); Console.WriteLine("Recycled:" + appPoolName); } } } } catch (Win32Exception ex) { Console.WriteLine(ex.ToString()); } } }