SoftRef
Instantiates a soft reference: a reference to a value that doesn't stop the garbage collector from collecting it.
The value may be accessed with WeakRef.read. However, it could disappear at any time.
When should you use a soft reference?
The runtime is encouraged to keep the value for as long as possible. For example, the runtime may decide to keep the value until memory pressure.
This makes this implementation ideal for writing caches, since the value will be kept longer than strictly necessary.
The exact behavior of the returned object is platform-specific.
See also
For implementing mappers
Implementation of WeakRef backed by a JS WeakRef.
JS doesn't make a difference between weak and soft references.
Implementation of WeakRef backed by a JVM SoftReference.
Implementation of WeakRef backed by a native WeakReference.
Kotlin Native doesn't make a difference between weak and soft references.