Summary
Add the options "file=" to JMap -histo to improve JMap's ability
Problem
Currently the "JMap -histo" tool doesn't support to dump result to a file directly.
Solution
Add "file=" option that let JMap -histo to dump directly to file. Please be aware that this is subset of enhancement of JMap More detail please refer to https://bugs.openjdk.java.net/browse/JDK-8214535
Specification
Diff:
--- old/src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java
+++ new/src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java
@@ -246,21 +266,27 @@
System.err.println(" to connect to running process and print class loader statistics");
System.err.println(" jmap -finalizerinfo <pid>");
System.err.println(" to connect to running process and print information on objects awaiting finalization");
- System.err.println(" jmap -histo[:live] <pid>");
+ System.err.println(" jmap -histo[:[<histo-options>]] <pid>");
System.err.println(" to connect to running process and print histogram of java object heap");
- System.err.println(" if the \"live\" suboption is specified, only count live objects");
System.err.println(" jmap -dump:<dump-options> <pid>");
System.err.println(" to connect to running process and dump java heap");
System.err.println(" jmap -? -h --help");
System.err.println(" to print this help message");
System.err.println("");
System.err.println(" dump-options:");
- System.err.println(" live dump only live objects; if not specified,");
- System.err.println(" all objects in the heap are dumped.");
+ System.err.println(" live dump only live objects");
+ System.err.println(" all dump all objects in the heap (default if one of \"live\" or \"all\" is not specified);
System.err.println(" format=b binary format");
System.err.println(" file=<file> dump heap to <file>");
System.err.println("");
System.err.println(" Example: jmap -dump:live,format=b,file=heap.bin <pid>");
+ System.err.println("");
+ System.err.println(" histo-options:");
+ 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=<file> dump data to <file>");
+ System.err.println("");
+ System.err.println(" Example: jmap -histo:live,file=/tmp/histo.data <pid>");
System.exit(exit);
}
}
Updated specification:
jmap -clstats <pid>
to connect to running process and print class loader statistics
jmap -finalizerinfo <pid>
to connect to running process and print information on objects awaiting finalization
jmap -histo[:<histo-options>] <pid>
to connect to running process and print histogram of java object heap
jmap -dump:<dump-options> <pid>
to connect to running process and dump java heap
jmap -? -h --help
to print this help message
dump-options:
live dump only live objects; if not specified, use "all".
all all objects in the heap are dumped.
format=b binary format
file=<file> dump heap to <file>
Example: jmap -dump:live,format=b,file=heap.bin <pid>
histo-options:
live only count live objects; if not specified, use "all".
all count all objects in the heap
file=<file> dump data to <file>
Example: jmap -histo:live,file=/tmp/histo.data <pid>
- csr of
-
JDK-8215622 Add dump to file support for jmap –histo
-
- Resolved
-