Skip to content

Memory leak causing OOM still occurs in Next.js 16.0.10 (also tested with 16.0.1) when using output: standalone with fetch requests. #90433

@haoyanwang

Description

@haoyanwang

Link to the code that reproduces this issue

https://github.com/austin-raey/next-memory-issue

To Reproduce

  1. Create a Next.js app with output: 'standalone'
  2. Make fetch requests to an external API
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    PerformanceAnything with regards to Next.js performance.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions