wasm-bindgen
wasm-bindgen copied to clipboard
Is it necessary to call `free()` for js class binding instances?
Summary
All js class bindings come with a free() method, which frees up the memory allocated for them when they are instantiated, let's say there is a loop on js which inside that class binding is instantiated, does some other stuff and just then WITHOUT calling free() we go to next iteration, would this cause memory leak and those instances on each iteration persist on memory?
or would they automatically end up in js gc and go out of scope themselves?
for (;;) {
const bindingClassInstance = new BindingClass();
// do something and NOT call free() on above instance
}
It will be automatically garbage collected at some point, as long as your JS runtime supports FinalizationRegistry.