Community
Participate
Working Groups
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)"
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.
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.
This issue has been migrated to https://github.com/eclipse-mat/org.eclipse.mat/issues/26.