敬的世界

          常用鏈接

          統計

          最新評論

          weak reference

          A weak reference is one that does not prevent the referenced object from being garbage collected. You might use them to manage a HashMap to look up a cache of objects. A weak reference is a reference that does not keep the object it refers to alive. A weak reference is not counted as a reference in garbage collection. If the object is not referred to elsewhere as well, it will be garbage collected.

          The GC will send some sort of "finalize" message to the object and then set any weakly-referencing variables to null whenever it disposes of the referenced object. This allows "finalization" logic to be run before the object is disposed of (e.g., close a file if still open, commit any open transaction(s), etc.). Java 1.1 does not support weak references other than via an undocumented Ref class that is not supported under Netscape. Weak references arrived officially with JDK 1.2. Java has three kinds of weak references, called soft references, weak references, and phantom references, in order of increasing weakness.

          Java has four orders of strength in holding onto Objects. In descending order from strongest to weakest they are:

          1. The JVM holds onto regular Objects until they are no longer reachable by either clients or any container. In other words Objects are garbage collected when there are no more live references to them. Dead references don’t count.
          2. Soft references can be deleted from a container if the clients are no longer referencing them and memory is tight.
          3. Weak references are automatically deleted from a container as soon clients stop referencing them.
          4. Phantom references point to objects that are already dead and have been finalised.

          posted on 2009-05-17 00:12 picture talk 閱讀(264) 評論(0)  編輯  收藏 所屬分類: Java

          主站蜘蛛池模板: 磐石市| 咸宁市| 合肥市| 建湖县| 繁昌县| 山阳县| 隆林| 特克斯县| 大洼县| 博罗县| 泽库县| 成都市| 嘉鱼县| 祁东县| 靖边县| 泸水县| 广饶县| 二手房| 息烽县| 鹰潭市| 贵德县| 旌德县| 麟游县| 高淳县| 泾川县| 当涂县| 昭觉县| 彭阳县| 汕头市| 巴彦淖尔市| 木里| 海林市| 林州市| 庆阳市| 赤城县| 如东县| 正镶白旗| 嘉鱼县| 咸宁市| 含山县| 延吉市|