--- old/src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java 2020-08-05 21:22:54.053590318 +0800 +++ new/src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java 2020-08-05 21:22:53.753590307 +0800 @@ -169,28 +169,41 @@ UnsupportedEncodingException { String liveopt = "-all"; String filename = null; + String parallel = null; String subopts[] = options.split(","); + boolean set_all = false; + boolean set_live = false; for (int i = 0; i < subopts.length; i++) { String subopt = subopts[i]; if (subopt.equals("") || subopt.equals("all")) { - // pass + set_all = true; + liveopt = "-all"; } else if (subopt.equals("live")) { + // Add '-' for compatibility. + set_live = true; liveopt = "-live"; } else if (subopt.startsWith("file=")) { filename = parseFileName(subopt); if (filename == null) { usage(1); // invalid options or no filename } + } else if (subopt.startsWith("parallel=")) { + parallel = subopt.substring("parallel=".length()); + if (parallel == null) { + usage(1); + } } else { usage(1); } } + if (set_live && set_all) { + usage(1); + } System.out.flush(); - // inspectHeap is not the same as jcmd GC.class_histogram - executeCommandForPid(pid, "inspectheap", liveopt, filename); + executeCommandForPid(pid, "inspectheap", liveopt, filename, parallel); } private static void dump(String pid, String options) @@ -287,6 +300,10 @@ System.err.println(" live count only live objects"); System.err.println(" all count all objects in the heap (default if one of \"live\" or \"all\" is not specified)"); System.err.println(" file= dump data to "); + System.err.println(" parallel= parallel threads number for heap iteration:"); + System.err.println(" parallel=0 default behavior, use predefined number of threads"); + System.err.println(" parallel=1 disable parallel heap iteration"); + System.err.println(" parallel= use N threads for parallel heap iteration"); System.err.println(""); System.err.println(" Example: jmap -histo:live,file=/tmp/histo.data "); System.exit(exit);