1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
/* Get Total Memory of Java Virtual Machine(JVM) Example This Java example shows how to get amount of total memory in the Java Virtual Machine(JVM) using totalMemory method of Java Runtime class. */ public class GetTotalMemory { public static void main(String args[]) { /* * get current Java Runtime using getRuntime() * method of Runtime class. */ Runtime runtime = Runtime.getRuntime(); /* * To determine amount of total memory available to current * Java Virtual Machine(JVM), use * * long totalMemory() * method of Runtime class. */ long totalMemory = runtime.totalMemory(); System.out.println(totalMemory + " bytes total in JVM"); } } /* Typical output would be 5177344 bytes total in JVM */ |
Add Comment