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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6626680/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 16:41:39  来源:igfitidea点击:

Does java garbage collection log entry "Full GC (System)" mean some class called System.gc()?

javagarbage-collection

提问by user331465

What does "Full GC (System)" entry in the garbage collection logs mean? That some class called System.gc() ?

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

My garbage collection logs has two different entry types for 'full gc'? One with the word 'System', the other without. What's the difference?

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

(Update: I searched on this term and didn't find a definitive answer, only a few questions. So I thought I'd post it).

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

System:

系统:

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]

164638.058:[全GC (系统)[PSYoungGen:22789K-> 0K(992448K)] [PSOldGen:1645508K-> 1666990K(2097152K)] 1668298K-> 1666990K(3089600K)[PSPermGen:164914K-> 164914K(166720K)],5.7499132秒] [时间:用户=5.69 系统=0.06,真实=5.75 秒]

No-System:

无系统:

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]

166687.013:[全GC [PSYoungGen:126501K-> 0K(922048K)] [PSOldGen:2063794K-> 1598637K(2097152K)] 2190295K-> 1598637K(3019200K)[PSPermGen:165840K-> 164249K(166016K)],6.8204928秒] [时间:用户=6.80 系统=0.02,真实=6.81 秒]

GC Options

GC 选项

Our gc-related java memory options are: -Xloggc:../server/pe/log/jvm_gc.log -XX:+PrintGCTimeStamps -XX:+PrintGCDetails

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

We do not '-XX:+DisableExplicitGC', so it's possible some errant class does call System.gc()

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

fwiw, our full jvm options:

fwiw,我们完整的 jvm 选项:

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

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

thanks in advance,

提前致谢,

will

将要

采纳答案by Peter Lawrey

From the source for OpenJDK I would say it is

从 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)";
}

I created a custom version of the Runtime class to record the thread name and stack trace to a file whenever Runtime.getRuntime().gc() was called. (System.gc() calls this) I found it useful in tracking down and removing such callers.

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

One place this happens is in sun.misc.GC class. The RMI will ask this class to ensure a GC has been performing in the last N seconds. If there has been no GC it triggers a full GC.

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

This only shows as a problem if you reduce the number of minor GCs. Ironicly it can mean you get more full GCs. ;)

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

I don't use RMI (except perhaps JConsole) So I have it set to a week. (Think the default is an hour)

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

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

回答by user922965

I test explicit GC on my mac, it do show "Full GC (System)" when using jdk 1.6, but show "Full GC" with jdk 1.7

我在我的 mac 上测试了显式 GC,它在使用 jdk 1.6 时显示“Full GC(系统)”,但使用 jdk 1.7 显示“Full GC”

So don't rely on the "System" label when you tuning GC log unless you know exactly about running environment and jdk version number

所以在调优GC日志时不要依赖“系统”标签,除非你确切地知道运行环境和jdk版本号