Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CPU and Memory Cap for an AppDomain

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?

like image 945
Hemanshu Bhojak Avatar asked Sep 15 '10 12:09

Hemanshu Bhojak


2 Answers

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.

like image 193
Jeroen Mostert Avatar answered Sep 18 '22 23:09

Jeroen Mostert


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/

like image 40
James Poulose Avatar answered Sep 20 '22 23:09

James Poulose