Reputation: 9624
I am trying to understand the outputs of jstat
as well as the APIs provided by Java's GarbageCollectorMXBean.getCollectionCount()
.
Using jstat
with the -gcutil
option provides a stat called 'FGC - Number of full GC events'. What does this number denote exactly? Does it denote the total number of objects collected by the corresponding garbage collector, as in total objects cleared in minor and major collections in that sample time period? If no, then what does it denote?
Coming to the GarbageCollectorMXBean.getCollectionCount()
, does it also denote the same thing - the total number of objects collected by the corresponding GC.
If anyone could provide a better understanding to the above, that would be great! Thanks.
Upvotes: 2
Views: 659
Reputation: 13696
The FGC
column of jstat
shows number of "full GC events". This basically means the number of full garbage collections performed since the JVM started. It says nothing about the number of collected objects.
The YGC
column of jstat
shows the same metric but for young generation collections.
The GarbageCollectorMXBean.getCollectionCount()
metric gives you the number of collections performed using that specific garbage collector since the JVM started.
Generally, the FGC
column of jstat
and the GarbageCollectorMXBean.getCollectionCount()
for your tenured generation collector will give you the same number. However there are some subtle differences. For example, if you use the Concurrent Mark Sweep collector, each Full GC will count as 2 "Full GC events" as counted by jstat
, while GarbageCollectorMXBean.getCollectionCount()
will count it as a single collection.
Upvotes: 1