Skip to content

[WASM] 4GB address space #58382

Description

@htdag

Consider -s MAXIMUM_MEMORY=4GB emcc flag and it's implications for mono VM codebase.
Review other aspects, which may prevent handling large data.
Among others, how many copies of data we have at any time.

----- Original description
Got out of memory when load big file (~1GB) to memory.

// <InputFile OnChange="OnInputFileChange"
async Task OnInputFileChange(InputFileChangeEventArgs e)
{
    var file = e.File;
    using (var stream = file.OpenReadStream(file.Size))
    {
        var ms = new MemoryStream((int)file.Size);
        await stream.CopyToAsync(ms); // memory access out of bounds | Out of memory
        
        // ...
    }
}

=>

Uncaught (in promise) RuntimeError: memory access out of bounds
    at <anonymous>:wasm-function[120]:0x53cf
    at <anonymous>:wasm-function[3924]:0xc7ead
    at <anonymous>:wasm-function[3925]:0xc7f03
    at <anonymous>:wasm-function[1749]:0x43fd6
    at <anonymous>:wasm-function[3923]:0xc7e2b
    at <anonymous>:wasm-function[6542]:0x158b1e
    at Object.Module._mono_wasm_string_from_utf16 [as mono_wasm_string_from_utf16] (dotnet.6.0.0-preview.7.21377.19.js:1)
    at Object.js_string_to_mono_string_new (dotnet.6.0.0-preview.7.21377.19.js:1)
    at Object.js_string_to_mono_string (dotnet.6.0.0-preview.7.21377.19.js:1)
    at Object.converter_ssss [as compiled_function] (converter_ssss:11)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions