Commit 6fe7b434 authored by Richard Musiol's avatar Richard Musiol Committed by Richard Musiol

misc/wasm: free up memory on exit

Private fields of the Go class are not used any more after the program
has exited. Delete them to allow JavaScript's garbage collection to
clean up the WebAssembly instance.

Updates #26193.

Change-Id: I349784a49eaad0c22ceedd4f859df97132775537
Reviewed-on: https://go-review.googlesource.com/122296
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarPaul Jolly <paul@myitcv.org.uk>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 5e70b132
......@@ -177,8 +177,12 @@
go: {
// func wasmExit(code int32)
"runtime.wasmExit": (sp) => {
const code = mem().getInt32(sp + 8, true);
this.exited = true;
this.exit(mem().getInt32(sp + 8, true));
delete this._inst;
delete this._values;
delete this._refs;
this.exit(code);
},
// func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment