1

I am using an application with G1 GC. Is there any parameter to trigger major GC when old gen utilization goes above a certain level? Right now, my heap usage looks like below

Heap Usage:
G1 Heap:
   regions  = 1504
   capacity = 1577058304 (1504.0MB)
   used     = 1183184896 (1128.373046875MB)
   free     = 393873408 (375.626953125MB)
   75.02480364860372% used
G1 Young Generation:
Eden Space:
   regions  = 540
   capacity = 823132160 (785.0MB)
   used     = 566231040 (540.0MB)
   free     = 256901120 (245.0MB)
   68.78980891719745% used
Survivor Space:
   regions  = 15
   capacity = 15728640 (15.0MB)
   used     = 15728640 (15.0MB)
   free     = 0 (0.0MB)
   100.0% used
G1 Old Generation:
   regions  = 580
   capacity = 738197504 (704.0MB)
   used     = 600176640 (572.373046875MB)
   free     = 138020864 (131.626953125MB)
   81.30298961292614% used

Though the old gen utilization is above 80%, major GC is not triggered. If i run the following, a major GC is triggered and most of the objects in my old gen are collected. Is there a way to trigger such major GCs periodically?

jmap -histo:live <pid>

GC related options provided on JVM startup

-server -Xms1503m -Xmx1503m -Xss512k -XX:ReservedCodeCacheSize=240m -XX:MetaspaceSize=512m -XX:MaxMetaspaceSize=512m -XX:+UseG1GC -XX:MaxGCPauseMillis=2000 -XX:+UseStringDeduplication -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=30
pc70
  • 681
  • 1
  • 14
  • 28
  • 1
    Calling `System::gc` should do. On Oracle JVM, there's an option to ignore the call, and IIRC another one causing minor GC instead, but by default it should do. `+++` However, you should reconsider what you want. Doing GC before it is necessary ist just wasting memory. Or are concerned with the pauses and the `-XX:MaxGCPauseMillis=2000` setting doesn't work for you? – maaartinus Aug 23 '18 at 00:27
  • hi @pc70, was this issue resolved and with what config.We too want to trigger a FullGC periodically. Waiting for your response. – Amol Kshirsagar Oct 09 '22 at 21:03

1 Answers1

0

With G1, the initial marking phase is triggered by the occupancy fraction, i.e. how full the heap is. By default, the initiating occupancy fraction is 45% but that is the fraction of the whole heap, not the old gen.

You can change this using the -XX:InitiatingHeapOccupancyPercent flag and set it to something less than 45. It seems a bit odd that you're seeing the old gen. 80% full. Since G1 does some phases concurrently with application threads maybe you're promoting at such a rate that the heap is filling up faster than G1 is reclaiming but that seems unlikely.

There's also an experimental flag, -XX:G1MixedGCLiveThresholdPercent that you might want to look at. There's more information here:

https://www.oracle.com/technetwork/articles/java/g1gc-1984535.html

Speakjava
  • 3,177
  • 13
  • 15
  • I am surprised by the 80% utilization as well since doing a jmap -histo:live collects a lot of objects. The total time being spent is less than 1 sec per minute. Though i set the pause target as 2 secs, very little is being collected. Will play around with -XX:G1MixedGCLiveThresholdPercent – pc70 Aug 23 '18 at 16:00