public static void main(String[] args) { // 得到JVM中的空閑內存量(單位是m) System.out.println(Runtime.getRuntime().freeMemory()/1024/1024); // 的JVM內存總量(單位是m) System.out.println(Runtime.getRuntime().totalMemory()/1024/1024); // JVM試圖使用額最大內存量(單位是m) System.out.println(Runtime.getRuntime().maxMemory()/1024/1024); // 可用處理器的數目 System.out.println(Runtime.getRuntime().availableProcessors()); }
可通過接口去查詢