【发布时间】:2017-02-06 09:01:01
【问题描述】:
我正在使用 IIS 托管 .net 核心网站。我特意写了一种消耗所有服务器内存的方式。我该如何设置,如果 dotnet 进程超过某个内存限制,它将自行回收。
我在红隼中找不到任何这样做的选项。 IIS 也不会产生任何影响,因为它只是一个反向代理
【问题讨论】:
标签: iis memory .net-core kestrel-http-server
我正在使用 IIS 托管 .net 核心网站。我特意写了一种消耗所有服务器内存的方式。我该如何设置,如果 dotnet 进程超过某个内存限制,它将自行回收。
我在红隼中找不到任何这样做的选项。 IIS 也不会产生任何影响,因为它只是一个反向代理
【问题讨论】:
标签: iis memory .net-core kestrel-http-server
我能想到的唯一方法是在WMI事件订阅中使用powershell脚本超时运行来监控和杀死进程
$processToMonitor = 'Thunderbird.exe' $阈值 = 100MB
Register-WmiEvent -Query "SELECT * FROM __InstanceModificationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_Process' AND TargetInstance.Name='$processToMonitor' AND TargetInstance.WorkingSetSize > $threshold" -Action { Get-Process -PID $event.SourceEventArgs .NewEvent.TargetInstance.ProcessId | Stop-Process -Force -ErrorAction SilentlyContinue |外空}
【讨论】: