-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Description
Verify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
$ next info
'pnpm' is not recognized as an internal or external command,
operable program or batch file.
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Binaries:
Node: 16.14.0
npm: 8.3.1
Yarn: 1.22.11
pnpm: N/A
Relevant packages:
next: 12.1.1-canary.1
react: 17.0.2
react-dom: 17.0.2
What browser are you using? (if relevant)
98.0.4758.102
How are you deploying your application? (if relevant)
next dev
Describe the Bug
Hey,
It seems that nextjs leak all previous version of hot reload, even when they are old and not used:

as you can see from the picture _app.js _document.js are duplicated for each of their revision, even when not used at all, and even when closing the browser tab. It causes memory to go up until everything crashes on OOM error with some large projects.
Expected Behavior
Only one instance of each page/code should be kept in memory, otherwise this leak cause crash.
To Reproduce
https://github.com/smulikHakipod/nextjs-hot-reload-leak
Start NextJS in dev mode e.g npm run dev
Go to some page e.g index e.g http://127.0.0.1:3000/
Change a char in _app.js and save it, causing a hot reload.
Refresh the page (index) in the browser.
Repeat.
Watch memory grow and heap snapshot containing all duplicated pages content.
Repeat enough time, and it will crash or run out of system memory.
Thanks!!