I'm writing a Java program that runs external executables using java.lang.ProcessBuilder
. This program should be able to watch running time and memory usage of a child process and terminate if it exceeds some predefined limits.
For time-based measurement it's pretty simple to achieve:
boolean inTime = process.waitFor(60, TimeUnit.SECONDS);
But I haven't found any methods for watching memory usage of a child process. Are there any ways to achieve this in Java?
Thanks in advance!