Next.js Discord

Discord Forum

High server RAM usage when enabling Next.js image optimization (unoptimized: false)

Unanswered
American black bear posted this in #help-forum
Open in Discord
American black bearOP
I noticed a big jump in server‑side RAM usage when I enable image optimization in Next.js

Setup: Next.js project with next.config.js set to images: { unoptimized: false } so that all images are optimized by the Next.js Image component.

Observed behavior: With unoptimized: true, server memory stays around 700–900 MB.
With unoptimized: false, memory spikes to ~5 GB.

Expectation: I expected some overhead for image processing, but not such a large increase.

Logs/Errors: No explicit error messages, just high memory usage observed in monitoring.

What I’ve tried:
- Verified that the spike correlates directly with enabling optimization.
- Checked for memory leaks in my own code — nothing unusual.

Is this expected behavior when using Next.js image optimization? Are there recommended practices to reduce memory usage when optimizing images with Next JS?

8 Replies

@Dreamgineer Can you provide example of what you are displaying with `next/image`?
American black bearOP
This for example, our 2nd most popular page
We have 814 images in total but pagination makes it so I'm only showing 24 items per page (24 images)
@Dreamgineer How big are the original images?
American black bearOP
854x480
that's... weird
American black bearOP
very
logo in the navbar was 4000x900 but i mean idk if that would take it to 5GB