@@ -185,15 +185,26 @@ run_tests() {
185185 # 2. async-stack-size (64MB): Stack for async operations. MUST be larger than
186186 # max-wasm-stack. XCTest uses async/await extensively, and swift_task_switch
187187 # operations during test execution and teardown require adequate async stack.
188- # 3. max-memory-size (1GB): Linear memory limit for heap allocations.
188+ # 3. max-memory-size (4GB): Linear memory limit for heap allocations. Set high
189+ # to allow Swift runtime metadata tables to grow as needed.
190+ # 4. pooling-allocator=n: Disable pooling allocator which has separate memory
191+ # limits that can conflict with -W max-memory-size settings.
192+ # 5. memory-reservation (4GB): Reserve enough virtual memory upfront to avoid
193+ # memory remapping issues that can cause Swift runtime metadata corruption.
194+ # 6. memory-may-move=n: Prevent linear memory from being moved in host address
195+ # space. This is critical for Swift runtime which caches pointers to metadata.
189196 WASMTIME_FLAGS=" --dir ."
197+ WASMTIME_FLAGS=" $WASMTIME_FLAGS -O pooling-allocator=n"
198+ WASMTIME_FLAGS=" $WASMTIME_FLAGS -O memory-reservation=4294967296"
199+ WASMTIME_FLAGS=" $WASMTIME_FLAGS -O memory-may-move=n"
190200 WASMTIME_FLAGS=" $WASMTIME_FLAGS -W max-wasm-stack=33554432"
191201 WASMTIME_FLAGS=" $WASMTIME_FLAGS -W async-stack-size=67108864"
192- WASMTIME_FLAGS=" $WASMTIME_FLAGS -W max-memory-size=1073741824 "
202+ WASMTIME_FLAGS=" $WASMTIME_FLAGS -W max-memory-size=4294967296 "
193203 if echo " $SWIFT_SDK_NAME " | grep -q " threads" ; then
194204 WASMTIME_FLAGS=" $WASMTIME_FLAGS --wasm threads=y --wasi threads=y"
195205 fi
196206
207+ echo " 🔧 Wasmtime flags: $WASMTIME_FLAGS "
197208 wasmtime run $WASMTIME_FLAGS " $TEST_BINARY "
198209 echo " "
199210}
0 commit comments