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

Improve the accuracy of the instance size in hprof heap dumps

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • None
    • core-svc
    • None
    • generic
    • generic

      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.

            amenkov Alex Menkov
            thurka Tomáš Hůrka
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: