-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
High virtual memory usage for each WebAssembly module #41319
Copy link
Copy link
Closed
Labels
memoryIssues and PRs related to the memory management or memory footprint.Issues and PRs related to the memory management or memory footprint.questionIssues that look for answers.Issues that look for answers.v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.wasmIssues and PRs related to WebAssembly.Issues and PRs related to WebAssembly.
Metadata
Metadata
Assignees
Labels
memoryIssues and PRs related to the memory management or memory footprint.Issues and PRs related to the memory management or memory footprint.questionIssues that look for answers.Issues that look for answers.v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.wasmIssues and PRs related to WebAssembly.Issues and PRs related to WebAssembly.
Version
17.3.0
Platform
Linux localhost.localdomain 5.15.7-1-default #1 SMP Wed Dec 8 08:54:39 UTC 2021 (b92986a) x86_64 x86_64 x86_64 GNU/Linux
Subsystem
WebAssembly
What steps will reproduce the bug?
When loading a simple WebAssembly program that instantiates linear memory, virtual memory usage is 10GB.
For example, the following
import.watConverted to wasm (import.wasm) and loaded as
The full code for this particular test is available at https://github.com/terminal69/wasm-worker-memory-test/tree/b8d58649e4576f156789bf05aeac15e9ae32af8c as test1d.js
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
There should not be a need to reserve 10 gb of memory upfront, especially since maximum memory in WebAssembly is 4 gb. This seems like a bug.
Also when the maximum size of memory is provided, then amount of memory reserved should be adjusted accordingly - although this may not be related to the current issue, and perhaps I should submit this as a feature request.
What do you see instead?
Additional information
Due to high virtual memory usage per module, the number of modules that can be loaded in the main thread or in worker threads is limited (piscinajs/piscina#158)