-
Notifications
You must be signed in to change notification settings - Fork 3
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
Detect cycles in WeakHashMaps #5
Comments
By Andrew Johnson on Dec 03, 2009 15:33 I've got a prototype for solving this, based on weak_reference_query. Current steps: Next steps: This should should show leaks where in a WeakHashMap the value retains the key. Is there a method to get a strongly retained set? Is there a method to get the reachable set? This could be used to show potential rather than actual problems. |
By Andrew Johnson on Dec 10, 2009 05:00 I've committed some changes. There is now a general references query on selected objects. The component report now produces a report for SoftReferences and WeakReferences. The GC paths view doesn't come out properly because of 297052. Once the report is working well then we could do a more general query for leaking references and if there is a problem then include it in the leak suspects. How could this reference query and the component report be improved? |
By Krum Tsvetkov on Dec 16, 2009 03:38 I tested this with the last heap dump we showed at JavaOne this year. I ran the "reference statistics" query and the "component report" on all instances of java.util.WeakHashMap$Entry The results were very good I think. Both showed me the leaking classloaders we demonstrated, but also some additional problems which I haven't noticed before :) However, I think it will be hard for non-experts to use it:
What could make it a bit simpler is to have a dedicated query for this, sth. like "Find possible leaks in WeakHashMaps" (with blinking pink title :)) What do you think about the suggestions? |
By Krum Tsvetkov on Apr 23, 2010 04:07 We can't finish this one for the 1.0 release. I move it to 1.1 and remove the "blocks" attribute for the central graduation ticket. |
By Andrew Johnson on Feb 25, 2020 05:57 Created attachment 281924 pathstoreferent.png |
By Andrew Johnson on Feb 25, 2020 05:58 Created attachment 281925 commonpaths.png |
By Andrew Johnson on Feb 25, 2020 06:39 I have written a query that processes references one by one looking for referents which also have a strong path The component report can then call this query and generate HTML. I needed a minor modification to displaying trees to make sure the selection was honoured. |
Feb 25, 2020 06:48 New Gerrit change created: https://git.eclipse.org/r/158295 |
Feb 25, 2020 06:50 Gerrit change https://git.eclipse.org/r/158295 was merged to [master]. |
Feb 25, 2020 08:08 New Gerrit change created: https://git.eclipse.org/r/158301 |
Feb 25, 2020 08:09 Gerrit change https://git.eclipse.org/r/158301 was merged to [master]. |
By Andrew Johnson on Feb 25, 2020 08:25 I have a slightly unusual result with the test dump sun_jdk6_32.hprof reference_leak java.lang.ref.WeakReference -include_subclasses -maxpaths 10 -factor 0.0 This includes java.util.WeakHashMap$Entry @ 0x22eb76c0 -> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor$ListenerWrapper That path goes through another WeakReference. The query considers each reference in turn, ignoring the others (presuming them as strong), The component report does not flag it as a problem because across all the weak references there are no referents strongly retained via weak references. Perhaps this needs some help or documentation to let the user decide what is happening. Class Name | Shallow Heap | Retained Heap
|
Feb 25, 2020 16:12 New Gerrit change created: https://git.eclipse.org/r/158350 |
Feb 25, 2020 16:12 Gerrit change https://git.eclipse.org/r/158350 was merged to [master]. |
| --- | --- |
| Bugzilla Link | 296826 |
| Status | ASSIGNED |
| Importance | P3 enhancement |
| Reported | Dec 03, 2009 11:22 EDT |
| Modified | Feb 25, 2020 16:12 EDT |
| Version | 1.1 |
| Depends on | 297052 |
| See also | Gerrit change https://git.eclipse.org/r/158295, Git commit e6465836, Gerrit change https://git.eclipse.org/r/158301, Git commit a78a213e, Gerrit change https://git.eclipse.org/r/158350, Git commit d8e9667e |
| Reporter | Andrew Johnson |
Description
WeakHashMaps have entries with a key held by the reference of a WeakReference and a value. If the key is no longer accessible and is only weakly reachable then it can be cleared and then the hash map entry can be cleared.
A user error is to have a path from the value to the key. The key is then strongly referenced via the WeakReference value field and won't be cleared when otherwise inaccessible.
We should detect this problem.
The text was updated successfully, but these errors were encountered: