Skip to content

Commit 6fe7b43

Browse files
neelanceRichard Musiol
authored and
Richard Musiol
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Paul Jolly <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 5e70b13 commit 6fe7b43

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

misc/wasm/wasm_exec.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,12 @@
177177
go: {
178178
// func wasmExit(code int32)
179179
"runtime.wasmExit": (sp) => {
180+
const code = mem().getInt32(sp + 8, true);
180181
this.exited = true;
181-
this.exit(mem().getInt32(sp + 8, true));
182+
delete this._inst;
183+
delete this._values;
184+
delete this._refs;
185+
this.exit(code);
182186
},
183187

184188
// func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)

0 commit comments

Comments
 (0)