Stream: git-wasmtime

Topic: wasmtime / issue #2273 Restrict memory usage


view this post on Zulip Wasmtime GitHub notifications bot (May 05 2022 at 16:47):

alexcrichton commented on issue #2273:

In addition to the resources already mentioned I believe that the current ResourceLimiter trait is another avenue to limiting memory of modules, so I'm going to close this.

view this post on Zulip Wasmtime GitHub notifications bot (May 05 2022 at 16:47):

alexcrichton closed issue #2273:

I wish to use wasmtime in a server to run small untrusted code blocks. I need to limit the maximum memory consumed by each running block to 5MB. I looked through the docs and found no way to restrict how much memory the VM can allocate. There seems to be a built-in limit of 4GB. See #1872 .

Let's support or document how to restrict memory usage.

view this post on Zulip Wasmtime GitHub notifications bot (May 25 2023 at 07:05):

huntc commented on issue #2273:

For completeness, another suggestion cited here: https://users.rust-lang.org/t/how-to-set-max-memory-limit-in-wasm/64725/10

The flags can also be declared in a .cargo/config.toml file so that a regular cargo build --target=wasm32-wasi command can be used:

[target.wasm32-wasi]
rustflags = ["-Clink-args=--initial-memory=2621440 --max-memory=2621440"]

Last updated: Dec 23 2024 at 12:05 UTC