Java垃圾收集日志消息 [英] Java Garbage Collection Log messages

查看:73
本文介绍了Java垃圾收集日志消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经配置java将垃圾收集信息转储到日志中( verbose GC )。我不确定日志中垃圾收集条目的含义。下面列出了这些条目的示例。我搜索了 Google ,但没有找到明确的解释。



我有一些合理的猜测,但我正在寻找答案,它们为条目中的数字提供了严格的定义,并由可靠来源提供支持。所有答案的自动+1引用sun文档。我的问题是:


  1. PSYoungGen是指什么?我认为这与以前的(年轻?)一代有关,但究竟是什么?

  2. 数字的第二个三元组与第一个三元组的区别是什么?

  3. 为什么名称(PSYoungGen)但不是第二?

  4. 三元组中每个数字(内存大小)的含义是什么。例如在109884K-> 14201K(139904K)中,是GC 109884k之前的内存,然后减少到14201K。第三个数字如何相关?为什么我们需要第二组数字?




8109.128:[GC [PSYoungGen:109884K-> 14201K(139904K)]
691015K-> 595332K(1119040K),0.0454530
秒]

8112.111:[GC [PSYoungGen:126649K-> 15528K (142336K)]
707780K-> 605892K(1121472K),0.0934560
secs]

8112.802:[GC [PSYoungGen:130344K-> 3732K

720708K-> 607895K(1097728K),0.0682690
secs] div>

大部分内容在 GC调优指南(您无论如何都会很好地阅读)。


命令行选项 - 详细信息:gc 会导致在每个集合上打印有关堆和垃圾回收的信息。例如,这里是一个大型服务器应用程序的输出:

  [GC 325407K-> 83000K(776768K),0.2300771秒] 
[GC 325816K-> 83372K(776768K),0.2454258秒]
[Full GC 267628K-> 83769K(776768K),1.8479984秒]
pre>

这里我们看到两个小集合,后面跟着一个主要集合。箭头之前和之后的数字(例如,第一行的 325407K-> 83000K )分别表示垃圾收集之前和之后的活动对象的总大小。在次要收集之后,大小包括一些垃圾(不再活动)但不能回收的对象。这些对象要么被包含在终身代中,要么从终身代代或永久代代中被引用。

括号中的下一个数字(例如,从第一行开始的(776768K))是承诺的大小堆:在没有从操作系统请求更多内存的情况下可用于Java对象的空间量。请注意,该数字不包含其中一个生存者空间,因为在任何给定时间只能使用一个空间空间,并且不包含永久生成,该永久生成保存虚拟机使用的元数据。

线上的最后一项(例如 0.2300771秒)表示执行收集所用的时间;在这种情况下约为四分之一秒。

第三行主要集合的格式类似。
$ b -verbose:gc 产生的输出格式在未来版本中可能会有所变化。

我不确定为什么在你的PSYoungGen中存在PSYoungGen;你改变了垃圾回收器吗?


I have configured java to dump garbage collection information into the logs (verbose GC). I am unsure of what the garbage collection entries in the logs mean. A sample of these entries are posted below. I've searched around on Google and have not found solid explanations.

I have some reasonable guesses, but I'm looking for answers which provide strict definitions of what the numbers in the entries mean, backed up by credible sources. An automatic +1 to all answers which cite sun documentation. My questions are:

  1. What does PSYoungGen refer to? I assume it has something to do with the previous (younger?) generation, but what exactly?
  2. What is the difference between the second triplet of numbers and the first?
  3. Why is a name(PSYoungGen) specified for the first triplet of numbers but not the second?
  4. What does each number (memory size) in the triplet mean. For example in 109884K->14201K(139904K), is the memory before GC 109884k and then it is reduced to 14201K. How is the third number relevant? Why would we require a second set of numbers?

8109.128: [GC [PSYoungGen: 109884K->14201K(139904K)] 691015K->595332K(1119040K), 0.0454530 secs]

8112.111: [GC [PSYoungGen: 126649K->15528K(142336K)] 707780K->605892K(1121472K), 0.0934560 secs]

8112.802: [GC [PSYoungGen: 130344K->3732K(118592K)] 720708K->607895K(1097728K), 0.0682690 secs]

解决方案

Most of it is explained in the GC Tuning Guide (which you would do well to read anyway).

The command line option -verbose:gc causes information about the heap and garbage collection to be printed at each collection. For example, here is output from a large server application:

[GC 325407K->83000K(776768K), 0.2300771 secs]
[GC 325816K->83372K(776768K), 0.2454258 secs]
[Full GC 267628K->83769K(776768K), 1.8479984 secs]

Here we see two minor collections followed by one major collection. The numbers before and after the arrow (e.g., 325407K->83000K from the first line) indicate the combined size of live objects before and after garbage collection, respectively. After minor collections the size includes some objects that are garbage (no longer alive) but that cannot be reclaimed. These objects are either contained in the tenured generation, or referenced from the tenured or permanent generations.

The next number in parentheses (e.g., (776768K) again from the first line) is the committed size of the heap: the amount of space usable for java objects without requesting more memory from the operating system. Note that this number does not include one of the survivor spaces, since only one can be used at any given time, and also does not include the permanent generation, which holds metadata used by the virtual machine.

The last item on the line (e.g., 0.2300771 secs) indicates the time taken to perform the collection; in this case approximately a quarter of a second.

The format for the major collection in the third line is similar.

The format of the output produced by -verbose:gc is subject to change in future releases.

I'm not certain why there's a PSYoungGen in yours; did you change the garbage collector?

这篇关于Java垃圾收集日志消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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