如何在java中获取进程的总堆内存和已用堆内存?
strong textint mb = 1024 * 1024;
Runtime instance = Runtime.getRuntime();
System.out.println("***** Heap utilization statistics [MB] *****\n");
System.out.println("Total Memory: " + instance.totalMemory() / mb);
String str = "9280";
Process pr = instance.exec("cmd /c jmap -heap "+str);
这是基于 Windows 的,我需要它用于跨平台。