[英]Minor GC pause times are too higfh. possible reasons?
I Am experiencing a regular high minor GC pause times(~ 9seconds).我正在经历一个常规的高次要 GC 暂停时间(~ 9 秒)。
The application is a server written in Java, executing 3 transactions/seconds.该应用程序是一个用 Java 编写的服务器,执行 3 个事务/秒。
Eventhough there's no I/O excessive activity即使没有 I/O 过度活动
Heap parameters are:堆参数为:
-Xms1G
-Xmx14G
-XX:+UseConcMarkSweepGC
-XX:+DisableExplicitGC
-XX:+PrintGC
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintGCTimeStamps
-XX:+PrintGCDateStamps
-XX:+PrintGCDetails
What are the possible reasons for such minor gc pause times values?这种较小的 gc 暂停时间值的可能原因是什么?
For questions in category "Why my GC pause that long?" 对于类别“为什么我的GC暂停这么长时间?”的问题 you should always provide some snippets for GC logs.
您应该始终为GC日志提供一些摘要。
As a pure speculation, here are few reasons why minor GC may be abnormally slow: 纯粹出于猜测,以下是次要GC可能异常缓慢的一些原因:
-XX:+PrintReferebceGC
to get reference processing info into GC log) -XX:+PrintReferebceGC
才能将参考处理信息添加到GC日志中) As the other answer says, without GC log snippets it's not possible to answer this definitively. 就像另一个答案所说的那样,没有GC日志片段,就不可能确切地回答这个问题。 Some things to think about:
需要考虑的一些事情:
Assuming no impact from the underlying OS (scheduling, CPU thrashing), the time taken for a minor collection will be proportional to the amount of live data in the young gen. 假设不受到底层操作系统的影响(计划,CPU抖动),次要收集所花费的时间将与年轻一代中实时数据的数量成正比。 when the collector runs (every live object in the young gen. gets copied during a minor GC).
收集器运行时(年轻一代中的每个活动对象在次要GC中都会被复制)。 Looking at the graph of your old gen.
看你的老一代的图。 you are seeing consistent growth which would indicate you are promoting significant amounts of data during minor GC.
您会看到持续增长,这表明您在次要GC期间正在推广大量数据。 You're either creating a lot of long-lived objects or you're maintaining references unnecessarily.
您要么创建许多长期存在的对象,要么不必要地维护引用。
To reduce the pauses you could try reducing the size of the Eden space (so there is less potential data to copy on each minor GC) and also reduce the tenuring threshold so that objects get moved out of the survivor spaces more quickly. 为了减少停顿,您可以尝试减小Eden空间的大小(因此,每个次要GC上要复制的潜在数据更少),还可以降低使用期限,以使对象更快地移出幸存空间。 The downside of this will be your minor GCs will happen more frequently so you will probably see a degradation in throughput.
这样做的缺点是次要GC的发生频率更高,因此吞吐量可能会下降。
I would also change the -Xms value. 我还将更改-Xms值。 You clearly need more than 1Gb in your heap so it would be best to set it to 14Gb to avoid the heap having to be resized by the JVM as the amount of data increases.
显然您的堆中需要超过1Gb,因此最好将其设置为14Gb,以避免随着数据量的增加,JVM必须调整堆的大小。
Try using 尝试使用
-XX:+UseG1GC -XX:MaxGCPauseMillis=1000
This will try to keep max GC pause below 1s. 这将尝试将最大GC暂停时间保持在1秒以下。
You need to assign enough memory using -Xmx
and set the MaxGCPauseMillis
as per need. 您需要使用
-Xmx
分配足够的内存,并根据需要设置MaxGCPauseMillis
。
IMHO:恕我直言:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.