WeakReference

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.

Since Kotlin

1.3

Constructors

Link copied to clipboard
constructor(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.

Properties

Link copied to clipboard
val value: T?

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

Since Kotlin 1.3

Functions

Link copied to clipboard
fun clear()

Clears reference to an object.

Since Kotlin 1.3
Link copied to clipboard
fun get(): T?

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

Since Kotlin 1.3