1. <tfoot id='lRBDI'></tfoot>
      <legend id='lRBDI'><style id='lRBDI'><dir id='lRBDI'><q id='lRBDI'></q></dir></style></legend>

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

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

        Python GC 会处理这样的引用循环吗?

        时间:2023-07-05

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

          • <legend id='421OM'><style id='421OM'><dir id='421OM'><q id='421OM'></q></dir></style></legend>

              <small id='421OM'></small><noframes id='421OM'>

              <tfoot id='421OM'></tfoot>

                • 本文介绍了Python GC 会处理这样的引用循环吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用默认情况下是启用的,应该是能够释放该结构,如果它的任何组件都无法从外部访问 并且它们没有 __del__() 方法.

                  如果这样做,垃圾收集器将不会 释放它们 因为它无法确定运行这些 __del__() 方法的安全顺序.

                  Using objgraph, I found a bunch of objects like this:

                  Will Python's garbage collector deal with cycles like this, or will it leak?

                  A slightly wider view of the loop:

                  解决方案

                  Python's standard reference counting mechanism cannot free cycles, so the structure in your example would leak.

                  The supplemental garbage collection facility, however, is enabled by default and should be able to free that structure, if none of its components are reachable from the outside anymore and they do not have __del__() methods.

                  If they do, the garbage collector will not free them because it cannot determine a safe order to run these __del__() methods.

                  这篇关于Python GC 会处理这样的引用循环吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:python如何关闭已被gc'ed的文件? 下一篇:为什么 sys.getrefcount() 返回 2?

                  相关文章

                    <tfoot id='pqF4K'></tfoot>

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

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