简体   繁体   中英

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...

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.

具有9个属性的对象的myWorkspaceMap为null


dominator tree window For me MAT shows all attributes of the object in the dominator tree 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:

名称未显示在统治者树中

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

从多个对象引用了字符串

The problem is the view I was looking at is only supposed to list object refereces , so null fields or primitive values are not shown.

The solution is to add the "Inspector" view or switch to the dedicated "Memory Analysis" perspective, which will show the actual fields for each instance selected, as shown is @Taky's screenshots.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM