代码示例
package com.thb;
public class Test5 {
public static void main(String[] args) {
System.out.println("runtime version: " + Runtime.version());
// 获取与当前Java应用关联的runtime
Runtime runtime = Runtime.getRuntime();
System.out.println("current runtime: " + runtime);
// 获取Java虚拟机试图使用的最大内存
System.out.println("max memory(bytes): " + runtime.maxMemory());
// 获取Java虚拟机中的总内存
System.out.println("total memory(bytes): " + runtime.totalMemory());
}
}
运行输出: