WASM Memory
WASM Memory is the linear-memory object of a WebAssembly module, a contiguous addressable byte array through which WASM code reads and writes data.
Purpose
To provide heap memory for WASM code with C-style pointer addressing; the bridge for data exchange between WASM and JS.
Mechanism
new WebAssembly.Memory({initial, maximum}) creates linear memory; grow() expands it and the buffer property exposes it as an ArrayBuffer. WASM code addresses memory with i32 indexes. It can be backed by a SharedArrayBuffer for threading.
Use cases
- WASM heap memory
- C code porting
- WASM-JS data exchange