FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

I cannot resolve issue :(, my project using use nuxt 3
My site: littlespace.vn

> 9:27:10 AM: Packaging Functions from .netlify/functions-internal directory:
> 9:27:10 AM:  - server/server.mjs
> 9:27:10 AM: ​
> 9:27:55 AM: <--- Last few GCs --->
> 9:27:55 AM: [4079:0x5e77430]    57413 ms: Mark-sweep 4052.5 (4133.9) -> 4052.5 (4133.9) MB, 4471.6 / 0.0 ms  (average mu = 0.165, current mu = 0.015) allocation failure; scavenge might not succeed
> 9:27:55 AM: [4079:0x5e77430]    63098 ms: Mark-sweep 4068.2 (4133.9) -> 4068.2 (4165.9) MB, 5678.0 / 0.0 ms  (average mu = 0.077, current mu = 0.001) allocation failure; scavenge might not succeed
> 9:27:55 AM: <--- JS stacktrace --->
> 9:27:55 AM: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
> 9:27:55 AM:  1: 0xb7a940 node::Abort() [/opt/buildhome/node-deps/node]
> 9:27:55 AM:  2: 0xa8e823  [/opt/buildhome/node-deps/node]
> 9:27:55 AM:  3: 0xd5c990 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/buildhome/node-deps/node]
> 9:27:55 AM:  4: 0xd5cd37 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/buildhome/node-deps/node]
> 9:27:55 AM:  5: 0xf3a435  [/opt/buildhome/node-deps/node]
> 9:27:55 AM:  6: 0xf4c91d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/buildhome/node-deps/node]
> 9:27:55 AM:  7: 0xf2701e v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/buildhome/node-deps/node]
> 9:27:55 AM:  8: 0xf283e7 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/buildhome/node-deps/node]
> 9:27:55 AM:  9: 0xf095ba v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/opt/buildhome/node-deps/node]
> 9:27:55 AM: 10: 0x12ce7ff v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/opt/buildhome/node-deps/node]
> 9:27:55 AM: 11: 0x16fb6f9  [/opt/buildhome/node-deps/node]
> 9:27:59 AM: /opt/build-bin/build: line 126:  4079 Aborted                 (core dumped) FORCE_COLOR=1 $netlify_build_node_bin $netlify_build_bin --cwd=$repository_root --repositoryRoot=$repository_root --config=$configuration_file_path --branch=$branch --siteId=$site_id --defaultConfig=$default_config --baseRelDir=$base_rel_dir --context=$context --node-path=$user_node_path --cachedConfigPath=$cached_netlify_build_config_file --api-host=$netlify_endpoint --token=$netlify_token --build-id=$BUILD_ID --deploy-id=$DEPLOY_ID --mode=buildbot --telemetry=$build_telemetry --send-status --save-config --statsd.host=$HOST_NODE_IP --statsd.port=$STATSD_PORT --tracing.enabled=$tracing_enabled --tracing.host=$HOST_NODE_IP --tracing.traceId=$trace_id --tracing.parentSpanId=$parent_span_id --tracing.traceFlags=$trace_flags --functions-dist-dir=$functions_dist_dir --edge-functions-dist-dir=$edge_functions_dist_dir --cache-dir=$cache_dir --buildbot-server-socket=$buildbot_server_socket --framework=$framework --feature-flags=$feature_flags --testOpts.silentLingeringProcesses=$SILENT_LINGERING_PROCESSES --system-log-file=$system_log_file --explicit-secret-keys=$explicit_secret_keys
> 9:28:44 AM: Failed during stage 'building site': Build script returned non-zero exit code: 134 (https://ntl.fyi/exit-code-134)
> 9:28:44 AM: Error running command: Build script returned non-zero exit code: 134
> 9:28:44 AM: Failing build: Failed to build site
> 9:28:44 AM: Finished processing build request in 2m31.308s

@glorfindel9 You’re running out of memory.

If you’re doing something that you know to be intensive you should look at optimizing it.

can i increase heap memory size?

@glorfindel9 There’s some limited capability for adjustment, see the support guide here:

1 Like

I don’t know how to fix it one build goes ok and next one faild and it last for three days now. I change almost nothing in my code. Please help

11:58:32 AM: success Building production JavaScript and CSS bundles - 27.161s
11:59:02 AM: <--- Last few GCs --->
11:59:02 AM: [3922:0x6de7ba0]    85135 ms: Scavenge (reduce) 1895.5 (2080.4) -> 1895.4 (2081.6) MB, 4.3 / 0.0 ms  (average mu = 0.210, current mu = 0.220) allocation failure;
11:59:02 AM: [3922:0x6de7ba0]    85142 ms: Scavenge (reduce) 1896.6 (2081.6) -> 1896.5 (2082.6) MB, 4.9 / 0.0 ms  (average mu = 0.210, current mu = 0.220) allocation failure;
11:59:02 AM: [3922:0x6de7ba0]    85148 ms: Scavenge (reduce) 1897.5 (2082.6) -> 1897.4 (2083.6) MB, 4.7 / 0.0 ms  (average mu = 0.210, current mu = 0.220) allocation failure;
11:59:02 AM: <--- JS stacktrace --->
11:59:02 AM: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
11:59:02 AM:  1: 0xb87bc0 node::Abort() [node]
11:59:02 AM:  2: 0xa96834  [node]
11:59:02 AM:  3: 0xd687f0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
11:59:02 AM:  4: 0xd68b97 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
11:59:02 AM:  5: 0xf462a5  [node]
11:59:02 AM:  6: 0xf471a8 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
11:59:02 AM:  7: 0xf576b3  [node]
11:59:02 AM:  8: 0xf58528 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
11:59:02 AM:  9: 0xf32e8e v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
11:59:02 AM: 10: 0xf34257 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
11:59:02 AM: 11: 0xf147a0 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [node]
11:59:02 AM: 12: 0xf0c214 v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [node]
11:59:02 AM: 13: 0xf0e5a8 v8::internal::FactoryBase<v8::internal::Factory>::NewRawTwoByteString(int, v8::internal::AllocationType) [node]
11:59:02 AM: 14: 0x133ff6c v8::internal::IncrementalStringBuilder::Extend() [node]
11:59:02 AM: 15: 0x1055450 v8::internal::JsonStringifier::SerializeString(v8::internal::Handle<v8::internal::String>) [node]
11:59:02 AM: 16: 0x10568f1 v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<true>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>) [node]
11:59:02 AM: 17: 0x105ad2f v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<false>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>) [node]
11:59:02 AM: 18: 0x105ba7f v8::internal::JsonStringify(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>) [node]
11:59:02 AM: 19: 0xdee7a7 v8::internal::Builtin_JsonStringify(int, unsigned long*, v8::internal::Isolate*) [node]
11:59:02 AM: 20: 0x170a179  [node]
11:59:04 AM: Aborted (core dumped)
11:59:04 AM: ​
11:59:04 AM: build.command failed                                        
11:59:04 AM: ────────────────────────────────────────────────────────────────
11:59:04 AM: ​
11:59:04 AM:   Error message
11:59:04 AM:   Command failed with exit code 134: npm run build (https://ntl.fyi/exit-code-134)
11:59:04 AM: ​
11:59:04 AM:   Error location
11:59:04 AM:   In Build command from Netlify app:
11:59:04 AM:   npm run build
11:59:04 AM: ​
11:59:04 AM:   Resolved config
11:59:04 AM:   build:
11:59:04 AM:     command: npm run build
11:59:04 AM:     commandOrigin: ui
11:59:04 AM:     environment:
11:59:04 AM:       - GATSBY_DISQUS_NAME
11:59:04 AM:       - REGIONS_ALLOWED
11:59:04 AM:       - WPGRAPHQL_URL
11:59:04 AM:       - YOUTUBE_DATA_API_V3_API_KEY
11:59:04 AM:     publish: /opt/build/repo/public
11:59:04 AM:     publishOrigin: ui
11:59:04 AM:   plugins:
11:59:04 AM:     - inputs: {}
11:59:04 AM:       origin: ui
11:59:04 AM:       package: '@netlify/plugin-gatsby'
11:59:04 AM:     - inputs: {}
11:59:04 AM:       origin: ui
11:59:04 AM:       package: '@netlify/plugin-lighthouse'
11:59:04 AM:   redirects:
11:59:06 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
11:59:06 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:59:06 AM: Failing build: Failed to build site
11:59:07 AM: Finished processing build request in 2m32.761s

can you share the link to your site?

Sure here it is: