| <?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE html |
| PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us"> |
| <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| |
| <meta name="generator" content="DITA-OT" /><meta name="DC.type" content="task" /> |
| <meta name="DC.title" content="Analyzing Finalizer" /> |
| <meta name="copyright" content="Copyright (c) 2008, 2023 SAP AG and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ " type="primary" /> |
| <meta name="DC.rights.owner" content="Copyright (c) 2008, 2023 SAP AG and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ " type="primary" /> |
| <meta name="DC.format" content="XHTML" /> |
| <meta name="DC.identifier" content="task_analyzingfinalizer" /> |
| <meta name="DC.language" content="en-us" /> |
| <link rel="stylesheet" type="text/css" href="../styles/commonltr.css" /> |
| <title>Analyzing Finalizer</title> |
| </head> |
| <body id="task_analyzingfinalizer"> |
| |
| <h1 class="title topictitle1" id="ariaid-title1">Analyzing Finalizer</h1> |
| |
| |
| |
| <div class="body taskbody"> |
| <div class="section context"> |
| <p class="p"> Finalizers are executed when the internal garbage collection |
| cleans up the objects. Since you have no control over the finalizer |
| execution, it is recommended not to use them. Because the memory can |
| only be released when the finalize method finished, long running |
| tasks in the finalizer can block the garbage collection. To get the |
| finalizers overview select Finalizer Overview Query from the query |
| list:</p> |
| |
| <img class="image" src="../mimes/finalizers.png" alt="Finalizer overview menu option and report" /> |
| <p class="p">This query includes the following subqueries:</p> |
| |
| |
| <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" class="table" frame="border" border="1" rules="all"><colgroup><col /><col /></colgroup><tbody class="tbody"> |
| <tr id="task_analyzingfinalizer__finalizer_in_processing" class="row"> |
| <td class="entry cellrowborder" style="vertical-align:top;"> |
| <strong class="ph b">Finalizer in Processing</strong> |
| </td> |
| |
| <td class="entry cellrowborder" style="vertical-align:top;"> |
| <p class="p"> Extract the object currently processed by Finalizer Thread. This |
| query returns the currently processed object by the Finalizer |
| Thread if any. The returned object can be processed for one of |
| the following reasons:</p> |
| |
| <ul class="ul"> |
| <li class="li">it is blocking</li> |
| |
| <li class="li">it is long running</li> |
| |
| <li class="li">the finalizer queue was or is still full.</li> |
| |
| </ul> |
| |
| <p class="p"> Use the finalizer queue query to check the queue.</p> |
| |
| </td> |
| |
| </tr> |
| |
| <tr id="task_analyzingfinalizer__ready_for_finalizer_thread" class="row"> |
| <td class="entry cellrowborder" style="vertical-align:top;"> |
| <strong class="ph b">Ready for Finalizer Thread</strong> |
| </td> |
| |
| <td class="entry cellrowborder" style="vertical-align:top;"> |
| <p class="p"> This query shows the objects ready for finalization in their |
| processing order. Following reasons can cause a full finalizer |
| queue:</p> |
| |
| <ul class="ul"> |
| <li class="li"> The currently processed object is blocking or long running |
| (please use our finalizer in processing query to check).</li> |
| |
| <li class="li"> The application made use of too many objects with |
| finalize() which are queued up in memory.</li> |
| |
| </ul> |
| |
| <div class="note"><span class="notetitle">Note:</span> |
| On J9 JVM-based dumps (e.g. IBM Java, OpenJ9), as expected, this |
| list shows objects waiting to be finalized. On previous versions |
| of Memory Analyzer (1.10 and earlier) it also showed those |
| which have already been finalized and are waiting to be |
| garbage collected. Those objects where finalization has been |
| completed are not now shown by this query, but might be in |
| the unreachable objects histogram if they are waiting to be |
| reclaimed. |
| <p class="p">States</p> |
| |
| <ol class="ol"> |
| <li class="li">Initially objects with a finalize method start in the |
| <a class="xref" href="../concepts/gcroots.html">UNFINALIZED</a> state. |
| With a J9 heap dump this is visible as an inbound <code class="ph codeph"><Unfinalized></code> reference from |
| the <code class="ph codeph">java.lang.Runtime</code> object.</li> |
| |
| <li class="li">Once the object is no longer <a class="xref" href="../concepts/reachability.html">reachable</a> |
| it goes onto the finalizer queue, visible via this query and with |
| J9 heap dumps as a <a class="xref" href="../concepts/gcroots.html">FINALIZABLE GC root</a>.</li> |
| |
| <li class="li">Once finalization is completed the object is not seen in either of these two |
| ways. Normally it would be garbage collected, but if the <code class="ph codeph">finalizer()</code> |
| code made the object reachable again by storing a reference to it in an ordinary object |
| it might still be strongly reachable.</li> |
| |
| </ol> |
| |
| </div> |
| |
| <p class="p"> Additionally a class-level summary of the objects is provided</p> |
| |
| </td> |
| |
| </tr> |
| |
| <tr id="task_analyzingfinalizer__finalizer_thread" class="row"> |
| <td class="entry cellrowborder" style="vertical-align:top;"> |
| <strong class="ph b">Finalizer Thread</strong> |
| </td> |
| |
| <td class="entry cellrowborder" style="vertical-align:top;"> This query shows the daemon thread which performs the |
| object finalizations.</td> |
| |
| </tr> |
| |
| <tr id="task_analyzingfinalizer__finalizer_thread_locals" class="row"> |
| <td class="entry cellrowborder" style="vertical-align:top;"> |
| <strong class="ph b">Finalizer Thread Locals</strong> |
| </td> |
| |
| <td class="entry cellrowborder" style="vertical-align:top;"> |
| <p class="p"> |
| This query shows the thread locals of the daemon thread that |
| performs the object finalizations. If there are any, this |
| indicates misuse in at least one of the processed finalizers |
| ( |
| <span class="keyword cmdname">finalize()</span> |
| implemented wrong) and might cause severe problems (e.g. |
| unreclaimed memory permanently hold by the finalizer thread or |
| finalizer processed under useless thread locals harming |
| application logic) |
| </p> |
| |
| </td> |
| |
| </tr> |
| |
| </tbody> |
| </table> |
| </div> |
| |
| <p class="p">The <a class="xref" href="../reference/inspections/component_report.html#ref_inspections_component_report__finalizer">component report</a> also includes information about objects |
| belonging to the component which implement the <code class="ph codeph">finalize()</code> method |
| and so could be finalized at some point.</p> |
| |
| </div> |
| |
| </div> |
| |
| </body> |
| </html> |