Community
Participate
Working Groups
Currently MAT does not recognize the fact that "WeakHashMap" is not the only dominator of the values that are stored in the map. In other words, it might realize that if all strong reference to the key are gone, the value would go away. It makes sense to support that in calculation of dominator tree. Additional support might be needed for some well-known weak/soft collections.
The Java Basics > References > Weak Reference Statistics query can help as one of the result tables is 'Only Weakly Retained'. You could get a list of all the objects which were not 'Only Weakly Retained' by: adding a histogram of all the objects to the compare basket, add the 'Only Weakly Retained' objects to the compare basket, select both, do a 'Compare Tables with all set operations', select all the objects and do 'Table 1 without table 2' > 'Java Basics' > 'Show As Histogram'. You could then have a new heap dump with just those objects: select all the objects in that Histogram, 'Export Snapshot' then reopen the resulting dump. There are still a couple of problems: 1. The objects in the new heap dump will have some dangling references to the weakly retained objects. These won't show on the outbound/inbound expansion, but will show on the object inspector and might break some queries. 2. The compare tables query can loss table rows if there are two identically named rows in the source e.g. if in a histogram a class is loaded twice by two class loaders. This could result in some missing objects in the compare table and resulting outputs.
This issue has been migrated to https://github.com/eclipse-mat/org.eclipse.mat/issues/23.