- long freeMemory()
Returns the amount of free memory in the Java Virtual Machine. - long maxMemory()
Returns the maximum amount of memory that the Java virtual machine will attempt to use. - long totalMemory()
Returns the total amount of memory in the Java virtual machine.
public class testMem {
public static void main(String[] args){
System.out.println("helloraspberrypi.blogspot.com");
//the total amount of memory in the Java virtual machine
long totalMem = Runtime.getRuntime().totalMemory();
//the maximum amount of memory that the Java virtual machine will attempt to use
long maxMem = Runtime.getRuntime().maxMemory();
//the amount of free memory in the Java Virtual Machine
long freeMem = Runtime.getRuntime().freeMemory();
System.out.println("totalMemory() - " + totalMem);
System.out.println("maxMemory() - " + maxMem);
System.out.println("freeMemory() - " + freeMem);
}
}
We can run java with -Xms and -Xmx options to set Java heap size:
Run on Raspberry Pi:
No comments:
Post a Comment