CPU and Memory Cap for an AppDomain

后端 未结 4 446
逝去的感伤
逝去的感伤 2020-12-18 21:13

I want to host an exe in an appdomain and assign a CPU and Memory cap to it so that it does not use more than the assigned processing power. Is this possible to do and how?<

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-18 22:04

    You can't cap the maximum memory directly, as far as I know.

    However, from .NET 4 on, the memory currently allocated by an AppDomain is available in the AppDomain.MonitoringSurvivedMemorySize property if AppDomain.MonitoringIsEnabled is set to true. You can spin up a watchdog thread to monitor allocations.

提交回复
热议问题