Finalizer objects and heap monitoring question

Questions about YourKit Java Profiler
Post Reply
orfano
Posts: 2
Joined: Mon Apr 20, 2020 11:32 pm

Finalizer objects and heap monitoring question

Post by orfano »

Hello team,

I have come across with excellent explanations of how java.lang.ref.Finalizer works.
However, I still have a doubt which I hope to be able to clarify in this forum.


Here is the scenario we are facing, we have a Java application running and even though when there is no heavy load submitted against it, there are still some threads running in the background to send information to other systems. And since there is some monitoring in place, sometimes the memory usage goes over a threshold and an alert is raised.
When we take a heap dump and check it we see that java.lang.ref.Finalizer is on top of the Class console (for Yourkit) and the retained Size is quite big.

My question is, for the perspective of HEAP monitoring using VMConsole and other tools, would the Finalizer be taken into consideration? Which would explain why the alert was raised?

TIA! Flavio
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Finalizer objects and heap monitoring question

Post by Anton Katilin »

Hello Flavio,

Do you mean the objects among "Objects pending finalization"?
https://www.yourkit.com/docs/java/help/reachability.jsp

A JVM implementation (HotSpot for example) may physically add a finalizeable object to the finalization queue immediately upon the object creation, but not when the object actually becomes unreachable as one may expect. The fact that an object is in the queue does not mean anything except for what the object's class has finalize() method redefined.

If you are interested in objects really pending GC, you should consider only those among "Objects pending finalization" as the above mentioned view shows.

Best regards,
Anton
orfano
Posts: 2
Joined: Mon Apr 20, 2020 11:32 pm

Re: Finalizer objects and heap monitoring question

Post by orfano »

Hello Anton,

Thank you very much for your answer. It is exactly the reachability view that you mentioned that I am interested in and I have doubt.
So if we use the link you shared https://www.yourkit.com/docs/java/help/reachability.jsp we can see that in this example we see that the objects unreachable and not collected account for 681,163 objects and 65% of retained size.
Let's say we had also VisualVM showing the memory of the JVM at that moment as an image example in https://visualvm.github.io/ . If you look at the heap memory tab the blue represents used heap(on the right). Would this no collected objects be part of this used heap memory in the Visual VM? I hope it is clear my doubt.

TIA! Flavio
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Finalizer objects and heap monitoring question

Post by Anton Katilin »

Hello Flavio,

Yes. All objects still existing in the heap constitute the used heap size.

Best regards,
Anton
Post Reply