SoftReferenceT


SoftReference<T> java.lang.ref

Java 1.2

This class represents a soft reference to an object. A SoftReference is not cleared while there are any remaining hard (direct) references to the referent. Once the referent is no longer in use (i.e., there are no remaining hard references to it), the garbage collector may clear the SoftReference to the referent at any time. However, the garbage collector does not clear a SoftReference until it determines that system memory is running low. In particular, the Java VM never throws an OutOfMemoryError without first clearing all soft references and reclaiming the memory of the referents . The VM may (but is not required to) clear soft references according to a least-recently-used ordering.

If a SoftReference has an associated ReferenceQueue , the garbage collector enqueues the SoftReference at some time after it clears the reference.

SoftReference is particularly useful for implementing object-caching systems that do not have a fixed size , but grow and shrink as available memory allows.

Figure 10-89. java.lang.ref.SoftReference<T>

 public class  SoftReference<T>  extends Reference<T> {  // Public Constructors  public  SoftReference  (T  referent  );        public  SoftReference  (T  referent  , ReferenceQueue<? super T>  q  );  // Public Methods Overriding Reference  public T  get  ( );   } 



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net