-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wasm] Set -sMAXIMUM_MEMORY to 256 MiB by default #84638
Comments
Interesting, we definitely need to think about what a good default for this is. |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsMobile Safari (on ios 16.4 and probably earlier) doesn't like wasmMemory=new WebAssembly.Memory({"initial":INITIAL_MEMORY/65536,"maximum":2147483648/65536,"shared":true}) That emscripten has by default, where We get a rejected promise during startup with As a workaround I can add this in my .csproj, but we should set a good default: <PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<!-- 256 MiB -->
<EmccFlags>-sMAXIMUM_MEMORY=268435456</EmccFlags>
</PropertyGroup> Note: we should double-check that 256 is a good default for Blazor Note2: demo https://lambdageek.dev/dotnet-wasm-raytracer/net8/
|
I think it's too late to change defaults and would prefer to start with in early .NET 9 |
I can't find I can see Memory section in wa-info
|
@maraf Can we think about adding an msbuild property for .net8 to set the maximum in a nice way instead of relying on |
The |
Are we saying that setting max heap lower will make GC run earlier, and the browser would not have to allocate more than he can (on limited device) ? Or we actually need to set initial memory ? |
we could also detect that we are on mobile safari and try to do it on runtime const memory = new WebAssembly.Memory({
initial: 10,
maximum: 100,
}); |
Also if this is only about Mono GC pressure I think we could have other means how to set it lower, without needing to make it compile time constant. @radekdoulik I remember that you somehow detect available memory for GC purpose ? |
I'm not sure what this has to do with Mono. Mobile Safari refuses to create the wasm memory instance if the maximum is more than 256MiB. Doesn't matter how Mono will use it. This happens much earlier |
Wasn't #91256 a fix for this? Do we need to keep the discussion open? |
#91256 made it easier for app authors to set the maximum initial memory. But we didn't change the default. Maybe we don't need to change the default? Maybe we can just add something to the docs? or write something to the console if we detect mobile safari and the runtime fails to start? |
Error message was added by #104963 |
Mobile Safari (on ios 16.4 and probably earlier) doesn't like Emscripten's default
MAXIMUM_MEMORY
of 2 GiB:We get a rejected promise during startup with
RangeError: out of memory
with the default maximum memory size.As a workaround I can add this in my .csproj, but we should set a good default:
Note: we should double-check that 256 is a good default for Blazor
Note2: demo https://lambdageek.dev/dotnet-wasm-raytracer/net8/
The text was updated successfully, but these errors were encountered: