Skip to content

Docs: Indicate High memory usage if not installing sharp for image optimization #41417

@gaplo917

Description

@gaplo917

What is the improvement or update you wish to see?

Introduction

Remote image sizes are difficult to guarantee when some users uploaded very large images on the CMS. The very large images will be retrieved by nextjs and served to the frontend.

The default library squoosh will cause the nextjs process a very high memory usage during image optimizations and might crash the whole nextjs container in a limited resource environment.

Thus, the high memory behaviour should be docuementated to increase the necessarity of installing sharp.

Note: Some of our team members can't see observable differences after installing sharp and then remove it immediately.

Suggestion

Indicate high memory usage of squoosh compared with sharp. For example, a single 5000 x 5000 images would consume ~600MB memory while sharp use less than few MB memory only.

Is there any context that might help us understand?

Demo Recording

Without installing Sharp

Three 5000x5000 images will cause 1.8GB memory usage, and the memory jump is linear.
next-high-mem

Installed Sharp

The memory usage remains stable.
next-sharp-installed-no-high-mem

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/messages/sharp-missing-in-production

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationRelated to Next.js' official documentation.locked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions