JavaScript heap out of memory
Environment
-
Operating System:
Darwin -
Node Version:
v22.16.0 -
Nuxt Version:
3.17.5 -
CLI Version:
3.25.1 -
Nitro Version:
2.11.12 -
Package Manager:
[email protected] -
Builder:
- -
User Config:
ignore,router,experimental,app,scripts,devtools,modules,feed,i18n,image,css,nitro,hooks,site,sitemap,linkChecker,schemaOrg,vite,compatibilityDate -
Runtime Modules:
@nuxt/[email protected],@nuxt/[email protected],@nuxt/[email protected],@nuxt/[email protected],@nuxt/[email protected],@nuxtjs/[email protected],@nuxtjs/[email protected],[email protected] -
Build Modules:
-
Version
v2.23.4
Reproduction
I can provide a reproduction shortly
Description
Hi team, I'm experiencing significant memory issues when running generate with Nuxt Content and wanted to check if this is expected behavior or if I'm missing a configuration option. Context:
- ~4,000 routes (GitLab Blog)
- Content stored as .yml files
- Using a [...slug].vue catch-all route with a data fetching composable
Our Setup:
export const useGitlabContent = async () => {
const { locale } = useI18n();
const { params, path } = useRoute();
const slug = `/${locale.value.toLowerCase()}/${params.slug ? params.slug.join('/') : ''}`;
const { data } = await useAsyncData(slug, () => queryContent(slug).findOne());
if (!data.value) {
throw createError({
statusCode: 404,
message: `Page not found in the content library: ${path}`,
});
}
return data.value;
};
The Issue: During static generation, memory usage grows linearly until hitting Node's heap limit. Here's what we've observed:
- Memory grows from ~200MB to 8GB across 4,000 routes
- Forcing GC every 30 seconds has minimal effect (<5% memory freed)
- Heap snapshots show ~1GB in LRU cache with rendered markdown content
- Memory is retained throughout the entire build, never released
Attempted Solutions:
- Enabled sharedPrerenderData: true to reduce duplicate queries
- Split generation into 2 parallel jobs and merged outputs (not ideal)
- Increased Node heap size to 8GB
- Forced garbage collection during build
Questions:
- Are there recommended settings for generating sites with thousands of content files?
- Is this linear memory growth expected behavior, or might we have misconfigured something?
For large static sites, it seems like the content cache is working against us by retaining all processed content in memory. Any guidance on optimizing memory usage during generation would be greatly appreciated. Thanks!
Additional context
No response
Logs