Lulu
01/07/2020, 10:30 AMAtomicRef
(common version) leak memory like AtomicReference
(native version)? And if so, how to avoid memory leak given that I write code in common?natpryce
01/07/2020, 11:09 AMLulu
01/07/2020, 11:38 AMPrateek Grover
01/07/2020, 12:00 PMLulu
01/07/2020, 12:06 PMAtomicRef
is an object that contains a Long
(immutable) and an AtomicInt
. There won't be issues regarding the AtomicInt
right? (i.e. I can change it as normal)Prateek Grover
01/07/2020, 12:36 PMkpgalligan
01/07/2020, 2:27 PMLulu
01/07/2020, 3:12 PMPrateek Grover
01/08/2020, 3:56 AMkpgalligan
01/08/2020, 1:13 PMref.isFrozen
will return true. However, you can still change the value it holds. So, it’s “frozen” but “mutable”.Prateek Grover
01/08/2020, 1:13 PMkpgalligan
01/08/2020, 1:17 PMpublic class AtomicReference<T>(private var value_: T) {
// A spinlock to fix potential ARC race.
private var lock: Int = 0
kpgalligan
01/08/2020, 1:19 PMvalue_
and lock
kpgalligan
01/08/2020, 1:20 PMvoid Kotlin_AtomicReference_set(KRef thiz, KRef newValue) {
Kotlin_AtomicReference_checkIfFrozen(newValue);
AtomicReferenceLayout* ref = asAtomicReference(thiz);
SetHeapRefLocked(&ref->value_, newValue, &ref->lock_);
}
kpgalligan
01/08/2020, 1:20 PMPrateek Grover
01/08/2020, 1:21 PMPrateek Grover
01/08/2020, 1:23 PMkpgalligan
01/08/2020, 1:24 PMkpgalligan
01/08/2020, 1:25 PMkpgalligan
01/08/2020, 1:25 PMPrateek Grover
01/08/2020, 1:26 PM