< prev index next >
src/hotspot/share/services/diagnosticCommand.cpp
Print this page
rev 58893 : 8237354: Add option to jcmd to write a gzipped heap dump
Reviewed-by:
*** 502,522 ****
#if INCLUDE_SERVICES // Heap dumping/inspection supported
HeapDumpDCmd::HeapDumpDCmd(outputStream* output, bool heap) :
DCmdWithParser(output, heap),
_filename("filename","Name of the dump file", "STRING",true),
_all("-all", "Dump all objects, including unreachable objects",
! "BOOLEAN", false, "false") {
_dcmdparser.add_dcmd_option(&_all);
_dcmdparser.add_dcmd_argument(&_filename);
}
void HeapDumpDCmd::execute(DCmdSource source, TRAPS) {
// Request a full GC before heap dump if _all is false
// This helps reduces the amount of unreachable objects in the dump
// and makes it easier to browse.
HeapDumper dumper(!_all.value() /* request GC if _all is false*/);
! dumper.dump(_filename.value(), output());
}
int HeapDumpDCmd::num_arguments() {
ResourceMark rm;
HeapDumpDCmd* dcmd = new HeapDumpDCmd(NULL, false);
--- 502,538 ----
#if INCLUDE_SERVICES // Heap dumping/inspection supported
HeapDumpDCmd::HeapDumpDCmd(outputStream* output, bool heap) :
DCmdWithParser(output, heap),
_filename("filename","Name of the dump file", "STRING",true),
_all("-all", "Dump all objects, including unreachable objects",
! "BOOLEAN", false, "false"),
! _gzip("-gz", "Write in gzipped format.", "BOOLEAN", false, "false"),
! _gzip_level("-gz-level", "The compression level from 0 (store) to 9 (best) when writing in gzipped format.",
! "INT", false, "1") {
_dcmdparser.add_dcmd_option(&_all);
_dcmdparser.add_dcmd_argument(&_filename);
+ _dcmdparser.add_dcmd_option(&_gzip);
+ _dcmdparser.add_dcmd_option(&_gzip_level);
}
void HeapDumpDCmd::execute(DCmdSource source, TRAPS) {
+ jlong level = -1; // -1 means no compression.
+
+ if (_gzip.value()) {
+ level = _gzip_level.value();
+
+ if (level < 0 || level > 9) {
+ output()->print_cr("Compression level out of range (0-9): " JLONG_FORMAT, level);
+ return;
+ }
+ }
+
// Request a full GC before heap dump if _all is false
// This helps reduces the amount of unreachable objects in the dump
// and makes it easier to browse.
HeapDumper dumper(!_all.value() /* request GC if _all is false*/);
! dumper.dump(_filename.value(), output(), (int) level);
}
int HeapDumpDCmd::num_arguments() {
ResourceMark rm;
HeapDumpDCmd* dcmd = new HeapDumpDCmd(NULL, false);
< prev index next >