package demo.api;
import java.io.IOException;
class RuntimeTest {
public static void main(String[] args) throws IOException, InterruptedException {
Runtime runtime = Runtime.getRuntime();
System.out.println("处理器个数:" + runtime.availableProcessors());
System.out.println("Java虚拟机中的空闲内存量(单位:字节):" + runtime.freeMemory() / 1024 / 1024 + "M");
System.out.println("Java 虚拟机试图使用的最大内存量:" + runtime.maxMemory() / 1024 / 1024 + "M");
System.out.println("返回 Java 虚拟机中的内存总量:" + runtime.totalMemory() / 1024 / 1024 + "M");
System.out.println("jvm已使用内存:" + (runtime.totalMemory() - runtime.freeMemory()) / 1024 / 1024 + "M");
}
}