You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m using sharp to resize images into multiple formats, specifically AVIF and WebP. I’m running the application on Digital Ocean App Platform with 1GB RAM. When uploading images (around 1.5MB in size), it takes about 20 seconds to resize them into six different image sizes, but this process causes the app to crash and restart due to high memory usage.
A Digital Ocean representative confirmed that even a small number of image requests leads to memory exhaustion and app restarts. I'm using Next.js alongside Payload CMS (v3.0.0-beta.76). Although the repo link I provided and tested with on App Platform just uses express alongside sharp.
I suspect the memory spike is related to processing AVIF and WebP formats, but I’m unsure how to mitigate the issue with my current memory constraints.
Any insights or suggestions for optimizing memory usage or handling large image workloads in Sharp would be highly appreciated.
When you searched for similar issues, what did you find that might be related?
I’ve seen similar issues regarding high memory usage when resizing to AVIF and WebP formats, but I haven’t found a specific solution or optimization recommendation for my case, where multiple sizes of these formats are being generated simultaneously.
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this question
Repo Link with sample images and additional context.
You might want to check that App Platform is reporting the relevant number of CPU cores and RAM available via cgroups, e.g. watch out for underlying physical cores vs available virtual cores.
The forthcoming libvips v8.16.0 contains logic to further limit the number of threads that libaom can spawn, which for many scenarios will reduce contention and speed things up.
Question about an existing feature
What are you trying to achieve?
I’m using sharp to resize images into multiple formats, specifically AVIF and WebP. I’m running the application on Digital Ocean App Platform with 1GB RAM. When uploading images (around 1.5MB in size), it takes about 20 seconds to resize them into six different image sizes, but this process causes the app to crash and restart due to high memory usage.
A Digital Ocean representative confirmed that even a small number of image requests leads to memory exhaustion and app restarts. I'm using Next.js alongside Payload CMS (v3.0.0-beta.76). Although the repo link I provided and tested with on App Platform just uses express alongside sharp.
I suspect the memory spike is related to processing AVIF and WebP formats, but I’m unsure how to mitigate the issue with my current memory constraints.
Any insights or suggestions for optimizing memory usage or handling large image workloads in Sharp would be highly appreciated.
When you searched for similar issues, what did you find that might be related?
I’ve seen similar issues regarding high memory usage when resizing to AVIF and WebP formats, but I haven’t found a specific solution or optimization recommendation for my case, where multiple sizes of these formats are being generated simultaneously.
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this question
Please provide sample image(s) that help explain this question
Under
/assets
in repo link.Image Sizes:
The text was updated successfully, but these errors were encountered: