简体   繁体   中英

How to run an executable with time and memory usage limit?

I want to run an executable and limit its memory and time usage. Of course I want to know if it breached any of these things and if not I want the data how much was used. What could I use from the .NET to do this?

You could use a Thread to monitor the executable you run.

var process = Process.Start("Test.exe");

//  Monitor - Use this property to monitor the memory
process.MainModule.ModuleMemorySize

//  Monitor - Use this property to monitor the time
process.StartTime

//  Limit - You can use this property to limit the executable memory size,
//  but I wouldn't recommend it...
process.MaxWorkingSet

Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM