cashapp / zipline

Run Kotlin/JS libraries in Kotlin/JVM and Kotlin/Native programs
Apache License 2.0
2.07k stars 158 forks source link

Detect unclosed ZiplineServices on iOS #559

Open swankjesse opened 2 years ago

swankjesse commented 2 years ago

We’ve already done it for JS and Android: https://github.com/cashapp/zipline/issues/302

For native it’s still a TODO: https://github.com/cashapp/zipline/blob/trunk/zipline/src/nativeMain/kotlin/app/cash/zipline/internal/bridge/leakCanaryNative.kt#L27

swankjesse commented 2 years ago

There’s a function called dealloc on iOS that can do it. Not sure if/how this is bridged to Kotlin/Native. https://developer.apple.com/documentation/objectivec/nsobject/1571947-dealloc

swankjesse commented 2 years ago

Discussed today. Decision is to try to use WeakReference. https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.native.ref/#:~:text=WeakReference