What is the recommended way to free allocated memory? I'm allocating memory in my init block and I'm wondering if I can define a dealloc method to free it when the class is destroyed?
j
jw
06/19/2024, 9:54 PM
Make your constructor take a MemorySegment and make it the callers problem
jw
06/19/2024, 9:54 PM
If it's an external C API, you could make your type AutoCloseable and once again make it your callers problem
t
Trey
06/19/2024, 9:55 PM
Cool. Thanks for the advice!
l
Landry Norris
06/20/2024, 12:02 AM
There's also Cleaner for Kotlin/Native that will be called when the Kotlin object gets gc'ed.