WeakRef

actual external class WeakRef<T : Any>(element: T)

js actual: the native JS WeakRef (object identity, true weak semantics).

actual class WeakRef<T : Any>(element: T)

wasm actual: a JS WeakRef can't reliably hold a Kotlin/Wasm heap object — it must be boxed in a JsReference whose box has no strong holder, so the WeakRef can clear while the boxed object is still in use (premature symbol-cache eviction → re-rasterization). The sole consumer is the bounded MIL-STD-2525 symbol cache, so retain strongly: bounded memory, no premature eviction.

expect class WeakRef<T : Any>(element: T)

A weak reference used by the MIL-STD-2525 symbol cache so unused earth.worldwind.shape.PlacemarkAttributes bundles can be reclaimed. js uses a native JS WeakRef; wasm retains strongly (a JS WeakRef can't reliably hold a Kotlin/Wasm heap object — see the wasm actual), which is sound because the cache is bounded to the finite set of MIL-STD symbol codes.

Constructors

Link copied to clipboard
actual constructor(element: T)
actual constructor(element: T)
expect constructor(element: T)

Functions

Link copied to clipboard
actual fun deref(): T?
actual fun deref(): T?
expect fun deref(): T?