Java heap retention in java.lang.ref.Finalizer

Solution Verified - Updated

Environment

  • JBoss Enterprise Application Platform (EAP)

Issue

Resolution

  • Avoid using finalize() as much as possible.
  • Decrease the rate at which finalizeable objects are generated.
  • Improve the execution time of finalize() calls. Avoid using any synchronization here to avoid putting the Finalizer thread into long waits/blocks.

Root Cause

Diagnostic Steps

  • Troubleshoot with a heap dump and garbage collection logging as described in Java application "java.lang.OutOfMemoryError: Java heap space" to identify the source of retention.
  • Check the objects in the Finalizer queue. For example, Java Basics / Finalizer Overview in the Eclipse Memory Analyzer tool.
  • Gather multiple thread dumps over time leading to the OOME and see what kind of calls the Finalizer is making and any snags it hits.
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.