什么是“GC - ”?意味着在一个Java垃圾收集日志? [英] What does "GC--" mean in a java garbage collection log?

查看:180
本文介绍了什么是“GC - ”?意味着在一个Java垃圾收集日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已开启详细的GC日志记录以跟踪已知的内存泄漏,并在日志中获得以下条目:

  ... 
3607872.687:[GC 471630K-> 390767K(462208K),0.0325540秒]
3607873.213:[GC-- 458095K-> 462181K(462208K),0.2757790秒]
3607873.488:[全GC 462181K-> 382186K(462208K),1.5346420秒]
...

我理解了第一个和第三个,但是这个GC--是什么意思? 解决方案

我在gc输出中得到了这些行:

  44871.602:[GC-- [PSYoungGen:342848K-> 342848K( 345600K)] 961401K-> 1041877K(1044672K),0.1018780秒] [时间:用户= 0.16 SYS = 0.00,真= 0.11秒] 

我读了Yishai的回答,这很有道理,但我想在Java GC源代码中看到它,当JVM在GC日志中打印 - 时,以及为什么。 / p>

因为据我所知Paralle l年轻一代的清除是一个世界末日的GC,因此不能是与此GC并行的任何对象。 (请参阅 https://blogs.oracle.com/jonthecollector/entry/our_collectors



您可以在jdk源代码中找到它(请参阅 http://hg.openjdk.java.net/jdk7/jdk7
g1CollectedHeap.cpp和psScavenge.cpp

  jdk7-ee67ee3bd597 / hotspot / src / share $ egrep -h -A2 -B5 -r'\ -\-''* 
#G1 Collector
if( evacuation_failed()){
remove_self_forwarding_pointers();
if(PrintGCDetails){
gclog_or_tty-> print((to-space overflow));
} else if(PrintGC){
gclog_or_tty-> print( - );
}
}
-
#并行清除收集器
promotion_failure_occurred = promotion_failed();
if(promotion_failure_occurred){
clean_up_failed_promotion();
if(PrintGC){
gclog_or_tty-> print( - );




$ b $ h $> GC的原因 - 并行清除收集器

年轻人GC遇到促销失败(请参阅 http://mail.openjdk.java.net/pipermail/hotspot-gc-use/2010-March/000567.html ):



促销失败是一种不成功的清理行为,因为旧有的空间不足以完成所有必需的促销活动。清除
基本上是解开的,然后完成整个堆的STW压缩。




没有足够的空间并不一定意味着旧的空间不够,而是旧的空间碎片严重(见 http://blog.ragozin.info/2011/10/java-cg-hotspots-cms-and-heap.html ):



[...]不可能找到一定数量的连续内存以促进特定的大对象,即使总空闲字节数足够大。


这两个JVM选项可以帮助您分析堆碎片(请参阅 http://blog.ragozin.info/2011/10/java-cg

  -XX:+ PrintPromotionFailure 
- XX:PrintFLSStatistics = 1



使用G1收集器的GC原因



G1的疏散失败是当一个幸存者地区没有足够的空间存放来自Young Region的幸存对象。


我不知道'不知道G1收集器是否回应Full GC的撤离失败。


We've turned on verbose GC logging to keep track of a known memory leak and got the following entries in the log:

...
3607872.687: [GC 471630K->390767K(462208K), 0.0325540 secs]
3607873.213: [GC-- 458095K->462181K(462208K), 0.2757790 secs]
3607873.488: [Full GC 462181K->382186K(462208K), 1.5346420 secs]
...

I understand the first and third of those, but what does the "GC--" one mean?

解决方案

I got these kind of lines in my gc output:

44871.602: [GC-- [PSYoungGen: 342848K->342848K(345600K)] 961401K->1041877K(1044672K), 0.1018780 secs] [Times: user=0.16 sys=0.00, real=0.11 secs]

I read Yishai's answer and it would make sense, but I wanted to see it for myself in the Java GC source code, when the JVM prints "--" in the GC log and why.

Because to my knowledge "Parallel Scavenge" of the Young Gen is a stop-the-world GC, so there couldn't be any objects created parallel to this GC. (see https://blogs.oracle.com/jonthecollector/entry/our_collectors)

You can find this in the jdk source code (see http://hg.openjdk.java.net/jdk7/jdk7) g1CollectedHeap.cpp and psScavenge.cpp

jdk7-ee67ee3bd597/hotspot/src/share$ egrep -h -A2 -B5 -r '"\-\-"' *
# G1 Collector
if (evacuation_failed()) {
  remove_self_forwarding_pointers();
  if (PrintGCDetails) {
    gclog_or_tty->print(" (to-space overflow)");
  } else if (PrintGC) {
    gclog_or_tty->print("--");
  }
}
--
# Parallel Scavenge Collector
promotion_failure_occurred = promotion_failed();
if (promotion_failure_occurred) {
  clean_up_failed_promotion();
  if (PrintGC) {
    gclog_or_tty->print("--");
  }
}

Reason for GC-- with the Parallel Scavenge Collector

The Young GC encountered a promotion failure (see http://mail.openjdk.java.net/pipermail/hotspot-gc-use/2010-March/000567.html):

A promotion failure is a scavenge that does not succeed because there is not enough space in the old gen to do all the needed promotions. The scavenge is in essence unwound and then a full STW compaction of the entire heap is done.

'Not enough space' doesn't necessarily mean that there isn't enough space in old, but that the old space is heavily fragmented (see http://blog.ragozin.info/2011/10/java-cg-hotspots-cms-and-heap.html):

[...] it is impossible to find certain amount of continuous memory to promote particular large object, even though total number of free bytes is large enough.

These two JVM options could help you analyze your heap fragmentation (see http://blog.ragozin.info/2011/10/java-cg-hotspots-cms-and-heap.html):

-XX:+PrintPromotionFailure
-XX:PrintFLSStatistics=1

Reason for GC-- with the G1 Collector

A evacuation failure with the G1 is when a Survivor Region hasn't enough space for the surviving objects from a Young Region.

I don't know if the G1 Collector responds to a evacuation failure with a Full GC or not.

这篇关于什么是“GC - ”?意味着在一个Java垃圾收集日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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