diff --git a/cli/src/api/templates/load-wasi-template.ts b/cli/src/api/templates/load-wasi-template.ts index abe59a5d..209c3a2d 100644 --- a/cli/src/api/templates/load-wasi-template.ts +++ b/cli/src/api/templates/load-wasi-template.ts @@ -24,8 +24,10 @@ const __wasi = new __WASI({ const __emnapiContext = __emnapiGetDefaultContext() const __sharedMemory = new WebAssembly.Memory({ - initial: 1024, - maximum: 10240, + // 1Gb + initial: 16384, + // 4Gb + maximum: 65536, shared: true, }) @@ -95,8 +97,10 @@ const __wasi = new __nodeWASI({ const __emnapiContext = __emnapiGetDefaultContext() const __sharedMemory = new WebAssembly.Memory({ - initial: 1024, - maximum: 10240, + // 1Gb + initial: 16384, + // 4Gb + maximum: 65536, shared: true, }) diff --git a/crates/build/src/wasi.rs b/crates/build/src/wasi.rs index f83ef919..4c44275a 100644 --- a/crates/build/src/wasi.rs +++ b/crates/build/src/wasi.rs @@ -16,11 +16,10 @@ pub fn setup() { println!("cargo:rustc-link-arg=--export=emnapi_async_worker_init"); println!("cargo:rustc-link-arg=--import-memory"); println!("cargo:rustc-link-arg=--import-undefined"); - println!("cargo:rustc-link-arg=--shared-memory"); - println!("cargo:rustc-link-arg=--max-memory=2147483648"); - // lld only allocates 1MiB for the WebAssembly stack, and the array that you're allocating on the stack is exactly 1MiB. - // 0x800000 bytes = 8MiB - println!("cargo:rustc-link-arg=-zstack-size=0x800000"); + println!("cargo:rustc-link-arg=--max-memory=4294967296"); + // lld only allocates 1MiB for the WebAssembly stack. + // 6400000 bytes = 64MiB + println!("cargo:rustc-link-arg=-zstack-size=6400000"); println!("cargo:rustc-link-arg=--no-check-features"); if let Ok(setjmp_link_dir) = env::var("SETJMP_LINK_DIR") { println!("cargo:rustc-link-search={setjmp_link_dir}"); diff --git a/examples/napi/example.wasi.cjs b/examples/napi/example.wasi.cjs index 37a55d6a..cdea31a5 100644 --- a/examples/napi/example.wasi.cjs +++ b/examples/napi/example.wasi.cjs @@ -24,8 +24,9 @@ const __wasi = new __nodeWASI({ const __emnapiContext = __emnapiGetDefaultContext() const __sharedMemory = new WebAssembly.Memory({ - initial: 1024, - maximum: 10240, + initial: 16384, + // 4Gb + maximum: 65536, shared: true, })