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

查看:145
本文介绍了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%28v = vs.110%29.aspx"rel =" nofollow noreferrer> AppDomain.MonitoringIsEnabled 设置为true.您可以启动看门狗线程来监视分配.

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天全站免登陆