Build command - JavaScript heap out of memory

Hi, @lukas123. We checked the memory use for that build and it didn’t exceed Netlify’s memory limits. However, it clearly is exceeding the default limits of node.js based on this:

8:28:32 PM: <--- Last few GCs --->
8:28:32 PM: [1401:0x5e54fb0]   156037 ms: Mark-sweep (reduce) 2030.1 (2051.0) -> 2029.0 (2052.7) MB, 656.1 / 0.0 ms  (average mu = 0.222, current mu = 0.060) allocation failure scavenge might not succeed
8:28:32 PM: [1401:0x5e54fb0]   156722 ms: Mark-sweep (reduce) 2030.1 (2054.2) -> 2029.5 (2054.5) MB, 682.1 / 0.0 ms  (average mu = 0.130, current mu = 0.004) allocation failure scavenge might not succeed
8:28:32 PM: <--- JS stacktrace --->
8:28:32 PM: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
8:28:32 PM:  1: 0xa3ac30 node::Abort() [/opt/buildhome/.nvm/versions/node/v14.21.2/bin/node]
8:28:32 PM:  2: 0x970199 node::FatalError(char const*, char const*) [/opt/buildhome/.nvm/versions/node/v14.21.2/bin/node]
8:28:32 PM:  3: 0xbba76e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/buildhome/.nvm/versions/node/v14.21.2/bin/node]
8:28:32 PM:  4: 0xbbaae7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/buildhome/.nvm/versions/node/v14.21.2/bin/node]
8:28:32 PM:  5: 0xd76d05  [/opt/buildhome/.nvm/versions/node/v14.21.2/bin/node]
8:28:32 PM:  6: 0xd7788f  [/opt/buildhome/.nvm/versions/node/v14.21.2/bin/node]
8:28:32 PM:  7: 0xd856cb v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/buildhome/.nvm/versions/node/v14.21.2/bin/node]
8:28:32 PM:  8: 0xd8928c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/buildhome/.nvm/versions/node/v14.21.2/bin/node]
8:28:32 PM:  9: 0xd5796b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/opt/buildhome/.nvm/versions/node/v14.21.2/bin/node]
8:28:32 PM: 10: 0x109ffbf v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/opt/buildhome/.nvm/versions/node/v14.21.2/bin/node]
8:28:32 PM: 11: 0x14491d9  [/opt/buildhome/.nvm/versions/node/v14.21.2/bin/node]

Your javascript (node) heap ran out of memory. You can increase it by adding an environment variable here:

https://app.netlify.com/sites/staging-pg-clinicy/settings/env

Please click the “Migrate environment variables” button and then add an environment variable named NODE_OPTIONS with a value of --max-old-space-size=4096 like so:

Create the variable to save it and now trigger a new deploy. This time node should run but allow more memory to be used for the javascript heap. This will hopefully resolve the “JavaScript heap out of memory” error.

​Please let us know if that works for you or not. If there are other questions, please feel free to share them here anytime.