Repository navigation
Conversation
makePromise registered its executor with js.FuncOf and never released
it, so syscall/js kept every executor, the function it runs, and
whatever that function captured for the life of the page. For a conn's
write, that is a copy of every chunk written. In headless Chrome 155
on macOS, sending 256 MiB from the page in its usual 64 KiB writes
left its WebAssembly memory at about 450 MiB; with this change it
stays under 30 MiB.
The Promise constructor calls the executor once, before it returns,
so release it right after.
The new TestWriteFreesPayload builds only for js/wasm. It fails
without this change and passes with it:
GOOS=js GOARCH=wasm go test -exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec" ./web/
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The web demo keeps every chunk it sends in memory until the tab is closed.
makePromise never releases the js.Func it creates for the Promise executor, so syscall/js keeps it alive together with the bytes of each write. This change releases it right after the Promise is created.
TestWriteFreesPayload fails without the change and passes with it. It only builds for js/wasm, so CI and plain go test don't run it: