Skip to content

Commit 0ee8cac

Browse files
committed
8299672: Enhance HeapDump JFR event
Reviewed-by: rschmelter, clanger
1 parent d716ec5 commit 0ee8cac

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/hotspot/share/jfr/metadata/metadata.xml

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

33
<!--
4-
Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
55
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
66
77
This code is free software; you can redistribute it and/or modify it
@@ -1144,11 +1144,14 @@
11441144
<Field type="ulong" contentType="bytes" name="size" label="Size Written" />
11451145
</Event>
11461146

1147-
<Event name="HeapDump" category="Java Virtual Machine, Diagnostics" label="Heap Dump" stackTrace="true" thread="true">
1148-
<Field type="string" name="destination" label="Destination" />
1147+
<Event name="HeapDump" category="Java Virtual Machine, Diagnostics" label="Heap Dump" description="Information about a successfully written Java heap dump"
1148+
stackTrace="true" thread="true">
1149+
<Field type="string" name="destination" label="Destination Path of the Dump" />
11491150
<Field type="long" name="size" label="Size" />
11501151
<Field type="boolean" name="gcBeforeDump" label="GC Before Dump" />
1151-
<Field type="boolean" name="onOutOfMemoryError" label="On Out of Memory Error" />
1152+
<Field type="boolean" name="onOutOfMemoryError" label="Heap Dump on Out of Memory Error" />
1153+
<Field type="boolean" name="overwrite" label="Overwrite" description="Heap dump overwrites previous file location if it exists" />
1154+
<Field type="int" name="compression" label="Compression Level" description="Compression level of the dump, if larger than 0 we use gzip compression with this level" />
11521155
</Event>
11531156

11541157
<Event name="GCLocker" category="Java Virtual Machine, GC, Detailed" label="GC Locker" startTime="true" thread="true" stackTrace="true">

src/hotspot/share/services/heapDumper.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -2425,7 +2425,11 @@ int HeapDumper::dump(const char* path, outputStream* out, int compression, bool
24252425
event.set_gcBeforeDump(_gc_before_heap_dump);
24262426
event.set_size(writer.bytes_written());
24272427
event.set_onOutOfMemoryError(_oome);
2428+
event.set_overwrite(overwrite);
2429+
event.set_compression(compression);
24282430
event.commit();
2431+
} else {
2432+
log_debug(cds, heap)("Error %s while dumping heap", error());
24292433
}
24302434

24312435
// print message in interactive case

test/jdk/jdk/jfr/event/diagnostics/TestHeapDump.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -65,6 +65,8 @@ public static void main(String[] args) throws Exception {
6565
Events.assertField(e, "gcBeforeDump").equal(true);
6666
Events.assertField(e, "onOutOfMemoryError").equal(false);
6767
Events.assertField(e, "size").equal(Files.size(path));
68+
Events.assertField(e, "compression").below(1);
69+
Events.assertField(e, "overwrite").equal(false);
6870
System.out.println(e);
6971
}
7072
}

0 commit comments

Comments
 (0)