16 lines
524 B
Java
16 lines
524 B
Java
package chapter5;
|
|
|
|
/**
|
|
* 获取当前虚拟机信息
|
|
*/
|
|
|
|
public class Example14 {
|
|
public static void main(String[] args) {
|
|
Runtime rt = Runtime.getRuntime();
|
|
System.out.println("处理器个数:" + rt.availableProcessors());
|
|
System.out.println("空闲内存:" + rt.freeMemory()/1024/1024 + "MB");
|
|
System.out.println("虚拟机中的内存总量:" + rt.totalMemory()/1024/1024 + "MB");
|
|
System.out.println("最大可用内存:" + rt.maxMemory()/1024/1024 + "MB");
|
|
}
|
|
}
|