emscripten-core / emscripten-core/emscripten
Import custom memory manager?
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Per [Emscripten Compiler Settings ](https://emscripten.org/docs/tools_reference/settings_reference.html#malloc), it is possible to omit any malloc implementation and provide your own. To reduce module size and improve efficiency, I would like to import `malloc` and `free` implementations; that way, modules don't have to all have their own copy of the allocator code, and heap overhead can live outside of WASM memory.
However, I can't find any way to safely do this. A custom allocator needs to know how Emscripten has laid out memory, and I can't find any options that will force it to export or import `__heap_base`, or documentation for how stack and heap memory are ordered, etc.
So, are there any examples of how to implement custom imported memory management functions?
Contributor guide
Assessment
This issue has not been assessed yet.