-
Notifications
You must be signed in to change notification settings - Fork 27k
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
10.0.8 next/image high memory use #22925
Comments
We experience this as well. We use Next.js for a shop-like website, which has 60-100 images per page. After updating Next.js from 10.0.7 to 10.0.8 our memory usage jumped from ~600MB to ~3.7GB With 10.0.7: With 10.0.8: We reverted to 10.0.7 and memory usage is back to ~600MB. We can't say for sure if this is related to images. But we did see a general increase in response time for |
I can confirm the same issue. We run our app in container with limited memory and since update to 10.0.8 we started to get regular out-of-memory crashes even though there were just two images going through |
It's also happening to me, more than this issue but its one critical issue even on the optimization of the images, its suffering with response time |
+1 |
10.0.8 was supposedly supposed to fix this issue by switching out the sharp library for a wasm equivalent but it's made it even worse. We've had to rollback all usage of next/image now in production unfortunately. It was consuming literally all memory available on our ec2 instances. |
This comment has been minimized.
This comment has been minimized.
We've identified the cause and are working on a fix, but it would be helpful if you can share more info for this! I.e. number of CPU cores, average image size, memory increased after upgrading, etc. |
I know @Thoud was experiencing this the other day, deploying his Next.js bootcamp project to the Heroku free plan... |
Having the same thing. There are only two Image component images (original image sizes approx 300kb and 20kb) After reverting to 10.0.7 much better, but still more memory usage than much bigger next.js apps without Image component. |
This PR upgrades `jest-worker` and `jest-cli` to the latest pre-release version, also removed `jest-circus` which is included in Jest by default. `jest-worker@next` includes a fix for memory leak that we need (jestjs/jest#11187). Fixes #22925. This will also improve the OOM issue for `next dev` #15855.
Hi! |
@fostyfost it's fixed on the canary line. Please try installing |
@timneutkens please tell me which commit fixes this issue? |
@timneutkens Just built and started on my mac (not m1) the same project and opened the same page with ~10 next/image images Sorry for Activity Monitor but even here the problem is obvious |
I can confirm this. I had the same memory issues when deployed to production. Even using |
@shuding Unfortunately you good work doesn't fix the issue for me (even on v10.0.10-canary.7). It still exceeds 1960MB, where as it uses much less memory in 10.0.7 (230MB). |
I guess the new issue tracking this problem is over here: #23189 |
This PR upgrades `jest-worker` and `jest-cli` to the latest pre-release version, also removed `jest-circus` which is included in Jest by default. `jest-worker@next` includes a fix for memory leak that we need (jestjs/jest#11187). Fixes vercel#22925. This will also improve the OOM issue for `next dev` vercel#15855.
As stated in vercel#23157, this PR merges all the operations into 1 worker thread (`processBuffer` in `impl.ts`) and only pass a list of operation names and args into the worker. This should improve the speed and memory usage of next/image. Fixes vercel#23157. X-ref: vercel#22925.
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
10.0.8
What version of Node.js are you using?
14.15.4
What browser are you using?
chrome
What operating system are you using?
macOS
How are you deploying your application?
next start
Describe the Bug
With v10.0.8 on pages with lots of next/image components seeing much higher memory use compared to 10.0.7. Possibly related to #22253
Expected Behavior
less memory use
To Reproduce
checkout branch
nextjs-leak
https://github.com/scttcper/xmplaylist/tree/nextjs-leakrun
yarn && yarn build && cd frontend && npx next start
open localhost:3000 and just refresh the root/home page a few times (the backend is not required for this page). Memory should shoot up to 400-500mb. In production this was consuming 2gb (all memory available)
Production version is - https://xmplaylist.com/ you can see the home page has a good set of images.
The text was updated successfully, but these errors were encountered: