【问题标题】:How to limit memory usage .net core web site in kestrel hosting in IIS如何在 IIS 中的红隼托管中限制内存使用 .net 核心网站
【发布时间】:2017-02-06 09:01:01
【问题描述】:

我正在使用 IIS 托管 .net 核心网站。我特意写了一种消耗所有服务器内存的方式。我该如何设置,如果 dotnet 进程超过某个内存限制,它将自行回收。

我在红隼中找不到任何这样做的选项。 IIS 也不会产生任何影响,因为它只是一个反向代理

【问题讨论】:

    标签: iis memory .net-core kestrel-http-server


    【解决方案1】:

    我能想到的唯一方法是在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 |外空}

    【讨论】:

      猜你喜欢
      • 2022-01-11
      • 1970-01-01
      • 2018-02-22
      • 2021-11-15
      • 2015-08-16
      • 1970-01-01
      • 2021-05-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多