fix(wasm): bound retained guest memory for warm synchronous workers - #542
Merged
Conversation
skhaz
force-pushed
the
investigate/runtime-memory-growth-20260731
branch
2 times, most recently
from
July 31, 2026 16:52
51440f4 to
14b30b3
Compare
wolfy-j
force-pushed
the
investigate/runtime-memory-growth-20260731
branch
from
August 1, 2026 22:17
14b30b3 to
e129795
Compare
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.
Problem
Warm synchronous WASM workers reuse one guest instance. Linear memory only grows, so an omitted recycling limit retains the worker high-water mark indefinitely. The existing per-function
limits.max_retained_memory_bytesguard was opt-in and therefore did not protect default configurations.Change
limits.max_retained_memory_bytesnow uses a 64 MiB per-worker recycling trigger0remains unlimited and survives JSON/YAML decode and encoderetained_memory_check_intervalcan override the sampling intervalInstance.HasMemoryprimitive added in fix(runtime): expose safe instance memory presence wasm-runtime#14There is no application-wide
wasm.limitsconfiguration and no new process-level policy. Aggregate pool/process memory budgets remain a separate concern.Repro
On
main, a one-page WAT guest growing two pages per call reached 4,001 pages after 2,000 calls and retained about 332 MiB of Go heap after GC. The existing explicit 1 MiB trigger kept the same workload at 17 pages and about 9 MiB after GC. This change makes the bounded behavior the default while preserving an explicit unlimited setting.Verification
make test-runtimepasses with the race detectormake lintpasses with 0 issuesThe branch is rebased on current
mainand squashed to one commit.