首页 > 解决方案 > 为什么 ParNew GC 时间随着老年代的大小而增加?

问题描述

我发现了一个奇怪的事情,ParNew GC 时间随着老年代大小的增加而增加,而在 Old GC(CMS) 之后,它又恢复了正常。老年代大小影响年轻gc时间吗?

Grafana GC 指标

Major GC 之间的 Young GC 日志

这是我的 jvm 选项:

-server -Xmx6656M -Xms6656M -Xmn4436M -XX:SurvivorRatio=8 -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m 

-XX:+UseConcMarkSweepGC -XX:ParallelGCThreads=4 -XX:ConcGCThreads=3 -XX:MaxTenuringThreshold=7 -XX:+CMSParallelInitialMarkEnabled -XX:+ParallelRefProcEnabled -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly 

-Xloggc:/dev/shm/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=2 -XX:GCLogFileSize=50M 

-XX:-UseCounterDecay -XX:AutoBoxCacheMax=20000 -XX:+AlwaysPreTouch -XX:MaxJavaStackTraceDepth=10000 -XX:-OmitStackTraceInFastThrow -XX:+UseCountedLoopSafepoints -XX:-UseBiasedLocking -XX:+ExplicitGCInvokesConcurrent -XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses

我怀疑这是因为年轻的 gc 工作时内存紧凑。

我怎样才能解决这个问题?

标签: javagarbage-collection

解决方案


Young GC with CMS collector involves dirty card scanning to capture old-to-young references. Size of dirty card table is proportional to size of old space.

More details are available in this article.


推荐阅读