Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>@iirekm No: WeakReferences are 'weaker' than SoftReferences, meaning that a WeakReference will always be garbage collected before a SoftReference.</p> <p>More info in this post: <a href="https://stackoverflow.com/questions/3329691/understanding-javas-reference-classes-softreference-weakreference-and-phantom">Understanding Java&#39;s Reference classes: SoftReference, WeakReference, and PhantomReference</a></p> <p>Edit: (after reading comments) Yes surely Weak References are 'Weaker' than SoftReferences, typo. :S</p> <p>Here's some use cases to throw further light on the subject:</p> <ul> <li><strong>SoftReference</strong>: In-memory cache (Object stays alive until VM deems that there's not enough heap mem)</li> <li><strong>WeakReference</strong>: Auto-clearing Listeners (Object <em>should be</em> cleared on next GC cycle after deemed being Weakly reachable)</li> <li><strong>PhantomReference</strong>: Avoiding out-of-memory errors when handling unusually large objects (When scheduled in reference queue, we know that host object is <em>to be</em> cleared, safe to allocate another large object). Think of it as a finalize() alternative, without the ability to bring dead objects back to life (as you potentially could with finalize)</li> </ul> <p>This being said, nothing prevents the VM (please correct me if I'm wrong) to let the Weakly reachable objects stay alive as long as it is not running out of memory (as in the orig. author's case).</p> <p>This is the best resource I could find on the subject: <a href="http://www.pawlan.com/monica/articles/refobjs/" rel="nofollow noreferrer">http://www.pawlan.com/monica/articles/refobjs/</a></p> <p>Edit 2: Added "to be" in front of cleared in PhantomRef </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload