Hi, Am I understand correctly the memory managemen...
# kotlin-native
n
Hi, Am I understand correctly the memory management in K/N that everything I write in a common package will automatically be released if the code in objective c does not have references to objects created by kotlin?
k
there is a family of functions for allocating native objects to which this does not apply. otherwise there is no memory management required.
n
Thanks for the answer, is there documentation for all of these functions, or should I rely only on IDEA hints? 🙂
o
memory management of Objective-C and K/N objects is coordinated, pure K/N without interop have Java-like guarantees (all structures are OK), if cyclic graph goes via Objective-C - such reference will leak. There are no functions to allocate native objects, only to allocate raw memory in malloc-like fashion. Objective-C proxies of Kotlin ones and vice versa are created automatically.
n
Objects that created by this function cause memory leaks only on the IOS side, android is OK.
@olonho I'm using kotlin multiplatform project and I have some business logic in a common package. IOS application uses generated framework and call this logic, but we faced with memory leaks.
o
please file an issue, this code unlikely causes memory leak per se, as it is pure Kotlin
n
I'll make a reproducible app with a kotlin library to show the problem
s
Just FYI I have been experiencing memory leaks using a K/N framework in Swift as well
n
s
Have you encountered memory leak? The issue you referred doesn’t seem related.
n
Yes, the original problem was in memory leaks. The code above was my guess at a place where memory could leak. But the real problem was using MutableSet.