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

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

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

        弱引用有实际用途吗?

        时间:2023-07-12
        <i id='lgPin'><tr id='lgPin'><dt id='lgPin'><q id='lgPin'><span id='lgPin'><b id='lgPin'><form id='lgPin'><ins id='lgPin'></ins><ul id='lgPin'></ul><sub id='lgPin'></sub></form><legend id='lgPin'></legend><bdo id='lgPin'><pre id='lgPin'><center id='lgPin'></center></pre></bdo></b><th id='lgPin'></th></span></q></dt></tr></i><div id='lgPin'><tfoot id='lgPin'></tfoot><dl id='lgPin'><fieldset id='lgPin'></fieldset></dl></div>

                <tbody id='lgPin'></tbody>

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

              <tfoot id='lgPin'></tfoot>

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

                • <bdo id='lgPin'></bdo><ul id='lgPin'></ul>

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

                  问题描述

                  可能重复:
                  弱引用 - 它们有多大用处?

                  既然垃圾收集器可以随时声明弱引用,那么使用它们有什么实际理由吗?

                  Since weak references can be claimed by the garbage collector at any time, is there any practical reason for using them?

                  推荐答案

                  如果你想保留对某个东西的引用,只要它在其他地方使用,例如一个监听器,你可以使用弱引用.

                  If you want to keep a reference to something as long as it is used elsewhere e.g. a Listener, you can use a weak reference.

                  WeakHashMap 可用作派生数据的键的短暂缓存.它还可以用于保存有关在其他地方使用的对象的信息,并且您不知道这些对象何时被丢弃.

                  WeakHashMap can be used as a short lived cache of keys to derived data. It can also be used to keep information about objects used else where and you don't know when those objects are discarded.

                  顺便说一句,软引用类似于弱引用,但它们并不总是会立即被清除.GC 总是会在可能的情况下丢弃弱引用,并在可能的情况下保留软引用.

                  BTW Soft References are like Weak references, but they will not always be cleaned up immediately. The GC will always discard weak references when it can and retain Soft References when it can.

                  还有另一种引用,称为幻影引用.这在 GC 清理过程中使用,指的是正常"代码无法访问的对象,因为它正在清理过程中.

                  There is another kind of reference called a Phantom Reference. This is used in the GC clean up process and refers to an object which isn't accessible to "normal" code because its in the process of being cleaned up.

                  这篇关于弱引用有实际用途吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Java GC:为什么有两个幸存者区域? 下一篇:是否有针对 GC 问题的食谱指南?

                  相关文章

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

                        <bdo id='5gnT7'></bdo><ul id='5gnT7'></ul>

                    1. <small id='5gnT7'></small><noframes id='5gnT7'>

                      <legend id='5gnT7'><style id='5gnT7'><dir id='5gnT7'><q id='5gnT7'></q></dir></style></legend>