Skip to content

Memory leak during load tests in dynamic rendering mode #84648

@grzegorz-orbital

Description

@grzegorz-orbital

Link to the code that reproduces this issue

https://github.com/grzegorz-orbital/nextjs-bug

To Reproduce

  1. Clone repository (I prepared a small test repository that reproduces this issue):
    https://github.com/grzegorz-orbital/nextjs-bug

  2. To trigger the problem, run ./run_next.sh in a terminal — this starts Next in production mode.

  3. Install Rust — it’s required to run the performance test:
    https://rust-lang.org/tools/install/

  4. In a second terminal run ./run_goose_attack_api.sh. You only need Rust installed locally because the load tests are written in Rust.

When I run this test on my MacBook the test finishes in about one minute. It executes 40,000 requests.
After the test finishes, the Next process memory stays around ~15 GB and does not drop.

I tested it on the canary version as well (the canary branch). The behavior is the same.

Current vs. Expected behavior

I would expect that after the load test completes, the process memory usage would return to approximately the same level as before the test started.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041
  Available memory (MB): 24576
  Available CPU cores: 14
Binaries:
  Node: 24.4.0
  npm: 11.4.2
  Yarn: 1.22.22
  pnpm: 10.14.0
Relevant Packages:
  next: 15.5.4 // Latest available version is detected (15.5.4).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Dynamic Routes

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions