Files
2024-03-15 01:28:01 +00:00

19 lines
530 B
Kotlin
Vendored

// DISABLE_NATIVE: gcType=NOOP
import kotlin.test.*
import kotlin.native.ref.*
@OptIn(kotlin.native.runtime.NativeRuntimeApi::class, kotlin.experimental.ExperimentalNativeApi::class)
@Test fun runTest() {
val weakRefToTrashCycle = createLoop()
kotlin.native.runtime.GC.collect()
assertNull(weakRefToTrashCycle.get())
}
@OptIn(kotlin.experimental.ExperimentalNativeApi::class)
private fun createLoop(): WeakReference<Any> {
val loop = Array<Any?>(1, { null })
loop[0] = loop
return WeakReference(loop)
}