-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Respect the WASM_MEM_MAX limit in memory growth #6937
Conversation
src/preamble.js
Outdated
@@ -1027,6 +1027,20 @@ function enlargeMemory() { | |||
} | |||
} | |||
|
|||
#if WASM_MEM_MAX != -1 | |||
// A limit was set for how much we can grow. We should not exceed that | |||
// (the wasm binary specifies it, so if we tried, we'd fail anyhow). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand why this is necessary. If WASM_MEM_MAX causes the binary to set the limit, then reallocBuffer
should fail and we'd fail down on line 1051? But from the linked issue it looks like we are not, so maybe something else is wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, maybe this should be explained better. The issue is if we are 64MB and the max is 100MB, then we normally double the size - so we'd try to 64->128MB, which fails. Instead, with this PR, we'll try for 64->100MB, which might work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, LGTM
If the user specified a limit, it is set in the wasm binary, and we can't (and shouldn't) grow past it.
Also the docs in settings.js about this were wrong.
See #6042 (comment)