#ffi memory management (destructor with gc)
1 messages · Page 1 of 1 (latest)
preferably you should do manual freeing when possible to not put pressure on gc and memory
but if that’s not possible then you can use https://mdn.io/FinalizationRegistry to interact with gc
gc is not aware of how much memory your ptr is worth so it might put off doing garbage collection for very long time
one way to fix that is to allocate memory on javascript side and give the pointer to c
but you have to keep reference to that slice somewhere or it will become dangling pointer