Fix garbage cycle collection for kotlin.Array
This commit is contained in:
committed by
SvyatoslavScherbina
parent
b31590f545
commit
2934588bbe
@@ -2117,6 +2117,10 @@ task memory_cycles0(type: RunKonanTest) {
|
||||
source = "runtime/memory/cycles0.kt"
|
||||
}
|
||||
|
||||
task memory_cycles1(type: RunKonanTest) {
|
||||
source = "runtime/memory/cycles1.kt"
|
||||
}
|
||||
|
||||
task memory_basic0(type: RunKonanTest) {
|
||||
source = "runtime/memory/basic0.kt"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package runtime.memory.cycles1
|
||||
|
||||
import kotlin.test.*
|
||||
import konan.ref.*
|
||||
|
||||
@Test fun runTest() {
|
||||
val weakRefToTrashCycle = createLoop()
|
||||
konan.internal.GC.collect()
|
||||
assertNull(weakRefToTrashCycle.get())
|
||||
}
|
||||
|
||||
private fun createLoop(): WeakReference<Any> {
|
||||
val loop = Array<Any?>(1, { null })
|
||||
loop[0] = loop
|
||||
|
||||
return WeakReference(loop)
|
||||
}
|
||||
Reference in New Issue
Block a user