Leon Kiefer
07/29/2022, 5:12 PMAutofreeScope
and Arena
work? do they automatically free the allocated memory when they are garbage collected, or is there some other mean to ensure native memory is freed if a kotlin object is garbage collected? We are currently wrapping a native library with a common code api and can not expose native memory management in the common code api.Leon Kiefer
07/29/2022, 5:14 PMLandry Norris
07/29/2022, 5:20 PMArena
has a clear method. When you alloc
an object, the Arena adds the pointer to a linked list. When you call clear
, it loops through this linked list and frees each pointer.Landry Norris
07/29/2022, 5:20 PMLandry Norris
07/29/2022, 5:25 PMArkadii Ivanov
07/29/2022, 5:34 PMcleaner
to automatically clean when the holding object is garbage collected. Here is how I use it - https://github.com/arkivanov/MVIKotlin/blob/62fceaaab920c7ea2460ec82c22c99a35cf12b95/rx-internal/src/nativeMain/kotlin/com/arkivanov/mvikotlin/rx/internal/Lock.kt#L25Leon Kiefer
07/29/2022, 5:59 PMLeon Kiefer
07/29/2022, 6:02 PMLeon Kiefer
07/29/2022, 6:08 PMexpected
class PLMScope to wrap a native placement, so we can pass it into our common apiLandry Norris
07/29/2022, 6:08 PMLandry Norris
07/29/2022, 6:59 PM