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?
相关问题
- slurm: use a control node also for computing
- What uses more memory in c++? An 2 ints or 2 funct
- Memory for python.exe on Windows 7 python 32 - Num
- No SynchronizationContext when calling Await in a
- C# CPU and GPU Temp
相关文章
- quartz.net 如何实现动态job ,appdomain 域卸载问题
- Why are memory addresses incremented by 4 in MIPS?
- How to get CPU serial under Linux without root per
- Is it possible to run 16 bit code in an operating
- Is my heap fragmented
- Is there a way to avoid this memory error?
- How do I store a Python object in memory for use b
- Why am I not getting a stack overflow?
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 theAppDomain.MonitoringSurvivedMemorySize
property ifAppDomain.MonitoringIsEnabled
is set totrue
. You can spin up a watchdog thread to monitor allocations.Even the Windows performance monitors don't allow you to view CPU usage by AppDomain - since AppDomains are logical constructs of the CLR and are not known by the OS the only CPU usage tracking is at process level - I would be shocked if there is a way to limit something that you can't even monitor.
What exactly is your reason for wanting to do this? Why wouldn't you want your application to use all resources available to it? If it is simply a case of making sure there is enough overhead for other processes to run can't you just set the priority of the threads very low and let the Windows scheduler figure it out?
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/
The only way I know to do something like this is using HyperV (or similar products) and partitioning your applications into different virtual machines. But that's not exactly a cheap or simple solution.