gpt4 book ai didi

java - java 垃圾收集日志条目 "Full GC (System)"是否意味着某个名为 System.gc() 的类?

转载 作者:IT老高 更新时间:2023-10-28 20:35:29 30 4
gpt4 key购买 nike

垃圾收集日志中的“Full GC (System)”条目是什么意思?那个叫 System.gc() 的类?

我的垃圾收集日志有两种不同的“完整 gc”条目类型?一个带有“系统”一词,另一个没有。有什么区别?

(更新:我搜索了这个词并没有找到明确的答案,只有几个问题。所以我想我会发布它。

系统:

164638.058: [Full GC (System) [PSYoungGen: 22789K->0K(992448K)] [PSOldGen: 1645508K->1666990K(2097152K)] 1668298K->1666990K(3089600K) [PSPermGen: 164914K->164914K(166720K)], 5.7499132 secs] [Times: user=5.69 sys=0.06, real=5.75 secs]

无系统:

166687.013: [Full GC [PSYoungGen: 126501K->0K(922048K)] [PSOldGen: 2063794K->1598637K(2097152K)] 2190295K->1598637K(3019200K) [PSPermGen: 165840K->164249K(166016K)], 6.8204928 secs] [Times: user=6.80 sys=0.02, real=6.81 secs]

GC 选项

我们与 gc 相关的 java 内存选项有:-Xloggc:../server/pe/log/jvm_gc.log -XX:+PrintGCTimeStamps -XX:+PrintGCDetails

我们不使用'-XX:+DisableExplicitGC',所以可能某些错误的类确实调用了 System.gc()

fwiw,我们完整的 jvm 选项:

-Xms3072m -Xmx3072m -XX:+HeapDumpOnOutOfMemoryError -XX:-UseGCOverheadLimit -Xloggc:../server/pe/log/jvm_gc.log -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -XX:MaxPermSize=256m -XX:+UseCompressedOops

提前致谢,

最佳答案

从 OpenJDK 的源代码我会说它是

const bool is_system_gc = gc_cause == GCCause::_java_lang_system_gc;

// This is useful for debugging but don't change the output the
// the customer sees.
const char* gc_cause_str = "Full GC";
if (is_system_gc && PrintGCDetails) {
gc_cause_str = "Full GC (System)";
}

我创建了一个自定义版本的 Runtime 类,以便在调用 Runtime.getRuntime().gc() 时将线程名称和堆栈跟踪记录到一个文件中。 (System.gc() 调用它)我发现它在跟踪和删除此类调用者方面很有用。

发生这种情况的一个地方是 sun.misc.GC 类。 RMI 将要求该类确保在最后 N 秒内执行了 GC。如果没有 GC,则会触发 full GC。

这仅在您减少次要 GC 的数量时才会显示为问题。具有讽刺意味的是,这可能意味着您获得更多完整的 GC。 ;)

我不使用 RMI(也许 JConsole 除外)所以我将它设置为一周。 (认为​​默认是一个小时)

-Dsun.rmi.dgc.server.gcInterval=604800000
-Dsun.rmi.dgc.client.gcInterval=604800000

关于java - java 垃圾收集日志条目 "Full GC (System)"是否意味着某个名为 System.gc() 的类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6626680/

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