AppDomain 的 CPU 和内存上限 [英] CPU and Memory Cap for an AppDomain

查看:33
本文介绍了AppDomain 的 CPU 和内存上限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在应用程序域中托管一个 exe 并为其分配 CPU 和内存上限,以便它使用的处理能力不会超过分配的处理能力.这可以做吗?如何做?

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?

推荐答案

据我所知,不能直接设置最大内存上限.

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

但是,从 .NET 4 开始,当前由 AppDomain 分配的内存在 AppDomain.MonitoringSurvivedMemorySize 属性如果 AppDomain.MonitoringIsEnabled 设置为.您可以启动一个看门狗线程来监控分配.

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.

这篇关于AppDomain 的 CPU 和内存上限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆