WeakReference

class WeakReference<T : Any>

Class WeakReference encapsulates weak reference to an object, which could be used to either retrieve a strong reference to an object, or return null, if object was already destroyed by the memory manager.

Constructors

WeakReference
Link copied to clipboard
fun <T : Any> WeakReference(referred: T)

Creates a weak reference object pointing to an object. Weak reference doesn't prevent removing object, and is nullified once object is collected.

Functions

clear
Link copied to clipboard
fun clear()

Clears reference to an object.

get
Link copied to clipboard
fun get(): T?

Returns either reference to an object or null, if it was collected.

Properties

value
Link copied to clipboard
val value: T?

Returns either reference to an object or null, if it was collected.