Stream: wasmtime

Topic: Component bindings - Determine # pages / memory used?


view this post on Zulip Adam Crain (Feb 10 2025 at 18:04):

Hi, I'm embedding wasmtime in my Rust app for a plugin architecture. I'm using WIT to define the contract (no WASI), just targeting wasm32-unknown-unknown.

I'm struggling to figure out how much memory / # pages my instantiated component is using in real-time. Since my application + component is long-lived, I'd like to track this to ensure I'm not leaking. Can someone point me in the right direction here? I have a leak in my application, and I'm trying to eliminate WASM as the source. I understand that WASM cannot return pages to the host, but am I understanding correctly that the memory allocator can reuse previously freed memory, right?

view this post on Zulip Alex Crichton (Feb 10 2025 at 18:06):

You're correct wasm can't free memory, and you can track memory with a ResourceLimiter implementation

view this post on Zulip Alex Crichton (Feb 10 2025 at 18:06):

(basically hook memory_growing and table_growing and add in values)

view this post on Zulip Adam Crain (Feb 10 2025 at 18:10):

Thanks @Alex Crichton ! I'll tack this onto the Store. Appreciate the tip.


Last updated: Feb 27 2025 at 22:03 UTC