Wasm, 32bit, 4GB workarounds

TLDR: Are there any workarounds the 4GB wasm limit ?

Detailed: IIRC, wasm is 32-bit, limiting us to 4GB memory. Therefore Rust programs compiled to wasm are limited to 4GB runtime.

I am wondering if there are any techniques around this. In particular, to have a single browser tab run multiple "rust-wasm" processes. Each "rust-wasm" process is limited to 4GB, but they can talk to each other.

As far as I'm aware, 64 bit integers have yet to be standardized (or implemented? not sure) in wasm. As such, it's kind of inherently limited to 4 GB of memory.

I agree that a single 'rust wasm process' is probably limited to 4GB.

What I am wondering is: can we stuff more than one 'rust wasm process' (each with it's own wasm memory) in a single browser tab? [These 'processes' can communicate via zero-sharing message passing.]

You can start "web workers" in the browser. I have only ever started one worker, passing data to and fro my main code (in Javascript) but I see no reason one could not start many.

1 Like

64-bit integers have been around for quite a while. The 4 primitive types in WebAssembly are i32 (used for pointers), i64, f32, and f64.

The standard has left room for the possibility of multiple linear memories (and some runtimes have implemented it), but don't know if any compilers give you a way to access it.

This blog post from V8 also mentioned that there is work towards wasm64, a 64-bit WebAssembly.

1 Like

Must have been misremembering things, then. I haven't written wasm directly in so long it doesn't really matter to me (or most people), as you can simulate 64 bit integers on 32 but platforms anyways. Pretty much the only situation it would matter is having large amounts of memory, actually.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.