next.js: Turbopack dev server and HMR consuming too much memory and freezing at code changes.
Link to the code that reproduces this issue
https://github.com/devhik0/crm-saas
To Reproduce
- Run
next dev --turboand check Memory values at task manager, htop etc. Also check VS Code’s process explorer viaF1 > Open Process Explorerand look for"<path>\nodejs\node.exe" <path-to-app>\node_modules\next\dist\server\lib\start-server.js
Current vs. Expected behavior
That process above is consuming around 1GB memory at idle state (just running and no code change), thus code change reflections taking around > 30s to appear on UI. Here is the latest hmr result:
○ Compiling /tasks ...
✓ Compiled in 39.9s (sometimes around 60)
✓ Compiled /tasks in 18.2s
Expected: faster rebuilds to see what happens at UI in short time and less memory consumption
I think there is a memory leak at somewhere in process.
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Home Single Language
Available memory (MB): 16280
Available CPU cores: 4
Binaries:
Node: 20.10.0
bun: 1
Relevant Packages:
next: 14.2.3 // Latest available version is detected (14.2.3).
eslint-config-next: 14.2.3
react: 18.3.1
react-dom: 18.3.1
typescript: 5.4.5
Which area(s) are affected? (Select all that apply)
Developer Experience, Module Resolution, Performance, Runtime, Turbopack, TypeScript
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
Here i am sharing process info from my system to show what is happening actually:
The process with red is : <path>\nodejs\node.exe" <path-to-app>\node_modules\next\dist\server\lib\start-server.js
Also this is from process explorer at vscode:
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 22 (10 by maintainers)
Seeing a similar issue running on Mac. It’s smoking ~5GB of CPU:
Updated from 14.1.4 -> 14.2.4