Allocate Dynamic Memory in WebAssembly with Malloc
We demonstrate how to build a WebAssembly module that depends on malloc, linking in a pre-built malloc implementation at runtime, using a JS binding trick to handle the circular reference between the two WebAssembly modules. We then optimize the load process to ensure we are fetching these modules in parallel.
Malloc implementation: https://github.com/guybedford/wasm-stdlib-hack/blob/master/dist/memory.wasm
WASM Fiddle: https://wasdk.github.io/WasmFiddle/?1feerp
Demo Repo: https://github.com/guybedford/wasm-intro