-
Notifications
You must be signed in to change notification settings - Fork 328
Closed
Description
At the moment there is no way to shutdown the WASM runtime after it was started.
The following addition to the Emscripten module was insufficient to free the allocated memory:
/**
* Expose a way to shut down the PHP runtime
*/
Module["exitRuntime"] = function () {
exitRuntime();
const empty = new ArrayBuffer([]);
Module["HEAP8"].set(empty);
Module["HEAP16"].set(empty);
Module["HEAP32"].set(empty);
Module["HEAPU8"].set(empty);
Module["HEAPU16"].set(empty);
Module["HEAPU32"].set(empty);
Module["HEAPF32"].set(empty);
Module["HEAPF64"].set(empty);
updateGlobalBufferAndViews(empty);
Module["HEAP8"] = HEAP8 = null;
Module["HEAP16"] = HEAP16 = null;
Module["HEAP32"] = HEAP32 = null;
Module["HEAPU8"] = HEAPU8 = null;
Module["HEAPU16"] = HEAPU16 = null;
Module["HEAPU32"] = HEAPU32 = null;
Module["HEAPF32"] = HEAPF32 = null;
Module["HEAPF64"] = HEAPF64 = null;
wasmTable = null;
wasmMemory = null;
wasmBinary = null;
for (let key in Module["asm"]) {
Module["asm"][key] = null
}
for (let key in Module) {
if(key !== 'websocket') {
Module[key] = null
}
}
}
Playground uses workers on every platform and then shuts down the entire worker thread so this issue has a very low priority for now.