• <small id='z683n'></small><noframes id='z683n'>

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

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

        垃圾收集的世代是什么?

        时间:2023-09-13

          <tbody id='luuIb'></tbody>
          <bdo id='luuIb'></bdo><ul id='luuIb'></ul>

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

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

                  本文介绍了垃圾收集的世代是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我不明白垃圾收集上下文中的世代"是什么.谁能简单的解释一下?

                  I don't understand what "generations" are in the context of Garbage Collection. Can someone explain in simple terms?

                  推荐答案

                  来自 了解 .NET 中的垃圾回收

                  世代

                  分代垃圾收集器多收集短命的对象经常比寿命更长的.短期对象存储在第一代,0代.寿命更长的物体被推入更高的世代,1 或 2.垃圾收集器工作更多经常在低代比更高的.

                  A generational garbage collector collects the short-lived objects more frequently than the longer lived ones. Short-lived objects are stored in the first generation, generation 0. The longer-lived objects are pushed into the higher generations, 1 or 2. The garbage collector works more frequently in the lower generations than in the higher ones.

                  当一个对象第一次被创建时,它是放入第 0 代.当第0代被填满,垃圾收集器被调用.那些对象在垃圾收集中幸存下来第一代被提升到下一代更高一代,第 1 代.在垃圾中幸存的对象第 1 代的收集是晋升到下一个和最高的一代,2代.这算法有效地适用于对象的垃圾收集,因为它很快.请注意,第 2 代是最高的一代由垃圾收集器支持.

                  When an object is first created, it is put into generation 0. When the generation 0 is filled up, the garbage collector is invoked. The objects that survive the garbage collection in the first generation are promoted onto the next higher generation, generation 1. The objects that survive garbage collection in generation 1 are promoted onto the next and the highest generation, generation 2. This algorithm works efficiently for garbage collection of objects, as it is fast. Note that generation 2 is the highest generation that is supported by the garbage collector.

                  .NET 中的垃圾收集

                  世代

                  内存分配时托管堆很快,GC本身可能需要一些时间.考虑到这一点进行了多项优化以提高性能.GC支持世代的概念,基于这样的假设一个对象在堆上的时间更长,它可能会停留的时间越长那里.当一个对象被分配到它属于第 0 代的堆.每个垃圾收集器对象生存增加其1代(目前最高支持的世代是 2).明显地搜索速度更快,并且垃圾收集所有的子集堆上的对象,所以 GC 有仅收集一代的选项0、1 或 2 个对象(或其他它选择的组合,直到它有足够的内存).即使在GC 只收集较年轻的对象还可以确定旧对象是否有对新对象的引用以确保它不会无意中忽略正在使用的对象.

                  While memory allocation on the managed heap is fast, GC itself may take some time. With this in mind several optimisations have been made to improve performance. The GC supports the concept of generations, based on the assumption that the longer an object has been on the heap, the longer it will probably stay there. When an object is allocated on the heap it belongs in generation 0. Each garbage collection that that object survives increases its generation by 1 (currently the highest supported generation is 2). Obviously it's faster to search through, and garbage collect a subset of all objects on the heap, so the GC has the option of collecting only generation 0, 1 or 2 objects (or whatever combination it chooses until it has sufficient memory). Even while collecting only younger objects the GC can also determine if old objects have references to new objects to ensure that it doesn't inadvertently ignore in-use objects.

                  这篇关于垃圾收集的世代是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为什么 C# 中没有引用计数 + 垃圾回收? 下一篇:Dispose() 方法中 GC.SuppressFinalize(this) 的目的是什么?

                  相关文章

                  1. <tfoot id='mY9p6'></tfoot>
                      <bdo id='mY9p6'></bdo><ul id='mY9p6'></ul>

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

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