当前位置: 首页 > 知识库问答 >
问题:

年轻一代是老一代吗

殷承恩
2023-03-14

我们使用G1收集器<当一个年轻的GC发生时(不是混合GC),堆的变化:[Eden:3666.0M(3666.0M)-

堆的变化为4819.1M(5346.0-526.9)

伊甸园改变了3666.0(3666.0-0.0)和幸存者-34M(20-54);为什么堆的变化不等于伊甸园和幸存者的总和(4819.1不等于(3666.0-34))?年轻的GC清除对象在老一代?

gc日志:

2021-04-06T03:00:51.872+0800: 296723.143: [GC pause (G1 Evacuation Pause) (young), 0.0483384 secs]
   [Parallel Time: 16.3 ms, GC Workers: 8]
      [GC Worker Start (ms): Min: 296723144.3, Avg: 296723144.3, Max: 296723144.4, Diff: 0.2]
      [Ext Root Scanning (ms): Min: 2.0, Avg: 2.5, Max: 3.8, Diff: 1.9, Sum: 20.0]
      [Update RS (ms): Min: 8.7, Avg: 9.8, Max: 10.2, Diff: 1.4, Sum: 78.5]
         [Processed Buffers: Min: 114, Avg: 124.2, Max: 145, Diff: 31, Sum: 994]
      [Scan RS (ms): Min: 1.0, Avg: 1.0, Max: 1.1, Diff: 0.1, Sum: 8.3]
      [Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
      [Object Copy (ms): Min: 2.4, Avg: 2.6, Max: 2.7, Diff: 0.3, Sum: 20.4]
      [Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
         [Termination Attempts: Min: 1, Avg: 1.4, Max: 2, Diff: 1, Sum: 11]
      [GC Worker Other (ms): Min: 0.0, Avg: 0.1, Max: 0.2, Diff: 0.2, Sum: 1.1]
      [GC Worker Total (ms): Min: 15.9, Avg: 16.1, Max: 16.1, Diff: 0.2, Sum: 128.4]
      [GC Worker End (ms): Min: 296723160.3, Avg: 296723160.4, Max: 296723160.5, Diff: 0.2]
   [Code Root Fixup: 0.2 ms]
   [Code Root Purge: 0.0 ms]
   [Clear CT: 0.7 ms]
   [Other: 31.2 ms]
      [Choose CSet: 0.0 ms]
      [Ref Proc: 25.6 ms]
      [Ref Enq: 0.0 ms]
      [Redirty Cards: 0.3 ms]
      [Humongous Register: 0.3 ms]
      [Humongous Reclaim: 1.6 ms]
      [Free CSet: 2.2 ms]
   [Eden: 3666.0M(3666.0M)->0.0B(3632.0M) Survivors: 20.0M->54.0M Heap: 5346.0M(6144.0M)->526.9M(6144.0M)]
 [Times: user=0.15 sys=0.02, real=0.04 secs] 
2021-04-06T03:02:23.524+0800: 296814.796: [GC pause (G1 Evacuation Pause) (young), 0.0485279 secs]
   [Parallel Time: 21.0 ms, GC Workers: 8]
      [GC Worker Start (ms): Min: 296814796.9, Avg: 296814797.0, Max: 296814797.1, Diff: 0.2]
      [Ext Root Scanning (ms): Min: 2.1, Avg: 2.5, Max: 3.9, Diff: 1.8, Sum: 20.0]
      [Update RS (ms): Min: 9.1, Avg: 10.3, Max: 10.6, Diff: 1.4, Sum: 82.0]
         [Processed Buffers: Min: 114, Avg: 126.0, Max: 134, Diff: 20, Sum: 1008]
      [Scan RS (ms): Min: 1.0, Avg: 1.1, Max: 1.2, Diff: 0.1, Sum: 8.6]
      [Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
      [Object Copy (ms): Min: 6.5, Avg: 6.7, Max: 6.9, Diff: 0.3, Sum: 53.6]
      [Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
         [Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 8]
      [GC Worker Other (ms): Min: 0.0, Avg: 0.1, Max: 0.2, Diff: 0.2, Sum: 1.0]
      [GC Worker Total (ms): Min: 20.5, Avg: 20.7, Max: 20.8, Diff: 0.3, Sum: 165.4]
      [GC Worker End (ms): Min: 296814817.5, Avg: 296814817.6, Max: 296814817.7, Diff: 0.2]
   [Code Root Fixup: 0.2 ms]
   [Code Root Purge: 0.0 ms]
   [Clear CT: 0.7 ms]
   [Other: 26.7 ms]
      [Choose CSet: 0.0 ms]
      [Ref Proc: 21.3 ms]
      [Ref Enq: 0.0 ms]
      [Redirty Cards: 0.2 ms]
      [Humongous Register: 0.3 ms]
      [Humongous Reclaim: 1.6 ms]
      [Free CSet: 2.0 ms]
   [Eden: 3632.0M(3632.0M)->0.0B(3632.0M) Survivors: 54.0M->54.0M Heap: 5390.6M(6144.0M)->526.9M(6144.0M)]
 [Times: user=0.18 sys=0.01, real=0.05 secs] 

共有1个答案

红经亘
2023-03-14

这是因为所做的工作是一个混合GC,所以它不仅清理了伊甸园,还清理了其他一些区域。

 类似资料:
  • 我正在为max分配8GB内存给Java编写的应用程序。它会内存溢出。我相信年轻一代总是比默认情况下的老一代小(堆的1/4)。而Eden/幸存者1,2在年轻一代内部。我相信在Eden空间中创建了新对象。 即使老一代还没有满,但年轻一代已经完全满了,java应用程序还是会耗尽内存吗? 如果短寿命的对象比长寿命的对象多,那么可以为年轻一代分配更多内存,或者至少将堆的50%分配给年轻一代吗?或者,由于jv

  • 问题内容: 是否将“静态最终”直接分配给年轻一代或老一代或烫发一代?(我猜想在我认为的时间内,它很可能会降落到旧的gen中。)如果在perm gen中分配了它,那么当在Perm Gen中进行类卸载时,是否会收集垃圾? 问题答案: 是否将“静态最终”直接分配给年轻一代或老一代或烫发一代? 变量引用的对象将根据与其他任何对象相同的规则进行分配。它最有可能在年轻一代或老一代中分配(如果它很大,并且适用某

  • 问题内容: 我对Heap,Young,Tenured和Perm一代感到困惑。 谁能解释一下? 问题答案: Java垃圾收集器被称为分 代垃圾收集器 。应用程序中的对象生存的时间长短不一,具体取决于它们的创建位置和使用方式。此处的主要见解在于,针对短期和长期对象使用不同的垃圾回收策略,可以针对每种情况专门优化GC。 松散地说,当对象在新 世代中 “生存”重复的垃圾回收时,它们将迁移到 终身代 。该

  • 我在尝试理解垃圾收集机制,我在研究代际算法,我有一个关于年轻人和老年人的代沟的问题。我读到,在年轻一代开始收集物品,GC是从GC根开始标记它们,以找到活的,通常它会将它们复制到幸存者空间,清除年轻一代区域,然后瞧。 我不明白,如果我们从GC根开始,我们开始遍历活动对象,我们不是也在旧一代中找到了对象吗?这是否意味着,当我们击中旧空间中的一个物体时,我们会在那个点上停止跟踪参照物?

  • 如果我错了,请随时指正。在JVM堆中,有老一代和年轻一代两代。在做全GC时,在老一代中,有像紧凑空间和修复漏洞这样的繁重操作,这会使JVM挂起。而我发现在年轻一代中,应用了一个轻量级的GC,从我的搜索结果中还有一个叫做Eden的区域涉及年轻一代。但是,在搜索了很多文档后,我对年轻一代中的GC仍然有两个困惑, 在年轻一代中,GC似乎不像老一代GC那样工作(即老一代GC压缩并修复漏洞)?如果是这样,年

  • 在某个时刻,我的应用程序开始创建许多临时阵列,这是预期的行为,我想给年轻一代提供大量空间,所以临时阵列不会被提升到终身一代。 JVM选项: 在某些时候,我的GC日志开始看起来像这样: 我非常困惑的事实,年轻一代的大小是629120K(=629M),而我预计它是约1/2(因为NewRatio=2)的终身一代大小这是158690816K(=158G)。终身大小生成对应于NewRatio和Xms的预期,