]> Cypherpunks repositories - gostls13.git/commitdiff
misc/wasm: free up memory on exit
authorRichard Musiol <mail@richard-musiol.de>
Thu, 5 Jul 2018 13:32:31 +0000 (15:32 +0200)
committerRichard Musiol <neelance@gmail.com>
Wed, 11 Jul 2018 10:22:17 +0000 (10:22 +0000)
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: Paul Jolly <paul@myitcv.org.uk>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
misc/wasm/wasm_exec.js

index 565dc928bcba05a3bd7c2ee8709628e673b71d65..233c5aa1877a6b28916ba767527b160f3c60d161 100644 (file)
                                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)