<bdo id='VrPZP'></bdo><ul id='VrPZP'></ul>

    <legend id='VrPZP'><style id='VrPZP'><dir id='VrPZP'><q id='VrPZP'></q></dir></style></legend>

  1. <i id='VrPZP'><tr id='VrPZP'><dt id='VrPZP'><q id='VrPZP'><span id='VrPZP'><b id='VrPZP'><form id='VrPZP'><ins id='VrPZP'></ins><ul id='VrPZP'></ul><sub id='VrPZP'></sub></form><legend id='VrPZP'></legend><bdo id='VrPZP'><pre id='VrPZP'><center id='VrPZP'></center></pre></bdo></b><th id='VrPZP'></th></span></q></dt></tr></i><div id='VrPZP'><tfoot id='VrPZP'></tfoot><dl id='VrPZP'><fieldset id='VrPZP'></fieldset></dl></div>

  2. <tfoot id='VrPZP'></tfoot>

    <small id='VrPZP'></small><noframes id='VrPZP'>

    1. Java GC:为什么有两个幸存者区域?

      时间:2023-07-12
        <tfoot id='TmoCD'></tfoot>

            <i id='TmoCD'><tr id='TmoCD'><dt id='TmoCD'><q id='TmoCD'><span id='TmoCD'><b id='TmoCD'><form id='TmoCD'><ins id='TmoCD'></ins><ul id='TmoCD'></ul><sub id='TmoCD'></sub></form><legend id='TmoCD'></legend><bdo id='TmoCD'><pre id='TmoCD'><center id='TmoCD'></center></pre></bdo></b><th id='TmoCD'></th></span></q></dt></tr></i><div id='TmoCD'><tfoot id='TmoCD'></tfoot><dl id='TmoCD'><fieldset id='TmoCD'></fieldset></dl></div>
              <bdo id='TmoCD'></bdo><ul id='TmoCD'></ul>

              <legend id='TmoCD'><style id='TmoCD'><dir id='TmoCD'><q id='TmoCD'></q></dir></style></legend>

              1. <small id='TmoCD'></small><noframes id='TmoCD'>

                  <tbody id='TmoCD'></tbody>
              2. 本文介绍了Java GC:为什么有两个幸存者区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                对于 Sun/Oracle 的 JVM,我读到 GC 算法将新一代划分为一个 Eden 区域和两个幸存者区域.我想知道的是,为什么有两个幸存者区域而不仅仅是一个?该算法可以在伊甸园和一个幸存者区域之间保持乒乓球(就像它目前在两个幸存者区域之间所做的那样);或者这种方法有什么缺点吗?

                For Sun/Oracle's JVM, I've read that the GC algo divides new generation into one Eden region and two survivor regions. What I'm wondering about is, why two survivor regions and not just one? The algo can keep ping-ponging between Eden and just one survivor region (the way it currently does between two survivor regions); or are there any shortcomings to this approach?

                推荐答案

                我相信 JRockit 的 GC 实现更像你建议的那样,只有一个伊甸园和一个幸存者空间,但不要引用我的话.

                I believe JRockit's GC implementation works more like you suggest, with just a single eden and single survivor space, but don't quote me on that.

                HotSpot JVM 有两个幸存者空间的原因是为了减少处理碎片的需要.新对象分配在伊甸园空间中.一切都很好.当它满了时,你需要一个 GC,所以杀死陈旧的对象并将活的对象移动到幸存者空间,在那里它们可以成熟一段时间,然后再被提升到老年代.到目前为止还是不错的.但是,下次我们用完伊甸园空间时,我们遇到了一个难题.下一次 GC 出现并清除了 eden 和我们的幸存者空间中的一些空间,但这些空间并不连续.那么是不是更好

                The reason for the HotSpot JVM's two survivor spaces is to reduce the need to deal with fragmentation. New objects are allocated in eden space. All well and good. When that's full, you need a GC, so kill stale objects and move live ones to a survivor space, where they can mature for a while before being promoted to the old generation. Still good so far. The next time we run out of eden space, though, we have a conundrum. The next GC comes along and clears out some space in both eden and our survivor space, but the spaces aren't contiguous. So is it better to

                1. 尝试将来自伊甸园的幸存者放入已被 GC 清除的幸存者空间的孔中?
                2. 将幸存者空间中的所有对象向下移动以消除碎片,然后然后将幸存者移入其中?
                3. 只需说去死吧,无论如何我们都在移动所有东西",然后将两个空间中的所有幸存者复制到一个完全独立的空间(第二个幸存者空间)中,从而为您留下一个干净的伊甸园和幸存者空间在哪里可以在下一次 GC 上重复该序列?

                孙对这个问题的回答是显而易见的.

                Sun's answer to the question is obvious.

                这篇关于Java GC:为什么有两个幸存者区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:可终结对象如何至少需要 2 个垃圾回收周期才能被回收? 下一篇:弱引用有实际用途吗?

                相关文章

                  <legend id='dXhld'><style id='dXhld'><dir id='dXhld'><q id='dXhld'></q></dir></style></legend>
                1. <i id='dXhld'><tr id='dXhld'><dt id='dXhld'><q id='dXhld'><span id='dXhld'><b id='dXhld'><form id='dXhld'><ins id='dXhld'></ins><ul id='dXhld'></ul><sub id='dXhld'></sub></form><legend id='dXhld'></legend><bdo id='dXhld'><pre id='dXhld'><center id='dXhld'></center></pre></bdo></b><th id='dXhld'></th></span></q></dt></tr></i><div id='dXhld'><tfoot id='dXhld'></tfoot><dl id='dXhld'><fieldset id='dXhld'></fieldset></dl></div>

                  <small id='dXhld'></small><noframes id='dXhld'>

                  <tfoot id='dXhld'></tfoot>
                  • <bdo id='dXhld'></bdo><ul id='dXhld'></ul>