emscripten-core / emscripten-core/emscripten

wasm-emscripten-finalize consumes more than 10GB memory to build successfully.

Open
#15,921 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

wasm-emscripten-finalize.exe needs more than 10GB memory to build my project successfully. My machine has 16GB memory, if open some other program, such as Edge browser, the memory left seems to be not enough for wasm-emscripten-finalize.exe, and it will fail with error 3221226505 as shown below.

Is this a memory leak issue in wasm-emscripten-finalize.exe? Is there any way to fix it or any workaround for it?

My test project can be downloaded from [here](https://1drv.ms/u/s!AuyLGpOYfQW9hdZievHwusUxJPtzIA?e=k9wUAL). It contains all the files generated during build in the project folder.

**Version of emscripten/emsdk:**

> emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.0.0 (3fd52e107187b8a169bb04a02b9f982c8a075205)
clang version 14.0.0 (https://github.com/llvm/llvm-project 4348cd42c385e71b63e5da7e492172cff6a79d7b)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: D:\emsdk\upstream\bin

**Full link command and output with `-v` appended:**

> Consolidate compiler generated dependencies of target occt-webgl-sample
[ 20%] Linking CXX executable occt-webgl-sample.js
"D:/emsdk/upstream/bin\wasm-ld.exe" -o occt-webgl-sample.wasm CMakeFiles/occt-webgl-sample.dir/WasmControllers/DisplayScene.cpp.o CMakeFiles/occt-webgl-sample.dir/WasmControllers/StepModelLoader.cpp.o CMakeFiles/occt-webgl-sample.dir/WasmViews/WasmOcctView.cpp.o CMakeFiles/occt-webgl-sample.dir/main.cpp.o -LE:/OpenCASCADE/7.6.0-install-wasm/Debug/lib E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKRWMesh.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKBinXCAF.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKBin.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKBinL.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKOpenGles.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKXCAF.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKVCAF.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKCAF.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKV3d.a
E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKHLR.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKMesh.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKService.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKShHealing.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKPrim.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKTopAlgo.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKGeomAlgo.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKBRep.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKGeomBase.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKG3d.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKG2d.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKMath.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKLCAF.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKCDF.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKernel.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKXSBase.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKXDESTEP.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKSTEP.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKSTEPBase.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKSTEPAttr.a E:/OpenCASCADE/7.6.0-install-wasm/Debug/lib/libTKSTEP209.a E:/OpenCASCADE/7.6.0-install-wasm/3rdparty/freetype-2.11.1/Debug/lib/libfreetyped.a -LD:\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten --whole-archive -lembind-rtti --no-whole-archive -lGL-webgl2 -lal -lhtml5 -lstubs-debug -lc -lcompiler_rt -lc++ -lc++abi -ldlmalloc -lc_rt -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --import-undefined --export-if-defined=main --export-if-defined=emscripten_stack_get_end --export-if-defined=emscripten_stack_get_free --export-if-defined=emscripten_stack_init --export-if-defined=stackSave --export-if-defined=stackRestore --export-if-defined=stackAlloc --export-if-defined=__wasm_call_ctors --export-if-defined=fflush --export-if-defined=__errno_location --export-if-defined=malloc --export-if-defined=free --export-if-defined=__cxa_is_pointer_type --export-if-defined=__cxa_can_catch --export-if-defined=setThrew --export-if-defined=saveSetjmp --export-if-defined=__dl_seterr --export-if-defined=htons --export-if-defined=_get_tzname --export-if-defined=_get_daylight --export-if-defined=_get_timezone --export-if-defined=memalign --export-if-defined=emscripten_main_thread_process_queued_calls --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-table -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=2147483648 --global-base=1024
"D:/emsdk/upstream\bin\wasm-emscripten-finalize" --minimize-wasm-changes -g --dyncalls-i64 --dwarf occt-webgl-sample.wasm -o occt-webgl-sample.wasm --detect-features
em++: error: 'D:/emsdk/upstream\bin\wasm-emscripten-finalize --minimize-wasm-changes -g --dyncalls-i64 --dwarf occt-webgl-sample.wasm -o occt-webgl-sample.wasm --detect-features' failed (returned 3221226505)
mingw32-make[2]: *** [src/occt-webgl-sample.js] Error 1
mingw32-make[1]: *** [src/CMakeFiles/occt-webgl-sample.dir/all] Error 2
mingw32-make: *** [all] Error 2
emmake: error: 'D:\emsdk\mingw\4.6.2_32bit\mingw32-make.exe install' failed (returned 2)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.