Hi, I just started to develop a (toy) wrapper for ...
# kotlin-native
f
Hi, I just started to develop a (toy) wrapper for ArrayFire to see how far I can get. I am new to kotlin native and got into trouble with the memory management. ArrayFire has its own reference counting and I do need to call a hook if a wrapper class instance gets freed. I have seen some solutions with an RAII like approach but I would like to try something like a destructor / finalizer. Sorry If i missed something in the examples or the docs but I did not find a solution yet. Any Ideas how I could approach this?
o
we do not support general purpose destructors, while for special cases like integration with ObjC reference counter there's custom code. Suggested solution for your case is not rely on Kotlin object lifetimes, and instead use inline functions, like I described here: https://stackoverflow.com/questions/44747862/does-kotlin-native-have-destructors
t
What about the finalizers that were added a while back, could they be used for something like this? (And what should they be used for otherwise?) https://github.com/JetBrains/kotlin-native/commit/9402a9c6a2bb14fa79be42a07ed84b92ae526251