Summary
Update HPROF file format and JDK heap dumper implementations (VM and Serviceability Agent) to report actual instance size of the objects in the heap.
Problem
HPROF tools need to know actual size objects occupy in the heap for memory analysis. Currently HPROF format has HPROF_GC_CLASS_DUMP records to describe classes and the record contains VM-independent value for instance size which is calculated as sum of sizes of all instance fields. This value does not take into account object header, padding, compressed oops, etc., so HPROF tools try to calculate actual instance size from class information (class fields/types, class hierarchy), using knowledge about VM internals. This is prone to errors in estimations.
Solution
VM and SA knows actual instance size and can report it in HPROF heap dump. HPROF format supports addition of new record types. Each record contains information about record size, parsers can (and should) skip the records they don't support. The solution is to add new records to HPROF heap dump to report actual size of the class instances.
Specification
There is no official HPROF format spec, the only description of the format are comments in the JDK source code (2 identical copies in VM heap dumper C++ code and in SA Java code):
https://github.com/openjdk/jdk/blob/master/src/hotspot/share/services/heapDumper.cpp#L71
To add new record type both copies should be updated:
+ * HPROF_CLASS_INST_SIZE class instance size
+ *
+ * id class object ID
+ * u4 instance size (in bytes, including header, padding)
+ *
- csr of
-
JDK-8327709 Heap dump should provide information about actual instance size
-
- Open
-