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.
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.
Looks like there is a solution for this requirement in .NET 4.0
http://www.c-sharpcorner.com/UploadFile/hasansheik/diagnostic-and-performance-monitoring-in-dotnet-4-0/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With