Does Kotlin-native have any sort of `WeakReference...
# kotlin-native
s
Does Kotlin-native have any sort of
WeakReference
?
o
what is exact use case for weak references in your case?
s
I've created a dependency injection library for Kotlin that I've been porting to multi-platform. I use weak references to ensure that I don't create memory leaks.
I define injected types in an object with delegated properties, and later fill those delegated properties with dependencies when inject is called later on.
sometimes inject isn't called during the constructor invocation, but rather later on during an initial lifecycle. In such a case where the object isn't taken through a lifecycle, the injection wouldn't happen, and I'd have a memory leak.
o
OK, got it. Currently, we do not support weak references, but could consider implementing that, shall there be sufficient demand.