Java垃圾收集日志条目是否为“Full GC(System)”?意思是一些叫做System.gc()的类? [英] Does java garbage collection log entry "Full GC (System)" mean some class called System.gc()?

查看:132
本文介绍了Java垃圾收集日志条目是否为“Full GC(System)”?意思是一些叫做System.gc()的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我的垃圾回收日志有两种不同的'full gc'入口类型?一个用'System'一词,另一个没有。有什么不同?



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



系统


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


无系统
$ b


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

GC选项



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

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



fwiw,这是我们完整的jvm选项:
$ b


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


/ p>

will

解决方案

从OpenJDK的源代码来看,

  const bool is_system_gc = gc_cause == GCCause :: _ java_lang_system_gc; 

//这对于调试很有用,但不要改变
//客户看到的输出。
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会要求这个班级确保GC在过去的N秒内执行完毕。如果没有GC,它会触发完整的GC。



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



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

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


What does "Full GC (System)" entry in the garbage collection logs mean? That some class called 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?

(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]

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]

GC Options

Our gc-related java memory options are: -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()

fwiw, our full jvm options:

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

thanks in advance,

will

解决方案

From the source for OpenJDK I would say it is

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.

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.

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

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

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

这篇关于Java垃圾收集日志条目是否为“Full GC(System)”?意思是一些叫做System.gc()的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆