I'm working on an issue to clean up all the memory from a webassembly app built with Emscripten. Some related questions without a suitable answer are here and here.
From my understanding, Webassembly memory can only be freed if all JS references to Wasm instance are set to undefined or fall out of scope. In some cases this is proving difficult due to reasons outside my control.
So, I'm wondering if it's possible to set, clear or reset the entire heap on a WebAssembly instance. In this case I no longer need it, it's litereally app cleanup and want to return memory to the browser.
I'm looking for something like this:
wasmInstance.buffer = undefined;
or
wasmInstance.buffer = new WebAssembly.Memory({ initial: 1});
I have tried
wasmInstance.HEAPF64 = undefined;
wasmInstance.HEAPF32 = undefined;
// ... etc
However this only clears the TypedArray views on the webassembly buffer (heap) not the buffer itself.