Dmitry Motyl
06/21/2019, 9:31 AMkpgalligan
06/21/2019, 9:34 AMDmitry Motyl
06/21/2019, 10:11 AMkpgalligan
06/21/2019, 10:17 AMDmitry Motyl
06/21/2019, 10:21 AMkpgalligan
06/21/2019, 10:23 AMDmitry Motyl
06/21/2019, 10:26 AMKotlin/Native provides an automated memory management scheme, similar to what Java or Swift provides. The current implementation includes an automated reference counter with a cycle collector to collect cyclical garbage.
I thought that reference counter
must clear memorykpgalligan
06/21/2019, 10:28 AMDmitry Motyl
06/21/2019, 10:36 AMkpgalligan
06/21/2019, 10:36 AMDmitry Motyl
06/21/2019, 10:37 AMkpgalligan
06/21/2019, 10:37 AMDmitry Motyl
06/21/2019, 10:40 AMkpgalligan
06/21/2019, 10:48 AMDmitry Motyl
06/21/2019, 10:50 AMkpgalligan
06/21/2019, 10:51 AMDmitry Motyl
06/21/2019, 10:55 AMkpgalligan
06/21/2019, 10:58 AMDmitry Motyl
06/21/2019, 11:05 AMvar kotlinClass = KotlinClass()
for _ in 1...1000 {
autoreleasepool {
kotlinClass = KotlinClass()
}
}
class KotlinClass {
fun foo() {
}
}
kpgalligan
06/21/2019, 11:06 AMDmitry Motyl
06/21/2019, 11:08 AMautoreleasepool {
var kotlinClass = KotlinClass()
for _ in 1...1000 {
kotlinClass = KotlinClass()
}
print(kotlinClass)
}
kpgalligan
06/21/2019, 11:12 AMDmitry Motyl
06/21/2019, 11:23 AMkpgalligan
06/21/2019, 11:32 AMDmitry Motyl
06/21/2019, 11:53 AMkpgalligan
06/21/2019, 11:55 AMDmitry Motyl
06/21/2019, 12:00 PMKotlin/Native provides an automated memory management scheme, similar to what Java or Swift provides.
kpgalligan
06/21/2019, 12:02 PMolonho
06/23/2019, 8:20 AMsvyatoslav.scherbina
06/23/2019, 8:53 AMautoreleasepool
shouldn’t be required in this particular case.
This behaviour is likely caused by deferred reference counting implemented in 1.3.40.
Add kotlin.native.internal.GC.collect()
call to process the objects to be released.olonho
06/23/2019, 9:03 AMsvyatoslav.scherbina
06/23/2019, 9:16 AMGC.collect
is not required for your application to work properly, because K/N memory manager invokes it automatically after the threshold has been reached.