emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.89k stars 3.32k forks source link

I am using sdk-fastcomp-tag-1.38.30-64bit, and I am getting abortOnCannotGrowMemory #14532

Open Buster28 opened 3 years ago

Buster28 commented 3 years ago

@kripken Need guidence to debug the issue

kripken commented 3 years ago

That is caused by not being able to grow memory when you need to. Your application is trying to malloc more than the memory allows. Enabling memory growth, or increasing the initial memory size, may help.

Buster28 commented 3 years ago

But this is old version right? So enabling memory growth is not supported explicitly with pthread. But, yes internally I think it is switched on that's how our emscripten code is running.

Fyi, i have allocated total memory which is initial memory is 32 mb. What value do you recommend?

kripken commented 3 years ago

That is a pretty old version, yeah, it might be that growth was not supported there. You can try a larger initial size of memory then. What the right value is depends on your codebase and where it is run.

Buster28 commented 3 years ago

@kripken the app we are using we have provided 32 mb memory, and we have seen the memory growing further also , when we run the application. Also, we are not getting crash on initialization. It comes in long running programs.

So, just wanted to confirm, what does that total memory mean here? and how it is consumed or used? how it;s impact will be changed when we will increase total memory from 32 mb? By increasing memory, will it really affect the long running programs?

kripken commented 3 years ago

The wasm memory uses something much like a typed array - a flat contiguous region of memory. That is allocated to the "initial" size at the start. The browser uses up all that memory. Emscripten then allocates within that region using malloc. You can use mallinfo() to get statistics about how much is used, etc. As more memory is used, or as memory gets fragmented, emscripten will use more and more of the wasm memory. If it runs out, it will need to grow the memory.

Buster28 commented 3 years ago

Exactly in our case, the memory is growing since at the start our application is not crashing. So, would it affect anything if we will increase the initial memory ?