From 30cf30ca8248b659ae7eb9b0f73f83899e21689f Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 24 Mar 2025 14:42:12 +0100 Subject: [PATCH] examples : reduce initial memory to 512MB (#2939) * examples : reduce initial memory to 512MB This commit reduces the initial memory size to 512MB. This is done to to avoid WebAssembly memory allocation issues on some platforms. It also adds a flag to allow the memory to grow dynamically (up to the maximum). The motivation for this change is that currently the initial memory is set to 2GB which might be to large for some platforms. This will lead to an error being thrown from the JavaScript code generated by Emscripten when trying to allocate memory. More details can be found in the referenced issue below. * examples : set MAXIMUM_MEMORY instead of TOTAL_MEMORY This commit sets MAXIMUM_MEMORY instead of TOTAL_MEMORY in the whisper.wasm example. The motivation for this is that TOTAL_MEMORY and INITIAL_MEMORY are actually the same thing. Instead we want to set MAXIMUM_MEMORY to 2GB. Refs: https://github.com/ggerganov/whisper.cpp/issues/2920 Refs: https://emscripten.org/docs/tools_reference/settings_reference.html#initial-memory --- examples/whisper.wasm/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/whisper.wasm/CMakeLists.txt b/examples/whisper.wasm/CMakeLists.txt index 75e5a8de..10e503fd 100644 --- a/examples/whisper.wasm/CMakeLists.txt +++ b/examples/whisper.wasm/CMakeLists.txt @@ -32,8 +32,9 @@ set_target_properties(${TARGET} PROPERTIES LINK_FLAGS " \ --bind \ -s USE_PTHREADS=1 \ -s PTHREAD_POOL_SIZE_STRICT=0 \ - -s INITIAL_MEMORY=2000MB \ - -s TOTAL_MEMORY=2000MB \ + -s INITIAL_MEMORY=512MB \ + -s MAXIMUM_MEMORY=2000MB \ + -s ALLOW_MEMORY_GROWTH=1 \ -s FORCE_FILESYSTEM=1 \ -s EXPORTED_RUNTIME_METHODS=\"['print', 'printErr', 'ccall', 'cwrap']\" \ ${EXTRA_FLAGS} \