Get the latest tech news
WebAssembly: How to Allocate Your Allocator
nullprogram.com/blog/2025/04/19/ An early, small hurdle diving into WebAssembly was allocating my allocator. On a server or desktop with virtual memory, the allocator asks the operating system to map fresh pages into its address space (sbrk, anonymous mmap, VirtualAlloc), which it then dynamically allocates to different purposes.
The WASM execution environment more resembles an embedded system, but both kinds of obtaining raw memory are viable and useful in different situations. wasm-ld doesn’t understand linker scripts, and there’s no stable, low-level assembly language on which to build, e.g. to reserve space, define symbols, etc. To find the upper bound, WASM has a memory.size instruction to query linear memory size, which again Clang provides as an undocumented built-in:
Or read this on Hacker News