How do I run an executable file with limited time and memory usage?

I want to run an executable and limit its memory and time usage. Of course I want to know if she violated any of these things, and if I don't want data, how much has been used. What can I use from .NET for this?

+2


source to share


1 answer


You can use Thread to track the executable you are executing.

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.

+5


source







All Articles