Another subclass of reference, soft references, fulfills a different but related purpose.
Reference的另一个子类——软引用——可满足一个不同却相关的目的。
Similarly, soft references are also often used in GUI applications for caching bitmap graphics.
类似地,软引用也经常用于GUI应用程序中,用于缓存位图图形。
When an object holds only soft references, GC collects it only if there is not enough memory.
当一个对象只具有软引用时,垃圾回收器只在内存不足的时候才回收它。
As the following example shows, weak references and soft references are powerful tools for fixing memory leaks.
如以下示例所示,弱引用和软引用都是解决内存泄露的强大工具。
Soft references are suitable for use only if the application can tolerate the loss of the softly referenced object.
只有当应用程序可以忍受大量软引用的对象时,软引用才适合使用。
Soft Reference . When an object holds only soft references, GC collects it only if there is not enough memory.
软引用 。当一个对象只具有软引用时,垃圾回收器只在内存不足的时候才回收它。
If you need to cache more than a single object, you might use a Map, but you have a choice as to how to employ soft references.
如果需要缓存不止一个对象,您可以使用一个Map,但是可以选择如何使用软引用。
Weak and soft references both extend the abstract reference class (as do phantom references, which will be discussed in a future article).
弱引用和软引用都扩展了抽象的reference类(虚引用(phantomreferences)也一样,这将在以后的文章中介绍)。
After processing the soft references, the set of weakly reachable objects is identified — objects for which no strong or soft references exist.
处理软引用之后,弱可及对象的集合被识别——这样的对象上不存在强引用或软引用。
Weak references are sometimes mistakenly used instead of soft references for building caches, but this will result in poor caching performance.
弱引用有时会错误地用于取代软引用,用于构建缓存,但是这会导致差的缓存性能。
After the trace, the collector identifies the softly reachable objects — these objects for which no strong references exist but soft references do.
在跟踪之后,垃圾收集器就识别软可及的对象——这些对象上除了软引用外,没有任何强引用。
Soft references, like weak references, can help applications prevent object loitering by enlisting the aid of the garbage collector in making cache eviction decisions.
与弱引用一样,软引用通过利用垃圾收集器在作出缓存回收决策方面的帮助,有助于防止应用程序出现对象游离。
Reference queues are not as useful with soft references as with weak references, but they could be used to raise a management alert that the application is starting to run low on memory.
引用队列对于软引用来说,没有对弱引用那么有用,但是它们可以用于发出管理警报,说明应用程序开始缺少内存。
The idea of a SoftReference is that you hold a reference to an object with the guarantee that all of your soft references will be cleared before the JVM reports an out-of-memory condition.
SoftReference的原理是:在保持对对象的引用时保证在JVM报告内存不足情况之前将清除所有的软引用。
The garbage collector then assesses whether soft references need to be cleared at this time, based on the amount of memory reclaimed by the current collection and other policy considerations.
垃圾收集器然后根据当前收集所回收的内存总量和其他策略考虑因素,判断软引用此时是否需要被清除。
Weak, soft, and phantom references can improve the memory characteristics of your application by allowing flexible caching.
弱引用、软引用和虚引用允许灵活的缓存,能够改进应用程序的内存特性。
Just as with weak references, a soft reference can be created with an associated reference queue, and the reference is enqueued when it is cleared by the garbage collector.
正如弱引用一样,软引用也可创建为具有一个相关的引用队列,引用在被垃圾收集器清除时进入队列。
Furthermore, an object in memory can be referenced by multiple references that could be strong, soft, weak, or phantom. Before proceeding further, let's look at some terminology.
而且,内存中的一个对象可以被多个引用(可以是强引用、软引用、弱引用或虚引用)引用。
Soft and weak references can be cleaned up when they are no longer referenced.
Soft和weak引用在引用不复存在时可被清除。
The research results can provide references to treatment of the soft subgrade of high-speed railways.
研究成果可为高速铁路软土路基处理提供参考。
The performance test demonstrates that the speed of soft PLC is much higher than that of common PLC. The further soft PLC application in open nc system can use this work for references.
对软plc的性能测试表明,软plc的执行速度较硬plc有了大幅度提高,为软plc在开放式数控系统中的应用提供了借鉴。
Objective To study the morphology of the soft palate in normal humans with digital radiography and to provide the references for therapy of the cleft.
目的通过数字化影像研究正常人软腭的形态,为腭裂整复提供参考。
The research results can provide some scientific guidelines and valuable references for construction and monitoring of soft rock tunnel projects.
该研究对软岩隧道施工、监测具有一定指导意义和参考价值。
The study method and conclusions can provide references to analyze the mechanical characters of lining in soft ground and establish a scientific and reasonable design method of tunnel.
研究方法和结论对分析软弱地层衬砌结构的受力特性、建立更加科学合理的隧道设计方法具有一定的参考价值。
The study method and conclusions can provide references to analyze the mechanical characters of lining in soft ground and establish a scientific and reasonable design method of tunnel.
研究方法和结论对分析软弱地层衬砌结构的受力特性、建立更加科学合理的隧道设计方法具有一定的参考价值。
应用推荐