Skip to content

FATAL ERROR: JavaScript heap out of memory #8329

Closed as not planned
Closed as not planned

Description

@rislaed

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

Too costly assembly for little documentation.
Inability to separate assembly of several documentations separately from each other.

Reproducible demo

https://github.com/Nernar/nernar.github.io/tree/a6f151ac0bececd79ee08649c4176a4c09a72698

Steps to reproduce

I've do some prebuilding before deploy:

  1. npm ci
  2. cd ./api
  3. npm ci
  4. npm run build:docs
  5. cd ..
  6. npm run build

But in any case, separately run npm run build gaves same results.

Expected behavior

Correctly assembling, I can't even get a single language version; increasing the amount of maximum memory for Node.js is far from the best solution. This temporarily solves the problem, but for the near future, a multiple increase in the number of documentation pages will be required.

Actual behavior

> [email protected] build
> docusaurus build

[INFO] Website will be built for all these locales: 
- en
- ru
[INFO] [en] Creating an optimized production build...
[info] [webpackbar] Compiling Client
[info] [webpackbar] Compiling Server
[success] [webpackbar] Client: Compiled successfully in 8.37m

<--- Last few GCs --->

[1819:0x621e840]  1372542 ms: Scavenge 1945.2 (2076.7) -> 1932.6 (2076.7) MB, 11.8 / 0.0 ms  (average mu = 0.332, current mu = 0.312) allocation failure; 
[1819:0x621e840]  1372619 ms: Scavenge 1948.5 (2078.5) -> 1935.1 (2078.5) MB, 16.2 / 0.0 ms  (average mu = 0.332, current mu = 0.312) allocation failure; 
[1819:0x621e840]  1372661 ms: Scavenge 1949.0 (2078.7) -> 1936.3 (2078.7) MB, 9.8 / 0.0 ms  (average mu = 0.332, current mu = 0.312) allocation failure; 


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb6e500 node::Abort() [node]
 2: 0xa7e632  [node]
 3: 0xd47ea0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xd48247 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xf[25](https://github.com/Nernar/nernar.github.io/actions/runs/3448410688/jobs/5755616270#step:8:26)605  [node]
 6: 0xf[26](https://github.com/Nernar/nernar.github.io/actions/runs/3448410688/jobs/5755616270#step:8:27)508 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
 7: 0xf36a13  [node]
 8: 0xf37888 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 9: 0xf121ee v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
10: 0xf135b7 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
11: 0xef478a v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
12: 0x12b7d2f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
13: 0x16e9979  [node]
Aborted (core dumped)
Error: Process completed with exit code 1[34](https://github.com/Nernar/nernar.github.io/actions/runs/3448410688/jobs/5755616270#step:8:35).

Screenshot_2022-11-12_16-25-56

Allocation sampling .heapprofile

Your environment

I've also tried with pretty same specs on GitHub Actions with ubuntu-latest.

Self-service

  • I'd be willing to fix this bug myself.

Activity

  1. added
    bug
    status: needs triage
    on Nov 12, 2022
  2. slorber commented on Nov 16, 2022

    @slorber
    Collaborator

    Thanks for the repro and heap dump 👍

    Are aware of the high memory usage of Docusaurus, let's track this here: #4765

    increasing the amount of maximum memory for Node.js is far from the best solution.

    Unfortunately, Docusaurus v2 has been initially architectured by loading everything into memory, so it's unlikely we'll be able to fix this in the near future with a completely new streaming architecture.

    There are some production build phases that are more memory intensive and we'll try to optimize them but I think it's unlikely a very large site will ever be able to build with the default NodeJS options on our current architecture.

  3. added
    pr: performance
    status: needs triage
    domain: performance
    and removed
    status: needs triage
    pr: performance
    on Nov 16, 2022
  4. sporritt commented on Jun 20, 2023

    @sporritt

    I came across this problem today and resolved it by bumping the heap available to node:

    export NODE_OPTIONS=--max-old-space-size=10248
    npm run build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdomain: performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions