首页 > TAG信息列表 > soft-references

Java,将对象转换为软引用

我需要将数据对象放入包含软引用的weakhashmap中.如何将“可绘制”对象转换为软引用? WeakHashMap <String, SoftReference<Drawable>> tempPulled = new WeakHashMap<String, SoftReference<Drawable>>(); Drawable pulled = BitmapDrawable.createFromResourceStream(null, n

有没有办法在GC确定无法访问时回收复杂的java对象

在C中,我使用引用计数对象来填充“自动”回收对象池 SmartPointer<ObjType> object = pool.getObject(); // hold reference // ... do stuff with object over time. object = nullptr; // that is when reference // count goes to 0 – 现在我在C对象上

java – 测试使用SoftReference的代码

要使用SoftReference< T>获取任何代码要经过充分测试,必须想出一些方法来测试“呀,它已经被淘汰”的情况.通过使用’for-test’代码路径强制引用为null,可能会或多或少地模仿这一点,但这不会像GC那样完全管理队列.我想知道是否有人可以分享建立可重复,受控制的环境的经验,其中GC实