Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[canary] wasm - could not allocate memory #195

Open
andreisergiu98 opened this issue Aug 20, 2020 · 2 comments
Open

[canary] wasm - could not allocate memory #195

andreisergiu98 opened this issue Aug 20, 2020 · 2 comments

Comments

@andreisergiu98
Copy link

andreisergiu98 commented Aug 20, 2020

Hi!
I have a lot of images, and i build a lot of variants for each image. And when i use the optimize: true option it takes a lot of time to optimize them and in the end it fails

RuntimeError: abort(RangeError: WebAssembly.Memory(): could not allocate memory). Build with -s ASSERTIONS=1 for more info.
    at process.abort (/home/andrei/Projects/Web/node_modules/@wasm-codecs/mozjpeg/lib/mozjpeg.js:9:11556)
    at process.emit (events.js:327:22)
    at processEmit [as emit] (/home/andrei/Projects/Web/node_modules/next/dist/compiled/ora/index.js:1:2260)
    at processPromiseRejections (internal/process/promises.js:209:33)
    at processTicksAndRejections (internal/process/task_queues.js:98:32)
error Command failed with exit code 7.

I think there is a limit to how much memory it can use.
My node version is 12.18.3

@andreisergiu98
Copy link
Author

I tried to build @wasm/mozjpeg with MAXIMUM_MEMORY=4GB and it still throws the error and it's the maximum we can get. I think the problem is webpack processing all image imports in parallel, that with some cpu interrupts and it's populating the ram like crazy without it being capable to free the memory because the images are still being processed. I think we could fix the problem by processing a maximum of cpu threads + 1 number of images in parallel. This could be achieved with some kind of internal state in the loader where we keep track of the number of images currently processed, but i don't know if it's possible with webpack, i'll make some research.

@Nadav42
Copy link

Nadav42 commented Oct 6, 2020

Can we get an official fix for this? happens to me as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants