public static void main(String[] a){
Runtime runtime = Runtime.getRuntime();
long freeMemoery = runtime.freeMemory();
long totalMemory = runtime.totalMemory();
long usedMemory = totalMemory – freeMemoery;
long maxMemory = runtime.maxMemory();
long useableMemory = maxMemory – totalMemory + freeMemoery;
System.out.println("當前時間:"+runtime);
System.out.println("系統閑置空間:"+freeMemoery);
System.out.println("系統總空間:"+totalMemory);
System.out.println("系統被用的空間:"+usedMemory);
System.out.println("系統最大空間:"+maxMemory);
System.out.println("系統可用空間:"+useableMemory);
}
運行效果:
當前時間:www.aiwalls.com
系統閑置空間:4873672
系統總空間:5177344
系統被用的空間:303672
系統最大空間:66650112
系統可用空間:66346440
作者:張慧