Linear memory growth in binaryen / webassembly

Hi there,

Is there a equivalent to

PlayerSettings.SetPropertyString("emscriptenArgs", "-s ALLOW_MEMORY_GROWTH=1", BuildTargetGroup.WebGL);

For binaryen? i.e. a “binaryenArgs” where we can add the “–allow-memory-growth” parameter?

This is a key feature for us,

Thanks!

Adam

Hi @AFrisby ,

try to use emscripten’s BINARYEN_MEM_MAX=

for example you could set total memory size to a very small value, let’s say 16mb, then set the maximum to 256mb via BINARYEN_MEM_MAX:

PlayerSettings.WebGL.emscriptenArgs = " -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_MEM_MAX=268435456";

then you should see warnings like these at run-time:

Warning: Enlarging memory arrays, this is not fast! 16777216,33554432
enlarged memory arrays from 16777216 to 33554432, took 14 ms (has ArrayBuffer.transfer? false)
Warning: Enlarging memory arrays, this is not fast! 33554432,67108864
enlarged memory arrays from 33554432 to 67108864, took 26 ms (has ArrayBuffer.transfer? false)

1 Like

Thanks Marco - I’ll double check with our engineering team, I know we’ve been testing ALLOW_MEMORY_GROWTH but it was sounding from them that it wasn’t being respected in WASM (but ASM.JS it was); is emscripten building both the asm.js and the wasm variants?

when WebAssembly Unity flag is enabled, both asm.js and wasm are generated.

1 Like