logoalt Hacker News

ridiculous_fishyesterday at 6:42 PM2 repliesview on HN

Doesn't every WASM program have to carry its own malloc/free today?


Replies

phickeyyesterday at 7:09 PM

Yes, every wasm program that uses linear memory (which includes all those created by llvm toolchains) must ship with its own allocator. You only get to use the wasm GC provided allocator if your program is using the gc types, which can’t be stored in a linear memory.

flohofwoeyesterday at 7:10 PM

Yes, but Emscripten comes with a minimal allocator that's good enough for most C code (e.g. code with low alloc/free frequency) and only adds minimal size overhead:

https://github.com/emscripten-core/emscripten/blob/main/syst...