vouillon opened issue #15382:
Test Case
This script generates a module with N globals, each initialized with nested
array.new_fixed, then compiles it:#!/bin/bash n=${1:-4000} { echo '(module (type $block (array (mut (ref eq))))' echo '(global $g0 (ref $block) (array.new_fixed $block 1 (ref.i31 (i32.const 0))))' for i in $(seq 1 $n); do echo "(global \$g$i (ref \$block) (array.new_fixed \$block 3 (ref.i31 (i32.const $i)) (global.get \$g$((i-1))) (array.new_fixed \$block 2 (ref.i31 (i32.const 1)) (global.get \$g0))))" done echo ')'; } > globals$n.wat /usr/bin/time -f "%e s, %M KB max RSS" wasmtime compile -W=all-proposals=y globals$n.wat -o /dev/nullSteps to Reproduce
- Save the script above as
repro.sh.- Run
./repro.sh 1000,./repro.sh 2000and./repro.sh 4000.Expected Results
Memory use grows roughly linearly with the number of globals, as it does with Wasmtime 50.0.3.
Actual Results
Memory use appears to grow quadratically. With N = 4000, the process used more than 4 GB and was killed.
Max RSS:
N 50.0.3 52.0.0-dev (268d877f3) 1000 107 MB 358 MB 2000 192 MB 1.2 GB 4000 360 MB killed at 4 GB With N = 4000,
-C cranelift-regalloc_algorithm=single_passbrings the dev build back to 300 MB.Versions and Environment
Wasmtime version or commit: 52.0.0-dev (268d877f3). The problem appeared with 3ce220987 (Update regalloc2 to v0.15.3).
Operating system: Linux (Ubuntu on GitHub Actions, and locally)
Architecture: x86_64
Extra Info
We found this because the wasm_of_ocaml CI, which uses the Wasmtime
devbuild, started running out of memory while compiling test programs. OCaml constant data is stored in globals initialized with nestedarray.new_fixed, so a large program has thousands of these allocations.Wasmtime compiles all global initializers into a single module startup function, so this function gets very large. On one real program (the js_of_ocaml compiler built for WASI, 3.4 MB of Wasm), 50.0.3 uses 1.1 GB and the dev build goes past 8 GB.
The last
devbuild that worked in our CI was fba257416, and 3ce220987 is the only commit between it and the build that failed. I compared against 50.0.3 because earlier dev builds can no longer be downloaded. Issue #15363 reports a compile-time regression from the same commit.
vouillon added the bug label to Issue #15382.
Last updated: Nov 19 2026 at 20:05 UTC