Can someone explain me something? I am using Kotlin on iOS and trying to implement an MVP architecture. I use a
WeakReference
to hold a reference to a View object from Kotlin, to try and avoid memory leaks. But these objects do not seem to get deallocated immediately when they go out of scope. This is annoying for me as I use iOS
UIViewController
as the view object, and the expectation is that these will have
deinit
called as soon as they are dismissed.
I have tried the project
icerockdev/moko-mvvm
. In their iOS sample project
sample6
, the memory leak does not seem to occur, and the view has
deinit
invoked immediately. I have read the
moko-mvvm
source code and I think their implementation is the same as mine. I can’t understand this.