Is it possible to get the current RAM usage of a java Process that is created with Runtime.getRuntime().exec(...);. I am creating a minecraft server instance and I need to monitor the resource usage of the server.
Here is exactly how I am creating the process.
private void runStartCommand(){
try {
lines = new ArrayList<>();
String cmd = "cmd.exe /c cd " + service.getLocation() + "& java -jar -Xmx2G -Xms2G "+service.getLocation()+"spigot-1.9.2.jar";
process = Runtime.getRuntime().exec(cmd);
input = new BufferedReader(new InputStreamReader(process.getInputStream()),8*1024);
writer = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
running = true;
} catch (IOException e) {
e.printStackTrace();
}
}
cmd.exeso he is under Windows