Instructions for replicating crash in golang/go#42979. I am running on Windows...interpret the meaning of the commands (e.g. wget).
Download this gist's files and the following to a directory.
Get a simple web server into serve.go
:
wget https://gist.githubusercontent.com/paulmach/7271283/raw/2a1116ca15e34ee23ac5a3a87e2a626451424993/serve.go
Get wasm_exec.js
:
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js"
go run serve.go
Get a terminal ready for Wasm:
set GOOS=js
set GOARCH=wasm
Direct browser to server address (default: localhost:8100
). Build each of the files in the below table (with wasm_base.go
) sequentially via:
go build -o test.wasm wasm_base.go <filename>.go
On redirect, console will show:
Start Go Web Assembly
Sleeping 10 seconds...
Ending Go Web Assembly
While Go is sleeping, you can observe memory usage of the page. The sleep is not necessary for the large memory usage; it continues even after the main()
has exited.
Results for me are:
Filename | Page memory usage |
---|---|
loop_wasm.go | < 100 MB |
explicit_wasm_ko.go | > 12 GB |
explicit_wasm_better.go | ~ 2 GB |
explicit_wasm_ok.go | < 100 MB |