Last active
October 17, 2021 04:40
-
-
Save marty-suzuki/614c52faa9ea7d04fbc3262a3eb72dc4 to your computer and use it in GitHub Desktop.
An Adapter of Kotlin native GarbageCollector for iOS project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlin.native.internal.GC as internalGC | |
/** | |
* https://github.com/JetBrains/kotlin/blob/1.5.30/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/GC.kt | |
*/ | |
object GC { | |
var threshold: Int | |
get() = internalGC.threshold | |
set(value) { internalGC.threshold = value } | |
var collectCyclesThreshold: Long | |
get() = internalGC.collectCyclesThreshold | |
set(value) { internalGC.collectCyclesThreshold = value } | |
var thresholdAllocations: Long | |
get() = internalGC.thresholdAllocations | |
set(value) { internalGC.thresholdAllocations = value } | |
var autotune: Boolean | |
get() = internalGC.autotune | |
set(value) { internalGC.autotune = value } | |
// Causes Exception because no implementations | |
// new MM: https://github.com/JetBrains/kotlin/blob/1.5.30/kotlin-native/runtime/src/mm/cpp/Memory.cpp | |
// legacy MM: https://github.com/JetBrains/kotlin/blob/1.5.30/kotlin-native/runtime/src/legacymm/cpp/Memory.cpp | |
var cyclicCollectorEnabled: Boolean | |
get() = internalGC.cyclicCollectorEnabled | |
set(value) { internalGC.cyclicCollectorEnabled = value } | |
fun detectCycles(): Array<Any>? = internalGC.detectCycles() | |
fun collect() = internalGC.collect() | |
// Causes ThrowIllegalArgumentException | |
// new MM: https://github.com/JetBrains/kotlin/blob/1.5.30/kotlin-native/runtime/src/mm/cpp/Memory.cpp#L273-L276 | |
// legacy MM: https://github.com/JetBrains/kotlin/blob/1.5.30/kotlin-native/runtime/src/legacymm/cpp/Memory.cpp#L3470-L3477 | |
fun collectCyclic() = internalGC.collectCyclic() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment