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
olonho
10/03/2017, 2:29 PM
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