emscripten-core / emscripten-core/emscripten

Automatic `INITIAL_MEMORY` for statically large modules

Open
#20,888 14 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Right now the default value of `INITIAL_MEMORY` is 16MB, which sets a hard limit on the amount of static data in a module - the linker will error out if the amount is insufficient. To work around this, you need to be able to calculate the number beforehand, e. g. the official .NET SDK [guesstimates](https://github.com/dotnet/runtime/blob/f0a6dbdf654b07cedc05217824500ae653409880/src/tasks/WasmAppBuilder/WasmCalculateInitialHeapSize.cs#L12) by doing something to the effect of going over all of the inputs and summing their size.

This all seems rather self-inflicted. The linker already knows how much memory will it need, and indeed, if you don't pass `--initial-memory`, it will already "do the right thing".

The question is, can this automatic behavior be supported by Emscripten natively?

Note: this is all assuming memory growth is allowed, of course.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.