没有抛出异常,但我仍然无法在我的桌面文件夹中找到dump.bin文件,我的路径错了吗?
public static void dumpHeap()
{
System.out.println("dumping data");
String name = ManagementFactory.getRuntimeMXBean().getName();
System.out.println("name :" + name);
String pid = name.substring(0, name.indexOf("@"));
System.out.println("pid :" + pid);
String[] cmd = { "jmap", "-dump:file=/Users/MyName/Desktop/dump.bin", pid };
Process p;
try {
p = Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
e.printStackTrace();
}
答案 0 :(得分:0)
我必须使用-F
强制它public static void dumpHeap()
{
System.out.println("dumping data");
String name = ManagementFactory.getRuntimeMXBean().getName();
System.out.println("name :" + name);
String pid = name.substring(0, name.indexOf("@"));
System.out.println("pid :" + pid);
String[] cmd = { "jmap", "-dump:file=/Users/MyName/Desktop/dump.bin", "-F", pid };
Process p;
try {
p = Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
e.printStackTrace();
}