Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support of WeakHashMap in dominator tree/retained set #23

Open
eclipsewebmaster opened this issue May 8, 2024 · 1 comment
Open

Comments

@eclipsewebmaster
Copy link

| --- | --- |
| Bugzilla Link | 470369 |
| Status | NEW |
| Importance | P3 normal |
| Reported | Jun 17, 2015 08:51 EDT |
| Modified | Feb 27, 2020 06:10 EDT |
| Version | 1.4 |
| Reporter | Vladimir Sitnikov |

Description

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.

@eclipsewebmaster
Copy link
Author

By Andrew Johnson on Feb 27, 2020 06:10

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant