Link to the code that reproduces this issue
https://github.com/austin-raey/next-memory-issue
To Reproduce
- Create a Next.js app with
output: 'standalone'
- Make fetch requests to an external API
- With just 2 requests per second, OOM occurs after a few minutes
Current vs. Expected behavior
- Current: Memory continuously grows until OOM after ~2 requests/second. GC cannot release the memory.
- Expected: Memory should stabilize, GC should work properly, no OOM.
Provide environment information
- Platform: Linux
- Node: v22.16.0
- Next.js: 16.0.10
- output: standalone
- Router: App Router
Which area(s) are affected? (Select all that apply)
Performance
Which stage(s) are affected? (Select all that apply)
Other (Deployed)
Additional context
Related to PR #88577 (fix for issue #85914). The fix should properly cancel both branches of a tee'd ReadableStream, but the issue still persists in 16.0.10.
@icyJoseph I've tested with next@16.2.0-canary.51 (which should include the fix from #88577), but the memory leak still occurs.
Heap Timeline Analysis
The heap timeline shows that string and object types are being retained and continuously accumulated. These objects are referenced by cacheController
nextjs-memory-leak.heaptimeline.zip