Fix garbage cycle collection for kotlin.Array

This commit is contained in:
Svyatoslav Scherbina
2018-06-04 15:34:35 +03:00
committed by SvyatoslavScherbina
parent b31590f545
commit 2934588bbe
5 changed files with 38 additions and 8 deletions
+4
View File
@@ -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)
}