Bug 482964 - Finalizer report does not show all objects available for finalization
Summary: Finalizer report does not show all objects available for finalization
Status: CLOSED MOVED
Alias: None
Product: MAT
Classification: Tools
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-25 01:03 EST by James Livingston CLA
Modified: 2024-05-08 14:53 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Livingston CLA 2015-11-25 01:03:35 EST
The Finalizer Overview shows objects being finalized and those queued for finalization, but it would be useful to also see objects that are not queued but would be if the JVM checked.

As a first approximation, all finalizable objects whose only incoming reference is from a Finalizer could be listed: in OQL "SELECT objects f.referent FROM java.lang.ref.Finalizer f where (inbounds(f.referent).size() = 1)"
Comment 1 Andrew Johnson CLA 2017-06-07 08:12:46 EDT
Would the retained set of all objects in the 'Ready for Finalizer Thread' query be interesting?
Those objects aren't reachable from ordinary threads, so might be eligible for finalization, though another finalizer could make them accessible before they go on the queue.
Comment 2 Andrew Johnson CLA 2020-04-09 13:37:33 EDT
Another approach for dumps from Oracle-based VMs is to use the Java Basics > References > Finalizer Reference Statistics query.

The 'Only Retained through Finalizer' shows all the objects only retained by finalizers, including finalizable objects on the finalizer queue and finalizable objects no longer directly reachable but which are not yet on the finalizer queue, plus all the other objects they retain.

For dumps from J9 based VMs it is a bit more complicated. In the latest snapshot builds the java.lang.Runtime object holds references via <Unfinalized>
to unfinalized objects. Select the objects, do merge shortest paths to GC roots excluding weak references, select merge to GC roots on class. 
That will show the objects with finalizer still in use. The compare query can then be used to take a difference of the histogram of the originally selected objects and the results of the merge to GC roots on class.
Comment 3 Eclipse Webmaster CLA 2024-05-08 14:53:10 EDT
This issue has been migrated to https://github.com/eclipse-mat/org.eclipse.mat/issues/26.