Skip to content

Most visited

Recently visited

navigation
Added in API level 1

WeakReference

public class WeakReference
extends Reference<T>

java.lang.Object
   ↳ java.lang.ref.Reference<T>
     ↳ java.lang.ref.WeakReference<T>


Implements a weak reference, which is the middle of the three types of references. Once the garbage collector decides that an object obj is is weakly-reachable, the following happens:

Weak references are useful for mappings that should have their entries removed automatically once they are not referenced any more (from outside). The difference between a SoftReference and a WeakReference is the point of time at which the decision is made to clear and enqueue the reference:

Summary

Public constructors

WeakReference(T r)

Constructs a new weak reference to the given referent.

WeakReference(T r, ReferenceQueue<? super T> q)

Constructs a new weak reference to the given referent.

Inherited methods

From class java.lang.ref.Reference
From class java.lang.Object

Public constructors

WeakReference

Added in API level 1
WeakReference (T r)

Constructs a new weak reference to the given referent. The newly created reference is not registered with any reference queue.

Parameters
r T: the referent to track

WeakReference

Added in API level 1
WeakReference (T r, 
                ReferenceQueue<? super T> q)

Constructs a new weak reference to the given referent. The newly created reference is registered with the given reference queue.

Parameters
r T: the referent to track
q ReferenceQueue: the queue to register to the reference object with. A null value results in a weak reference that is not associated with any queue.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.