Wasm GC doesn't seem to collect garbage which results in GC heap out of memory
errors
#9701
Labels
bug
Incorrect behavior in the current implementation that needs fixing
wasm-proposal:gc
Issues with the implementation of the gc wasm proposal
Test Case
Running Kotlin-compiled Wasm guest requires Wasm GC proposal to be implemented by the runtime and Wasmtime now officially supports Wasm GC since version 27.0.0.
I'm embedding Wasmtime in Go (Wasmtime version in wasmtime-go updated to 27.0.0 locally) and running a benchmark that calls a simple guest function which makes small heap allocations. A minimal Kotlin guest function that reproduces the issue looks like this:
Running a benchmark which calls this this function from the host repeatedly results in
GC heap out of memory
error almost instantaneously. According to the discussion at #wamtime this might be caused by an issue with Wasm GC implementation in Wasmtime.Expected Results
Kotlin's
withScopedMemoryAllocator
is supposed to free all the memory allocated during the function call so this function shouldn't cause GC to run out of memory.Actual Results
Wasm guest execution fails with a
GC heap out of memory
error after several calls to the function.Versions and Environment
Wasmtime version or commit: 27.0.0
Operating system: macOS
Architecture: arm64
Extra Info
It would be great to have more details in the documentation on how Wasm GC works in Wasmtime. For example, Wasm GC uses it's own memory but I can't find any documentation on the default size of it or whether it can be configured.
Edit: actually,
MemoryAllocator
doesn't rely on Wasm GC and uses linear memory instead so probably theGC heap out of memory
error is not caused byallocator.allocate
calls but by all the allocations Kotlin does automatically which do use Wasm GC heap.The text was updated successfully, but these errors were encountered: