I'm running a certain Java program, with its -Xmx
higher than -Xms
, i.e. its heap can grow. The heap size at execution end is (IIRC) not the maximum used during the run.
Get current heap size:
public static long getHeapSize(){
int mb = 1024*1024;
//Getting the runtime reference from system
Runtime runtime = Runtime.getRuntime();
return ((runtime.totalMemory() - runtime.freeMemory()) / mb);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With