GC You Later, Allocator
summary
A Kotlin Multiplatform sample app leaks a listener each time a dialog opens, creating 6 leaked NearbyGatorsContent instances that are trivial to find in Android Studio + LeakCanary + YourKit but still present in Xcode until addressed. The root cause is a cross-language retain cycle between Kotlin native and Swift reference counting; fixing on Android by removing the listener works, while on iOS the solution is to extract the listener and break the cycle with a weak listener and use Xcode malloc stack logging to get allocation sites.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 3:15Alligator-themed app demo
- 7:11Logical vs physical memory
- 11:26Allocators bridge memory
- 14:56GC vs reference counting
- 18:57Memory leaks in apps
- 21:05Finding leaks with Profiler
- 22:50Xcode memory tips
- 27:43Command-line memory tools
- 28:47Fixing leaks with tools
- 30:35Kotlin Multiplatform leaks
- 33:47Retain cycles in Kotlin Native
- 36:00Preventing memory leaks
- 39:53Summary and Valhalla bonus
related talks
42mSpeaking of Leaking
24mUnveiling the Unseen Threat: Demystifying Memory Leaks in Android
34mMemory Leaks & Performance Considerations: A Cookbook
49mPokeLeaks: Gotta Catch 'em All
33mNuking Nasty Memory Leaks
31mA Small Leak Can Sink A Great Ship
47mLeakCanary, and Then? Unraveling Android Memory Leaks
37mLeakCanary, then what? Nuking Nasty Memory Leaks
