Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin/Native Garbage collection on iOS and Android

I need to develop a multiplatform module in Kotlin Native for iOS and Android. According to kotlinlang documentation:

Objective-C and Swift use reference counting. Kotlin/Native has it's own garbage collection too. Kotlin/Native garbage collection is integrated with Objective-C/Swift reference counting.

Does it mean that Kotlin/Native compiled for iOS does not use CMS (Concurrent Mark Sweep) and uses ARC(Automatic Reference Counting)?

Is it possible that common module which written in Kotlin and compiled for iOS might leak and the same module compiled for Android might be completely fine?

like image 252
Kirk_hehe Avatar asked Dec 07 '25 06:12

Kirk_hehe


1 Answers

Kotlin/Native does not use Concurrent Mark-Sweep garbage collector even on Android. It uses an automated reference counter with a cycle collector to collect cyclical garbage (https://github.com/JetBrains/kotlin-native/blob/master/FAQ.md). So should behave more-or-less same way on both platforms.

like image 160
Anton Malyshev Avatar answered Dec 08 '25 18:12

Anton Malyshev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!