Hello! Can I malloc some memory that will free wit...
# kotlin-native
c
Hello! Can I malloc some memory that will free with my object where I was malloc memory? or If I wrote something like
class Buffer(val capacity:Int){private val mem = ByteArray(capacity); val ptr = mem.refTo(0);}
variable
ptr
will be stable? Can I use value of
ptr
during all object life cycle?
Also what happend if I will call
pin
in init block on my instance of ByteArray and never call
unpin()
d
If you never call unpin I'm fairly certain garbage collection won't happen.
ptr
is stable to use in Kotlin but won't be stable when passed to the native side. It must be pinned for that.