@Yandros , @sfackler : Yes, I was going to make the same comment. I read the doc a few time, and the only thing I got out of it was: due to isize offset, a single Vec/Box can't be more than 2^31, but I don't see how to prove the entire heap is only 2^31.
IIRC, there was some reason the heap was "split" in wasm? Either code vs data (which would be kind of silly since code generally isn't 2GB) or some other reason.
If your pointers are 32-bit signed integers then I would assume the highest address you can reach is 2^31.
As far as I am aware, the multi-memory proposal hasn't been merged yet, so you can't increase your available memory by saying "pointer A should use memory block 1 and pointer B should use memory block 2".
In the current version of WebAssembly, at most one memory may be defined or imported in a single module, and all constructs implicitly reference this memory 0. This restriction may be lifted in future versions.
(although I notice the wasmtime VM has an experimental flag that enables it)
There is also the requirement that linear memory is one backed by contiguous block of memory.
I'd try to modify the program so it doesn't require 2+ GB of memory at any one time (e.g. by processing inputs in smaller chunks). I'm assuming you've already tried this though or that there might be domain-specific reasons why you need more memory, so this suggestion is probably not helpful.
Where do you get the assumption that pointers are 32-bit SIGNED integers ?
From the above docs, all I see is that: offsets (within a single object) are 32-bit SIGNED integers, which caps Vec/Box to 2^31 bytes.
Right now, I'm just shoving data in ArrayBuffer , and loading them into wasm as needed. What I meant to ask in the question was if there were any other techniques, besides js_sys::ArrayBuffer / web_worker that might be useful in this situation. (I.e. other JS/wasm APIs I should learn about).
You can use the wasm64-unknown-unknown target instead. AFAIK it is still experimental in rustc though. I believe browser support is also still experimental if existent at all.
I believe chrome used to be limited to 2GB for internal reasons, but now allows the full 4GB.