Skip to content

Large project, JavaScript heap out of memory #3948

@uuksu

Description

@uuksu

Operating system

Debian 12

Eleventy

3.1.2

Describe the bug

Let's start by saying that I'm doing some unholy with Eleventy and maybe pushing it to the limits where it should not be pushed. But still, I'm suspecting that there might be some actual bug somewhere.

I have a project with around ~190k .liquid files. These files are built externally from a data source, by custom tool, made by me. Largest of the file is around 300 Kb, but most of the are under 50 Kb. Individual pages are content empty files, but they have a frontmatter with all the needed data. All the pages point to one common layout (and that uses default layout) and uses the data in the frontmatter. There is also a computed data in the layout that creates the title of the page from the pages frontmatter data.

I've tried to build the project simply by running

ELEVENTY_ENV=production npx @11ty/eleventy"

Eleventy does something for a long time (maybe 20-30 minutes) and then crashes. This leads to heap out of memory error mentioned in the title

<--- Last few GCs --->

[32711:0x456f1000]  1869082 ms: Scavenge 16180.2 (16513.7) -> 16180.2 (16513.7) MB, pooled: 0 MB, 240.00 / 0.00 ms  (average mu = 0.992, current mu = 0.990) allocation failure; 
[32711:0x456f1000]  1869317 ms: Scavenge 16180.2 (16513.7) -> 16180.2 (16513.7) MB, pooled: 0 MB, 235.14 / 0.00 ms  (average mu = 0.992, current mu = 0.990) allocation failure; 


<--- JS stacktrace --->

FATAL ERROR: Scavenger: semi-space copy Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0xe1603a node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
 2: 0x11e3540 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 3: 0x11e3817 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 4: 0x14110f5  [node]
 5: 0x14a13f4 heap::base::SlotCallbackResult v8::internal::Scavenger::ScavengeObject<v8::internal::FullHeapObjectSlot>(v8::internal::FullHeapObjectSlot, v8::internal::Tagged<v8::internal::HeapObject>) [node]
 6: 0x14a1a5f void v8::internal::BodyDescriptorBase::IteratePointers<v8::internal::ScavengeVisitor>(v8::internal::Tagged<v8::internal::HeapObject>, int, int, v8::internal::ScavengeVisitor*) [node]
 7: 0x14ad40e v8::internal::Scavenger::Process(v8::JobDelegate*) [node]
 8: 0x14ae1ef v8::internal::ScavengerCollector::JobTask::ProcessItems(v8::JobDelegate*, v8::internal::Scavenger*) [node]
 9: 0x14ae35a v8::internal::ScavengerCollector::JobTask::Run(v8::JobDelegate*) [node]
10: 0x21ce548 v8::platform::DefaultJobWorker::Run() [node]
11: 0xffba04  [node]
12: 0x7fafc60821f5  [/lib/x86_64-linux-gnu/libc.so.6]
13: 0x7fafc61028dc  [/lib/x86_64-linux-gnu/libc.so.6]

I tried first solution I found and increased the max memory size of V8's old memory section. By increasing this to 20 G, the Eleventy is able to do little bit more by writing couple of files (actually outside of the directory that contains the 190k files) but still ends up in the same error. That's a lot of memory so I'm thinking there must be leak somewhere.

When running with a Debug Mode (and with increased memory), last lines before the error are these

  Eleventy:ComputedData Computed data order of execution: [] +0ms
  Eleventy:Template Second round of computed data for './src/pages/thread/99998-1/99998.liquid' +0ms
  Eleventy:ComputedData Computed data order of execution: [] +0ms
  Eleventy:Template Second round of computed data for './src/pages/thread/99999-1/99999.liquid' +0ms
  Eleventy:ComputedData Computed data order of execution: [] +0ms
  Eleventy:Template Second round of computed data for './src/pages/thread/99997-1/99997.liquid' +0ms
  Eleventy:ComputedData Computed data order of execution: [] +0ms
  Eleventy:TemplateWriter Template map created. +0ms
  Eleventy:Transforms Running '@11ty/eleventy-bundle' transform on './src/pages/users.liquid': './_site/pages/users/index.html' +0ms
  Eleventy:Bundle Processing '/pages/users/' +0ms
  Eleventy:Transforms Running '@11ty/eleventy/html-transformer' transform on './src/pages/users.liquid': './_site/pages/users/index.html' +570ms
  Eleventy:Transforms Running '@11ty/eleventy-bundle/delayed' transform on './src/pages/users.liquid': './_site/pages/users/index.html' +41ms
  Eleventy:Logger Writing ./_site/pages/users/index.html from ./src/pages/users.liquid +0ms
  Eleventy:Template ./_site/pages/users/index.html written. +11m

I can provide more information if needed and even share the project privately if necessary.

Reproduction steps

  1. Run the build

Expected behavior

Eleventy should build the static website.

Reproduction URL

No response

Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions