Summary
Change implementation of heap dumpers (VM and Serviceability Agent) to report actual instance size.
Problem
For all loaded classes HPROF heap dump file contains a HPROF_GC_CLASS_DUMP record. One of the field of the record is
u4 instance size (in bytes)
HPROF format was created to be independent of VM and value of the field was reported as sum of sizes of all instance fields.
HPROF tools for memory analysis require actual size of the instances in the heap (taking into account object header, padding, compressed oops, etc.). So the tools cannot rely on the reported value and instead 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.
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 clarify meaning of the field description should be updated in both copies:
u4 instance size (in bytes, including header, padding)
- csr of
-
JDK-8176520 Improve the accuracy of the instance size in hprof heap dumps
-
- Closed
-