Webassembly.instantiate 期间如何定义最大内存?
How is maximum memory defined during Webassembly.instantiate?
实例化:
const res = await WebAssembly.instantiate(wasmBuf, {});
内存声明:
const memory = res.instance.exports.memory as WebAssembly.Memory;
memory
对象的maximum如何设置,如何指定内存最大值,and/or实例化后如何更改?
请注意,目前当我尝试 memory.grow()
时出现以下错误
Uncaught RangeError: WebAssembly.Memory.grow(): Maximum memory size exceeded
Defined at compile time,将以下内容添加到 emcc
编译选项作为命令行参数
// allow memory.grow()
-s ALLOW_MEMORY_GROWTH=1 \
// change default memory size
-s INITIAL_MEMORY=1000000
更多详情:
Whelp....我想我只是想问这个问题,现在已经找了一个小时,并在 post:
5 分钟后找到答案
似乎 WebAssembly 在 .wasm
文件中采用了 memory
规范,这些规范在编译时由 emcc
.
定义
实例化:
const res = await WebAssembly.instantiate(wasmBuf, {});
内存声明:
const memory = res.instance.exports.memory as WebAssembly.Memory;
memory
对象的maximum如何设置,如何指定内存最大值,and/or实例化后如何更改?
请注意,目前当我尝试 memory.grow()
时出现以下错误
Uncaught RangeError: WebAssembly.Memory.grow(): Maximum memory size exceeded
Defined at compile time,将以下内容添加到 emcc
编译选项作为命令行参数
// allow memory.grow()
-s ALLOW_MEMORY_GROWTH=1 \
// change default memory size
-s INITIAL_MEMORY=1000000
更多详情:
Whelp....我想我只是想问这个问题,现在已经找了一个小时,并在 post:
5 分钟后找到答案似乎 WebAssembly 在 .wasm
文件中采用了 memory
规范,这些规范在编译时由 emcc
.