Repository navigation
Description
Problem
The wasm32 and Memory64 providers use bump allocators. sys_free validates basic arguments but does not reclaim or reuse the allocation. This is an intentional initial limitation, documented in std/sys/wasm/memory.wave, rather than a newly introduced regression.
Repeated allocation/free and portable buffer resizing can therefore consume linear memory even when live storage stays bounded.
Scope
Add reuse of freed allocations to the single-threaded WebAssembly allocators while preserving the existing sys_alloc(size) / sys_free(pointer, size) API and target pointer widths. Reclaiming here means reusing linear-memory space; it does not require shrinking WebAssembly memory or returning pages to the host.
Completion criteria
- Repeated same-size allocate/free workloads reach a bounded memory plateau.
- Mixed sizes can reuse freed storage with suitable splitting and coalescing, or an explicitly bounded alternative.
- Live allocations never overlap and retain their contents across allocator activity.
- Preserve at least the current 16-byte alignment and allocation-failure behavior.
- Check metadata arithmetic, memory growth failure, and wasm32 address limits without narrowing Memory64 pointers.
- Document allocator ownership and the pointer/size requirements for freeing.
- Test wasm32 unknown/WASI and wasm64 unknown execution, including buffer reallocation, zero/invalid sizes, and fragmentation.
- Do not add libc or another allocator dependency.
Difficulty: high. This is not a good first issue. Separate from #466 (wasm64 WASI ABI), #532 (async watch ownership), and #676 (buffer source alias classification).
Activity
Fix typed codegen and expand portable std capabilities (#701)