1

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

Mirko Ebert
  • 1,349
  • 1
  • 18
  • 36
rohit roy
  • 31
  • 3
  • do you use finalizers in your code at all? – Eugene Dec 05 '18 at 20:04
  • Finalizers can cause objects to be retained and never garbage collected. This is of course a bug in the finalizer method. If those Finalizer references are for anything other than well tested code (i.e., some well known public library) then it's likely whoever wrote them messed up and is causing problems. – markspace Dec 05 '18 at 20:10

1 Answers1

0

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.

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
  • Thanks for your answer karol. So before clicking on calculate exact size your kit is showing finalizer in heap dump. So finalizer is the problem correct? Also we are not using finalizer directly. Instead it is coming from various libraries and not just one single class. Seems all the finalizer that are created are not getting cleared out. – rohit roy Dec 06 '18 at 05:48