I would like to improve the accuracy of the instance size in heap dumps. Currently the instance size in heap dump is reported as size of bytes, particular instance occupy in the heap dump file. Unfortunately due to compressed oops and paddings, this is different from the actual instance size in the heap. The fix is in src/share/vm/services/heapDumper.cpp and it looks simple:
diff -r 77d9c9da7188 src/share/vm/services/heapDumper.cpp
--- a/src/share/vm/services/heapDumper.cpp Mon Feb 06 23:36:58 2017 +0300
+++ b/src/share/vm/services/heapDumper.cpp Fri Feb 10 17:25:43 2017 +0100
@@ -922,7 +922,7 @@
writer->write_objectID(oop(NULL));
// instance size
- writer->write_u4(DumperSupport::instance_size(k));
+ writer->write_u4(HeapWordSize * ik->size_helper());
// size of constant pool - ignored by HAT 1.1
writer->write_u2(0);
DumperSupport::instance_size(k) calculates the size used in heap dump. DumperSupport::instance_size(k) just computes size of instance variables. So the size of java.lang.Object is zero. This is correctly used in dumping the particular instance.
The above change writes the actual instance size on the heap.
I don’t know how SA heap dump code looks like, but it will probably needs some adjustment too.
diff -r 77d9c9da7188 src/share/vm/services/heapDumper.cpp
--- a/src/share/vm/services/heapDumper.cpp Mon Feb 06 23:36:58 2017 +0300
+++ b/src/share/vm/services/heapDumper.cpp Fri Feb 10 17:25:43 2017 +0100
@@ -922,7 +922,7 @@
writer->write_objectID(oop(NULL));
// instance size
- writer->write_u4(DumperSupport::instance_size(k));
+ writer->write_u4(HeapWordSize * ik->size_helper());
// size of constant pool - ignored by HAT 1.1
writer->write_u2(0);
DumperSupport::instance_size(k) calculates the size used in heap dump. DumperSupport::instance_size(k) just computes size of instance variables. So the size of java.lang.Object is zero. This is correctly used in dumping the particular instance.
The above change writes the actual instance size on the heap.
I don’t know how SA heap dump code looks like, but it will probably needs some adjustment too.
- csr for
-
JDK-8326436 Improve the accuracy of the instance size in hprof heap dumps
-
- Closed
-
- relates to
-
JDK-8327709 Heap dump should provide information about actual instance size
-
- Open
-
-
JDK-8005604 HPROF should report the actual instance size
-
- Closed
-
- links to
-
Review openjdk/jdk/17855