Clearly, the weak references are no longer working.
很明显,弱引用不再起作用。
Soft and weak references can be cleaned up when they are no longer referenced.
Soft和weak引用在引用不复存在时可被清除。
For example, it heavily relies on weak references for its data-binding technology.
比如说,WPF严重倚赖于弱引用来实现数据绑定技术。
The solution in this case is to change the links in the linked list to also be weak references.
在这种情况下,解决办法就是也将链接列表中的链接更改 为弱引用。
A previous article, "Plugging memory leaks with weak references," offers some helpful techniques.
以前的一篇文章“用弱引用堵住内存泄漏”给出了一些有用的技巧。
Notice how this method accounts for possible weak references in the queue with the do-while loop.
请注意该方法如何用do -while循环来处理队列中可能存在的弱引用。
One approach that is sometimes suggested for dealing with lapsed listeners is to use weak references.
有时推荐的一个处理失效侦听器的方法是使用弱引用。
As the following example shows, weak references and soft references are powerful tools for fixing memory leaks.
如以下示例所示,弱引用和软引用都是解决内存泄露的强大工具。
Use long weak references only when necessary as the state of the object is unpredictable after finalization.
仅在必要时使用长弱引用,因为在终止后对象的状态是不可预知的。
With weak references, you can maintain a reference to the referent without preventing it from being garbage collected.
使用弱引用后,可以维持对referent的引用,而不会阻止它被垃圾收集。
After adding the linkage to the list, the number of weak references cleared changes from a large number to none at all.
向列表中添加链接之后,被清除的弱引用的数量将从较大的数更改为完全没有。
The problem can be verified by plotting the weak references cleared in the GC and Memory Visualizer, as shown in Figure 17.
通过在EVTK中绘制被清除的弱引用的图,可以证实该问题,如图17所示。
Weak references have two constructors: one takes only the referent as an argument and the other also takes a reference queue.
弱引用有两个构造函数:一个只取referent作为参数,另一个还取引用队列作为参数。
Weak references form the basis of one such policy, but there are others, and which policy to use is based on circumstance.
弱引用构成了这样的一个策略的基础,但是还有其他一些机制,并且所要使用的策略取决于环境。
The implementation of WeakHashMap illustrates a common idiom with weak references — that some internal object extends WeakReference.
WeakHashMap的实现展示了弱引用的一种常见用法——一些内部对象扩展WeakReference。
Weak references tell the garbage collector that it should collect an object if there are no references to it other than the weak reference.
弱引用告诉垃圾收集器如果某个对象除了弱引用之外没有其他任何引用,则应该收集该对象。
These maps hold weak references to allow tracked objects like connections to be garbage collected when they are referenced only by the aspect.
这些图持有弱引用,允许连接这样的被跟踪对象在只有方面引用它们的时候,被垃圾收集掉。
Weak references are useful for objects that use a lot of memory, but can be recreated easily if they are reclaimed by garbage collection.
弱引用特别适合以下对象:占用大量内存,但通过垃圾回收功能回收以后很容易重新创建。
Weak references are sometimes mistakenly used instead of soft references for building caches, but this will result in poor caching performance.
弱引用有时会错误地用于取代软引用,用于构建缓存,但是这会导致差的缓存性能。
Since they seem to be a little-known feature, here is a brief overview of what weak references are, how to use them, and when to use them.
鉴于弱引用看起来似乎是一个鲜为人知的特性,这里简要介绍下什么是弱引用,该如何使用以及何时应该使用他们。
So the best advice with weak references is: profile or benchmark it, to make sure that you choose the best solution for your specific situation.
所以,对于弱引用的最好的建议是:概要描述或者用基准问题测试它,以确保你为特定的环境选择最好的方案。
Even when the actual objects are being released in a timely manner, WPF's arrays of weak references hang around and under stress become the memory leak.
哪怕及时释放掉了实际的对象,但WPF的弱引用数组还是会继续持有引用,这就导致了内存泄漏。
Soft references, like weak references, can help applications prevent object loitering by enlisting the aid of the garbage collector in making cache eviction decisions.
与弱引用一样,软引用通过利用垃圾收集器在作出缓存回收决策方面的帮助,有助于防止应用程序出现对象游离。
After working with obj after this if block, you should set obj to null to enable the garbage collector to reclaim this object to take full advantage of weak references.
在使用这个if块之后的obj之后,您应该将ob j设置为null,从而让垃圾收集器能够回收这个对象以充分利用弱引用。
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.
正如弱引用一样,软引用也可创建为具有一个相关的引用队列,引用在被垃圾收集器清除时进入队列。
Because this is such a common use for weak references, WeakHashMap, which USES weak references for keys (but not for values), was also added to the class library in JDK 1.2.
因为这是弱引用最常见的用法,WeakHashMap也被添加到JD k 1.2的类库中,它对键(而不是对值)使用弱引用。
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.
引用队列对于软引用来说,没有对弱引用那么有用,但是它们可以用于发出管理警报,说明应用程序开始缺少内存。
In the previous installment, we saw how weak references can provide an application with an alternate means of reaching an object while it is used by the program, but without prolonging its lifetime.
在前一期文章中我们看到了,弱引用如何可以给应用程序提供当对象被程序使用时另一种到达该对象的方法,但是不会延长对象的生命周期。
Weak, soft, and phantom references can improve the memory characteristics of your application by allowing flexible caching.
弱引用、软引用和虚引用允许灵活的缓存,能够改进应用程序的内存特性。
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.
而且,内存中的一个对象可以被多个引用(可以是强引用、软引用、弱引用或虚引用)引用。
应用推荐