Skip to content

about memory grow problem #119

Closed
Closed
@GuoLei1990

Description

@GuoLei1990

I have a memory problem!but I don't know create issues in which project. maybe is llvm or wasi. I use llvm and wasi-sdk compile wasm.
the problem is I init wasm lib version with code
var mem = new WebAssembly.Memory({ 'initial': initialMemory}); fetch("laya.physics3D.wasm.wasm").then((response) => { response.arrayBuffer().then((buffer) => { WebAssembly.instantiate(buffer, { wasi_unstable: { }, env: { memory: mem, } }).then((physics3D) => { }); }); });
I compile the wasm with "--import-memory" by llvm ,but the initial memory not really work, wasm still grow the memory base the initial memory end.
for example I run a sample need 7M(or pages) wasm memory, if initial memory is 2M the memory in chrome is 2M+7M=9M,if the initialMemory is 100M the memory in chrome is 100M+7M=107M. in fact wasm ignore the initial memory and waste. so I must initial mininum size 2 pages with new WebAssembly.Memory({ 'initial': 2}); to avoid waste,but this is not I want. because this will grow memory many times,this is very slow,and especially when convert it to js version,it's very very slow,but i think the problem is in llvm or wasi. If I can sucess give a big memory to wasm, and wasm can use this memory first form start( not always grow from this memory end),will
save many performance,do not need to grow memoy many times,for my project(it's a 3D engine) the initial memory size must be a config write by developer according to their game, this is good for performance( avoid grow memory many times). before i use emsdk to compile wasm, don't have this problem. I hope this is my mistake cause!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions