tage64 opened issue #12445:
In the function
MallocMemory::new()(in the file/crates/wasmtime/src/runtime/vm/memory/malloc.rs), we allocateminimum + tunables.memory_reservation_for_growthbytes. I was working in a bare metal context and therefore didn't have access to virtual memory. An error message kindly told me that "malloc memory is only compatible with no ahead-of-time memory reservation". This led me to setconfig.memory_reservation(0). But thenmemory_reservation_for_growthstill defaulted to 2 GiB causing theMallocMemoryto allocate more than 2 GiB of memory. This time I didn't get a helpful error message but an allocation failure without further context.Is there a reason why we even use the
memory_reservation_for_growthoption in theMallocMemory? Otherwise I propose that we either ignore it or throw an error if it is greater than 0.Wasmtime version: 41.0.0
alexcrichton commented on issue #12445:
This knob is used to amortize the cost of growth of a memory because without it all wasm growth would require reallocating the memory and moving it around. In that sense it's an intentional knob that is indeed used, but improving error messages for allocation failures is always reasonable.
Are you unable to set this configuration option to 0? Or are you interested in having it default to 0 for your target so you don't have to configure it?
tage64 commented on issue #12445:
I was indeed able to set
memory_reservation_for_growthto 0. The problem was to find out that was the cause of my allocation failure. I am working on a risc-v 64-bit platform so it defaulted to 2 GiB which was a lot more than available. I don't know of the best solution. The problem is just the confusing error which doesn't direct the user to this configuration.
alexcrichton commented on issue #12445:
I've expanded the error contexts in https://github.com/bytecodealliance/wasmtime/pull/12468 to try to help make the error here more clear.
pchickey closed issue #12445:
In the function
MallocMemory::new()(in the file/crates/wasmtime/src/runtime/vm/memory/malloc.rs), we allocateminimum + tunables.memory_reservation_for_growthbytes. I was working in a bare metal context and therefore didn't have access to virtual memory. An error message kindly told me that "malloc memory is only compatible with no ahead-of-time memory reservation". This led me to setconfig.memory_reservation(0). But thenmemory_reservation_for_growthstill defaulted to 2 GiB causing theMallocMemoryto allocate more than 2 GiB of memory. This time I didn't get a helpful error message but an allocation failure without further context.Is there a reason why we even use the
memory_reservation_for_growthoption in theMallocMemory? Otherwise I propose that we either ignore it or throw an error if it is greater than 0.Wasmtime version: 41.0.0
Last updated: Feb 24 2026 at 05:28 UTC