New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak when generating many pages #25362
Comments
Did more tests to pin point leak. Leak happens only when pre-rendering files. Used same test Nuxt installation, but without modules/prerender.ts, so it won't pre-render routes. Built server, started it, used separate process to fetch pages. No memory leak. Server works flawlessly. So leak happens only when pre-rendering routes. |
This is probably because we keep all payloads in memory:
We need to adopt a fs-backed cache for this. |
@cyberalien are you using nuxt-delay-hydration ? |
No |
Hi 👋 Any news about this bug or has this bug been prioritized in the roadmap? We're facing the same issue on our side when we use |
I just switched to SSR. No point in using SSG for so many pages. I'm using prerender only for most popular pages, which is about 200 pages, the rest are rendered on demand. Works flawlessly. No leaks. Downside is I need to run a node process, not just upload html, but a basic cheap VPS can easily handle that. Build process is faster, much fewer files to upload to server, so deployment is many times faster than SSG. Old version of website used Svelte with SSG, it took over 30 minutes to deploy. Now it takes 5. |
Same thing happening here. Only happens on generate. |
Environment
Darwin
v20.5.0
3.9.3
3.10.0
2.8.1
pnpm@8.14.1
-
devtools
-
-
Reproduction
https://github.com/cyberalien/nuxt-memory-test
Describe the bug
When there are many pages, Nuxt generates all pages one after another, memory usage always grows and eventually Node crashes with error about missing memory.
Demo repository has about 65k pages, generates using basic loops:
/[dir]/
-> directories, wheredir
is a number from 0 to 128 (converted to string). Links to all items in that directory./[dir]/[page]/
-> pages inside directories, wherepage
is a number from 0 to 512. Links to other pages in same directory and to other directories with same pages.So basically a simple 2 nested loops iterating number: 0 to 128 and 0 to 512, rendering all combinations of those numbers.
Additional context
When running generate, memory usage starts below 1gb, quickly goes over it, then eventually gets to 2gb and so on, until Node crashes. In my environment it took about 10 minutes for Node to crash, Nuxt generates 2390 files before crashing.
Logs
The text was updated successfully, but these errors were encountered: