Search code examples
javaheap-dumphprof

Java HPROF heap dump missing fields?


I am using Eclipse Memory Analyser to view an HPROF file. It displays different number of fields for different instances of the same class:

It seems the fields missing may never have been assigned to, but what was the value in those missing fields? Are they the "zero" value or the value from the field initialiser?

Edit:

JVM is Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

Edit 2:

It seems the missing fields are not "zero" (as confirmed through debugging), but probably never assigned to.

The below OQL query shows that Eclipse Memory Analyser actually knows about the real values in those fields, but just chose to not display them...


Solution

  • According to the HProf format documentation all fields of the object is stored in the dump, so MAT can know the value of all field of the object.


    OQL window

    For OQL all references are shown except those, that have null value.

    myWorkspaceMap is null for the object with 9 attributes


    dominator tree window For me MAT shows all attributes of the object in the dominator tree window.

    Attributes window

    Since the idea of the dominator tree is to have acyclic graph MAT determined that closeController own URLJarFile object and doesn't show this attribute in the main window.

    Also, it means, that if there are several strong references to the particular object and the owner of the object cannot be identified object will not be displayed in the dominator tree.

    Consider the name attribute in the URLJarFile:

    Name is not shown in the dominator tree

    If we choose "List object -> with incoming references" we can see, that this String is referenced from several objects:

    String is referenced from several objects