next/og
cause memory leak in production standalone build
#65451
Labels
bug
Issue was opened via the bug report template.
Image (next/image)
Related to Next.js Image Optimization.
Link to the code that reproduces this issue
https://github.com/Innei/next-og-oom-repro
To Reproduce
node server.js
/og
The initial memory usage about to 50M, and refresh
/og
about 10 times, got 300MI can provide some ways to try to troubleshoot memory issues.
Add memory dump code in
.next/standalone/server.js
And then refresh the page and refresh the page several times and observe the app memory usage afterwards. When memory overflows and is not freed, hit the heap of memory at that point with
kill -SIGUSR2 <pid>
.As you can see from the following dump, it's the ImageResponse-related modules that are leaking memory. ImageResponse and FigmaImageResponse that means @vercel/og causes memory leak?
Link to #44685 (comment).
Current vs. Expected behavior
expected:
Memory can be freed up.
Provide environment information
Operating System: Platform: darwin/linux Arch: arm64/amd64 Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020/ or Linux Available memory (MB): 32768 Available CPU cores: 12 Binaries: Node: 18.18.0/20.x npm: 10.2.4 Yarn: 1.22.21 pnpm: 9.1.0 Relevant Packages: next: 14.2.3 // Latest available version is detected (14.2.3). eslint-config-next: N/A react: 18.3.1 react-dom: 18.3.1 typescript: 5.4.5 Next.js Config: output: standalone
Which area(s) are affected? (Select all that apply)
Image (next/image)
Which stage(s) are affected? (Select all that apply)
Other (Deployed)
Additional context
No response
The text was updated successfully, but these errors were encountered: