• 1 reply
  • Latest Post - ‏2011-09-13T11:50:36Z by Ruwin
1 Post

Pinned topic How to identify classes with finalizers

‏2009-06-23T21:24:19Z |
When analysing verbosegc from WebSphere using a tool like IBM Monitoring and Diagnostic Tools for Java - Garbage Collection and Memory Visualizer it warns about a large number of objects queued for finalizing.
The question is, how can a WebSphere system administrator determine which classes are 'guilty' of using finalizers?
The answer "Ask the developer" is not good enough because in this case there is a 'them and us' relationship between the people running the production system (and trying to tune it) and the developers who provide the apps.
What I need is tool or perhaps a trace option that can produce a list of the objects queued for finalizing so guilt can be properly attributed.
Anyone any suggestions?
Updated on 2011-09-13T11:50:36Z at 2011-09-13T11:50:36Z by Ruwin
  • Ruwin
    1 Post

    Re: How to identify classes with finalizers

    Did you ever solve this question?

    I have been struggling with the same question for a while now. In JVMs prior to Java 5, they were visible in a heapdump, but with Java 5 or higher they don't show in the heapdump anymore.

    The way I have it working on my windows machine with WebSphere 6.1 (java 5) is ugly, and I wonder if there is a better way.

    This is how I can see the classes that are finalized
    Add the following to the generic JVM arguments:
    -Xtrace:methods={java/lang/J9VMInternals.runFinalize()},print=mt -Xjit:exclude={java/lang/J9VMInternals.runFinalize*}

    Sample output in which java/util/zip/Inflater is the Class with the finalizer:
    11:04:12.974*0x14beae00 mt.3 > java/lang/J9VMInternals.runFinalize(Ljava/lang/Object;)V Bytecode static method
    11:04:12.974 0x14beae00 mt.19 - Static method arguments: (java/util/zip/Inflater@005ACDB8)
    11:04:12.974 0x14beae00 mt.9 < java/lang/J9VMInternals.runFinalize(Ljava/lang/Object;)V Bytecode static method
    The -Xtrace command traces the method that will execute the finalizer and also prints the argument which is the class we are looking for. To keep the logfile small I only included this particular method in the trace.
    The jit:exclude command prevents the method from being compiled by the JIT compiler. This is needed since the argument of the method will not be shown in the trace ones the method is compiled by the JIT compiler. Only this method is excluded to keep the performance impact to a minimum.

    Ruwin Veldwijk