https://kotlinlang.org logo
#kotlin-native
Title
# kotlin-native
t

Trey

08/03/2022, 7:34 PM
Can somebody point me to some documentation on how to use the Arena class? I can only find one mention of it in the docs here. https://kotlinlang.org/docs/mapping-struct-union-types-from-c.html#create-struct-and-union-as-cvaluesref-lt-t-gt I would like to understand the difference between it and using nativeHeap.
l

Landry Norris

08/03/2022, 7:57 PM
The main difference is that Arena keeps track of everything you allocate with it. You can call Arena#close() to free everything it’s allocated. If using nativeHeap, you need to free everything individually.
Arena is useful when several structs have the same lifetime, since you can free them all at once.
2 Views