In a running system, we see lots of "Full GC (System)" which indicates someone triggers System.gc().
Is there a way to find out where in the code this happens?
I did search all the available source but found nothing suspicious so it must be somewhere, probably another app that's running in the same container or the container itself.
gc() method runs the garbage collector. Calling this suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse.
It's almost always a bad idea to call it because the automatic memory management usually knows better than you when to gc. It will do so when its internal pool of free memory is low, or if the OS requests some memory be handed back.
gc() call is when you want to force finalization, i.e. the call to finalize method.
Developers can call System. gc() anywhere in their code to instruct the JVM to prioritize garbage collection. When a developer calls this method -- and there isn't an extreme load on the JVM -- a Java GC cycle will happen within seconds.
You can change the Runtime class to log where gc() is being called to a file (System.gc() calls Runtime.gc())
To do this, edit a copy, compile it and add it to your -Xbootclasspath/p:
However a high number of Full GC is more likely to be due to insufficient survivor space or a full tenured space.
Can you try running
jstat -gccause {pid} 5s
Some library which you use might call explicit gc. You can disable it with -XX:-DisableExplicitGC
and take a look if it stops Full GC
in the logs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With