简体   繁体   English

使用G1 GC定期触发主要GC

[英]Trigger major GC periodically with G1 GC

I am using an application with G1 GC. 我正在使用G1 GC的应用程序。 Is there any parameter to trigger major GC when old gen utilization goes above a certain level? 当旧发电利用率超过一定水平时,是否有任何参数可触发主要GC? 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. 尽管旧发电利用率高于80%,但不会触发大型GC。 If i run the following, a major GC is triggered and most of the objects in my old gen are collected. 如果我运行以下命令,则会触发一个主要的GC并收集我的旧一代中的大多数对象。 Is there a way to trigger such major GCs periodically? 有没有办法定期触发这些主要的GC?

jmap -histo:live <pid>

GC related options provided on JVM startup JVM启动时提供的与GC相关的选项

-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

With G1, the initial marking phase is triggered by the occupancy fraction, ie how full the heap is. 使用G1时,初始标记阶段由占用率(即堆满)触发。 By default, the initiating occupancy fraction is 45% but that is the fraction of the whole heap, not the old gen. 默认情况下,初始占用率是45%,但这是整个堆(而不是旧一代)的一部分。

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. 您可以使用-XX:InitiatingHeapOccupancyPercent标志将其更改,并将其设置为小于45的值。您看到的是旧一代似乎有点奇怪。 80% full. 80%充满。 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. 由于G1与应用程序线程同时执行某些阶段,因此您可能以这样的速率进行升级:堆的填充速度比G1的回收速度快,但这似乎不太可能。

There's also an experimental flag, -XX:G1MixedGCLiveThresholdPercent that you might want to look at. 您可能还需要查看一个实验性标志-XX:G1MixedGCLiveThresholdPercent。 There's more information here: 这里有更多信息:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM