-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Description
Link to the code that reproduces this issue
https://github.com/NoatToan/next_memory_leak/blob/main
To Reproduce
- yarn && yarn build && yarn server_local
- Goto resource inspector of devices (htop for Linux, Activity Monitor for MacOS)
- goto localhost:3000 or localhost:3000/test1
Current vs. Expected behavior
Current:
### This issue happened on my PRD server with around 9GB RAM usage and need to restart the server to clean up the RAM usages with actually project has been built for 2 years
First run output build only 32.8MB
After load some pages and actions. Then close all pages, the RAM usage increased to 44MB
Open many tabs and spam reload, then RAM usage increased from 44MB to 8xMB (~80% increased?)
After that close all tabs
RAM usage to around 60MB
I dont understand why the server is running with NextJS increase RAM usage over time
First time 32.8MB to 60MB ~ 90%. then the ram usage never back to under 60MB
Expect
Do you know how to overcome the issue. I have tried to migrate the project to Next 15.1.6 but issue still happening and first server running is slightly over the amount of RAM usage.
I tried to record heap from Next documentation but could not understand what I can do next
https://nextjs.org/docs/14/app/building-your-application/optimizing/memory-usage
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6030
Available memory (MB): 18432
Available CPU cores: 11
Binaries:
Node: 23.7.0
npm: 10.9.2
Yarn: 1.22.22
pnpm: N/A
Relevant Packages:
next: 14.3.0-canary.11 // An outdated version detected (latest is 15.1.8), upgrade is highly recommended!
eslint-config-next: 14.3.0-canary.11
react: 18.3.1
react-dom: 18.3.1
typescript: 5.8.3
Next.js Config:
output: standalone
⚠ An outdated version detected (latest is 15.1.8), upgrade is highly recommended!
Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
Read more - https://nextjs.org/docs/messages/opening-an-issue
Which area(s) are affected? (Select all that apply)
Runtime
Which stage(s) are affected? (Select all that apply)
Other (Deployed), next start (local)
Additional context
My project is following the best practice from NextJS App router
With almost server actions for fetching and revalidatePath.
I have tried to force dynamic and default-no-store for fetch to find out the issues.