Currently I am facing the problem that my application is showing long GC times sporadically, but all these are only caused by weak reference processing. So the thread stopped time is always close to the weak ref processing time. All other GC cycles are 0.0001 sec to 0.200 sec.
From the gc.log (reformatted):
10388.186: [GC[YG occupancy: 206547 K (306688 K)]10388.186: [Rescan (parallel) ,
0.1095860 secs]10388.295: [weak refs processing, 2.0799570 secs]
[1 CMS-remark: 2973838K(3853568K)] 3180386K(4160256K), 2.1899230 secs]
[Times: user=2.51 sys=0.00, real=2.18 secs]
Total time for which application threads were stopped: 2.1906890 seconds
Currently I have these settings in place. Tried simpler settings, but no change.
-Xms4g
-Xmx4g
-XX:NewSize=128m
-XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalMode
-XX:MaxGCPauseMillis=50
-XX:CMSInitiatingOccupancyFraction=50
-XX:ParallelGCThreads=16
-XX:+DisableExplicitGC
If I turn up NewSize, I end up with long normal GC cycles. The machine has 8 cores and does not burn that much cpu for the application. Tried to get to run the old gen GC early and concurrently.
And yes, I cannot get rid off the weak ref usage, because this is part of a 3rd party library.
I found this message in the "hotspot-gc-use" mailing list.
In short, try the
-XX:+ParallelRefProcEnabled
switch.UPDATE
I found a better explanation in Jon Masamitsu's Weblog: