gggrafff opened issue #7594:
Hello!
Question:
I know how much memory will be needed when executing wasm code, can I somehow allocate the necessary amount of memory in advance to avoid allocations during execution?I write wasm in golang and compile with tinygo
What I tried:
- I'm compiling code with
--initial-memory
option but I want to set this in runtime before execution- I tried calling
memory.Grow()
manually, but it doesn't seem to have worked. GC seems to continue to think that the amount of memory is the same and makes an allocation. Did I understand correctly thatmemory.Grow()
is intended to be called only from wasm?- Compiling with the
--import-memory
parameter can help? How to properly run code compiled in this way? I didn't find any examples in the documentation.Thanks
alexcrichton commented on issue #7594:
This I think would typically be done through the WebAssembly module itself rather than the embedding API. For example WebAssembly memories list their minimum size and in this situation you'd ensure that the minimum size of memory was configured at the size you need. Wasmtime's allocation of linear memory then would reserve virtual memory for that and let it get lazily committed (at least on Linux, depends a bit on each OS).
Are you seeing behavior different though?
Last updated: Dec 23 2024 at 12:05 UTC