Java Memory Leaks Finalizer Your Kit

I have web server which is having memory leaks. There is sudden spike in old gen usage and then latency of server spikes. When I took heap dump and analyzed using your kit it was suggesting Finalizer object taking 100% of memory. But i am not able to understand why the gc usage is high only at some point of time and it does not happen regularly(it happens say once a week).

Also i observed that there is button on your kit "calculate exact retained size" when i use that finalizer object does not show in updated list.

I am attaching screenshot of your kit.

Also if there is a way i can get list of all the classes from where finalizer is coming up in heap dump.

Before pressing calculate retained size

Before pressing calculate retained size

After pressing calculate retained size:

after pressing calculate retained size

1 answer

  • answered 2018-12-05 20:04 Karol Dowbecki

    As per YourKit docs: Class List page:

    On opening the view, estimated retained sizes are shown instead of exact sizes, which cannot be immediately calculated. The exact sizes may be obtained by using "Calculate exact retained sizes" balloon above the "Retained Size" column. However, for most classes the estimation is very close to the exact value, so there is almost no need to run exact size calculation.

    java.lang.ref.Finalizer is created by objects overriding Object.finalize() method as they have to be collected in the background. Your best bet would be to inspect the heap dump and figure out which class is using finalize(). Ideally don't depend on this method as it's behavior tends to be unpredictable.

    If you have a high GC usage only once a week try to get the GC logs or record JVM behaviour with FlightRecorder. Perhaps you get a stop the world full GC cycle only once a week? It's impossible to tell without seeing logs and JVM configuration.