emscripten-core / emscripten-core/emscripten
Allow configuring MAXIMUM_MEMORY at load time for 2gb vs 4gb?
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Currently you can pass `-s MAXIMUM_MEMORY=4gb` to emcc and it will generate JS glue code that supports addresses up to that limit. This is convenient for browsers that support 4gb, but not so convenient for sharing this same bundle with browsers that only support 2gb limit. You can pass in your own `wasmMemory` object that has a smaller limit, but `_emscripten_resize_heap()` hardcodes the maximum heap size into the generated JS code.
This means that if the `requestedSize` is very close to the 2gb limit, it's possible that `_emscripten_resize_heap()` will actually try to grow larger than 2gb and fail (where previously it would have been clamped by this code:
```
var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));
```
Is it possible to have `MAXIMUM_MEMORY` be configurable via a "pre-js" file to prevent this behavior?
Contributor guide
Assessment
This issue has not been assessed yet.