Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8327710

Heap dump should provide information about actual instance size

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • core-svc
    • None
    • behavioral
    • low
    • Hide
      HPROF format was designed to be expandable, so parsers can skip unknown records.
      Testing shown that 2 popular tools can parse .hprof files with new record types: VisualVM skipped unknown record; MAT has an option how to handle unknown tags - report error and stop parsing or produces warning and continue parsing.
      Show
      HPROF format was designed to be expandable, so parsers can skip unknown records. Testing shown that 2 popular tools can parse .hprof files with new record types: VisualVM skipped unknown record; MAT has an option how to handle unknown tags - report error and stop parsing or produces warning and continue parsing.
    • File or wire format
    • JDK

      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

      https://github.com/openjdk/jdk/blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java#L47

      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)
      + *

            amenkov Alex Menkov
            amenkov Alex Menkov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: