[英]java store objects that may be garbage collected
In Java, I recall there is a way to store objects in a usable format that may be garbage collected. 我记得在Java中,有一种方法可以以可用格式存储对象,这些对象可能会被垃圾收集。 It is some sort of loose reference.
这是一些宽松的参考。 If they get garbage collected there is a way to detect and reload.
如果他们收集了垃圾,则有一种方法可以检测并重新加载。
I'm having a hard time finding this. 我很难找到这个。 There is so much information about GC in general.
通常,有关GC的信息太多。 Anyone know the name?
有人知道这个名字吗?
我相信您正在寻找WeakReference
您正在考虑弱引用。
I think you're looking for the *Reference
classes in java.lang.ref
. 我认为您正在寻找
java.lang.ref
的*Reference
类。 The ReferenceQueue
class allows you to be notified when a reference is collected. ReferenceQueue
类使您可以在收集引用时得到通知。
You might also find FinalizableReference from Google Guava useful. 您可能还会发现FinalizableReference从谷歌番石榴有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.