gpt4 book ai didi

java - 为什么 GC 每小时运行一次?

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:48:09 26 4
gpt4 key购买 nike

我们观察到完整垃圾回收 (GC) 通常每小时执行一次。

检查了JreMemoryLeakPreventionListener的时间间隔。它被设置为 Long.MAX_VALUE。尽管 gc 每小时运行一次。

还观察到GC称为hourly basis是显式GC

GC 日志:

2016-10-15T23:23:09.341-0400: 165558.099: [GC (System.gc()) [PSYoungGen: 264601K->5865K(1357312K)] 389672K->130937K(4153856K), 0.0075210 secs] [Times: user=0.07 sys=0.00, real=0.00 secs] 
2016-10-15T23:23:09.349-0400: 165558.107: [Full GC (System.gc()) [PSYoungGen: 5865K->0K(1357312K)] [ParOldGen: 125071K->125178K(2796544K)] 130937K->125178K(4153856K) [PSPermGen: 72263K->72263K(131072K)], 0.3417940 secs] [Times: user=5.16 sys=0.04, real=0.35 secs]
2016-10-16T00:23:09.692-0400: 169158.450: [GC (System.gc()) [PSYoungGen: 198858K->2600K(1354752K)] 324037K->127779K(4151296K), 0.0077680 secs] [Times: user=0.08 sys=0.01, real=0.01 secs]
2016-10-16T00:23:09.700-0400: 169158.458: [Full GC (System.gc()) [PSYoungGen: 2600K->0K(1354752K)] [ParOldGen: 125178K->124436K(2796544K)] 127779K->124436K(4151296K) [PSPermGen: 72282K->72282K(131072K)], 0.3481690 secs] [Times: user=5.13 sys=0.03, real=0.35 secs]
2016-10-16T01:23:10.050-0400: 172758.808: [GC (System.gc()) [PSYoungGen: 279139K->7990K(1361408K)] 403576K->132426K(4157952K), 0.0075860 secs] [Times: user=0.07 sys=0.00, real=0.01 secs]
2016-10-16T01:23:10.058-0400: 172758.815: [Full GC (System.gc()) [PSYoungGen: 7990K->0K(1361408K)] [ParOldGen: 124436K->124383K(2796544K)] 132426K->124383K(4157952K) [PSPermGen: 72284K->72284K(131072K)], 0.3713300 secs] [Times: user=5.73 sys=0.04, real=0.37 secs]
2016-10-16T02:23:10.430-0400: 176359.188: [GC (System.gc()) [PSYoungGen: 112842K->544K(1358848K)] 237225K->124927K(4155392K), 0.0167260 secs] [Times: user=0.05 sys=0.00, real=0.02 secs]
2016-10-16T02:23:10.447-0400: 176359.205: [Full GC (System.gc()) [PSYoungGen: 544K->0K(1358848K)] [ParOldGen: 124383K->124265K(2796544K)] 124927K->124265K(4155392K) [PSPermGen: 72292K->72292K(131072K)], 0.2931430 secs] [Times: user=3.21 sys=0.03, real=0.29 secs]
2016-10-16T03:23:10.742-0400: 179959.500: [GC (System.gc()) [PSYoungGen: 117926K->768K(1363968K)] 242192K->125033K(4160512K), 0.0070720 secs] [Times: user=0.06 sys=0.00, real=0.01 secs]
2016-10-16T03:23:10.749-0400: 179959.507: [Full GC (System.gc()) [PSYoungGen: 768K->0K(1363968K)] [ParOldGen: 124265K->124263K(2796544K)] 125033K->124263K(4160512K) [PSPermGen: 72306K->72306K(131072K)], 0.2602180 secs] [Times: user=3.33 sys=0.02, real=0.26 secs]
2016-10-16T04:23:11.011-0400: 183559.768: [GC (System.gc()) [PSYoungGen: 198248K->2356K(1362432K)] 322511K->126619K(4158976K), 0.0076610 secs] [Times: user=0.07 sys=0.00, real=0.01 secs]
2016-10-16T04:23:11.018-0400: 183559.776: [Full GC (System.gc()) [PSYoungGen: 2356K->0K(1362432K)] [ParOldGen: 124263K->124978K(2796544K)] 126619K->124978K(4158976K) [PSPermGen: 72308K->72308K(131072K)], 0.3353340 secs] [Times: user=5.78 sys=0.04, real=0.33 secs]
2016-10-16T05:23:11.355-0400: 187160.113: [GC (System.gc()) [PSYoungGen: 228778K->10333K(1367040K)] 353757K->135311K(4163584K), 0.0069470 secs] [Times: user=0.08 sys=0.00, real=0.00 secs]
2016-10-16T05:23:11.362-0400: 187160.120: [Full GC (System.gc()) [PSYoungGen: 10333K->0K(1367040K)] [ParOldGen: 124978K->130352K(2796544K)] 135311K->130352K(4163584K) [PSPermGen: 72308K->72308K(131072K)], 0.2240270 secs] [Times: user=2.96 sys=0.02, real=0.23 secs]


Tomcat 版本:Apache Tomcat/8.0.24

# /opt/tomcat/bin/version.sh 
Using CATALINA_BASE: /opt/tomcat
Using CATALINA_HOME: /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/hbase/conf:/opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.0.24
Server built: Jul 1 2015 20:19:55 UTC
Server number: 8.0.24.0
OS Name: Linux
OS Version: 2.6.32-573.3.1.el6.x86_64
Architecture: amd64
JVM Version: 1.7.0_79-b15
JVM Vendor: Oracle Corporation

为什么 GC 每小时运行一次,即使堆未满?

最佳答案

我怀疑这是重复的,但找不到。

DGC(分布式 GC)的默认周期为 1 小时。这会定期运行以清理分布式 RMI 资源,例如 JMX。

您可以将周期延长至一周。

https://docs.oracle.com/javase/8/docs/technotes/guides/rmi/sunrmiproperties.html

sun.rmi.dgc.server.gcInterval

When it is necessary to ensure that unreachable remote objects are unexported and garbage collected in a timely fashion, the value of this property represents the maximum interval (in milliseconds) that the Java RMI runtime will allow between garbage collections of the local heap. The default value is 3600000 milliseconds (one hour).

sun.rmi.dgc.client.gcInterval

When it is necessary to ensure that DGC clean calls for unreachable remote references are delivered in a timely fashion, the value of this property represents the maximum interval (in milliseconds) that the Java RMI runtime will allow between garbage collections of the local heap. The default value is 3600000 milliseconds (one hour).

这两个都要设置一个大的数字(我设置为一周)

关于java - 为什么 GC 每小时运行一次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40069054/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com