nuxt: JavaScript heap out of memory in Dev env, several times a day
Version
Reproduction link
Steps to reproduce
After programming some hours in dev env, node server crashs with this error :
<--- Last few GCs --->
[47073:0x104800000] 7043097 ms: Mark-sweep 1380.1 (1424.3) -> 1380.0 (1424.8) MB, 1170.5 / 0.0 ms (average mu = 0.159, current mu = 0.001) allocation failure scavenge might not succeed
[47073:0x104800000] 7044402 ms: Mark-sweep 1380.7 (1424.8) -> 1380.6 (1425.3) MB, 1301.5 / 0.0 ms (average mu = 0.080, current mu = 0.003) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0xa30765cfb7d]
Security context: 0x0da72a89d8c1 <JSObject>
1: parsePath(aka parsePath) [0xda7b3e73391] [/Users/pro/Documents/CLIENTS/node_modules/vue/dist/vue.runtime.common.dev.js:~497] [pc=0xa30788a252d](this=0x0da7414025b1 <undefined>,0x0da7391ee3c1 <String[10]: inputValue>)
2: initWatch(aka initWatch) [0xda7b3e75921] [/Users/pro/Documents/CLIENTS/node_mo...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x100061233 node::Abort() [/usr/local/bin/node]
2: 0x10006184d node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
3: 0x100167953 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
4: 0x1001678f4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
5: 0x1004288e8 v8::internal::Heap::UpdateSurvivalStatistics(int) [/usr/local/bin/node]
6: 0x10042a305 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/usr/local/bin/node]
7: 0x100427c7d v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
8: 0x100426a73 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
9: 0x10042e941 v8::internal::Heap::AllocateRawWithLightRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
10: 0x10042e990 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
11: 0x10040ed57 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
12: 0x1005ec896 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
13: 0xa30765cfb7d
14: 0xa30788a252d
Abort trap: 6
I’m not able give any reproduce repo due to the confidentiality of my project.
I’m using nuxt-apollo in this project, not sure if it can related with this memory leaks.
What is expected ?
Having a server running correctly
What is actually happening?
Server crash several (≈ 2-6) times a day
Additional comments?
Thanks for your help !
<div align="right">This bug report is available on Nuxt community (#c8943)</div>About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 23
- Comments: 43 (4 by maintainers)
For everyone who faces this problem. Try to bump memory limit with
max-old-space-sizenode optimization flag, but use it correctly. As example:And example for TS guys:
If you still get errors, allocate some more memory
--max-old-space-size=8192etc. If you don’t have enough memory on the node, try to add flag--optimize_for_size, this will allow less memory to be allocated, but may affect performance and give some errors in theory.Can confirm this is still happening in Nuxt 2.14.0
this is still happening to me. I am running
npm run devand if i try to loadlocalhost:3000it either never loads or crashes the server.+1
@clarkdo I’m now on Nuxt 2.6.1 and I still have memory leaks 😕 Today, it happened a couple of time with this error:
Thanks again for you help
i’m still having memory leak in
3.6.3After a few hours of trying to find the issue, I’ve found the fix for me.
If you are using the
"@nuxtjs/auth-next"and"@nuxtjs/axios"module with proxy enabled in axios. Try setting thebaseUrloption in axios to"/", this fixed the issue for me.even tho the nuxt axios docs says: “WARNING: baseURL and proxy cannot be used at the same time, so when the proxy option is in use, you need to define prefix instead of baseURL.”
There is a problem with an infinite loop or something.
Hello! I have similar problem. node v14.18.2 “nuxt”: “2.16.3”
<— Last few GCs —>
[2620:00000271AC58CC40] 422814 ms: Scavenge 1935.3 (2028.1) -> 1923.9 (2028.1) MB, 21.6 / 0.0 ms (average mu = 0.727, current mu = 0.560) allocation failure [2620:00000271AC58CC40] 423588 ms: Scavenge 1935.7 (2028.1) -> 1925.7 (2028.1) MB, 35.5 / 0.0 ms (average mu = 0.727, current mu = 0.560) task [2620:00000271AC58CC40] 424582 ms: Scavenge 1954.8 (2053.4) -> 1951.1 (2053.4) MB, 16.1 / 0.0 ms (average mu = 0.727, current mu = 0.560) allocation failure
<— JS stacktrace —>
FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory 1: 00007FF682C8428F napi_wrap+133311 2: 00007FF682C1DE66 SSL_get_quiet_shutdown+63062 3: 00007FF682C1ECFD node::OnFatalError+301 4: 00007FF683501B2E v8::Isolate::ReportExternalAllocationLimitReached+94 5: 00007FF6834E691D v8::SharedArrayBuffer::Externalize+781 6: 00007FF68339012C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1516 7: 00007FF68337ABAB v8::internal::NativeContextInferrer::Infer+59739 8: 00007FF68335FE7F v8::internal::MarkingWorklists::SwitchToContextSlow+56975 9: 00007FF683373B6B v8::internal::NativeContextInferrer::Infer+31003 10: 00007FF68336AC4D v8::internal::MarkCompactCollector::EnsureSweepingCompleted+6285 11: 00007FF683372DBE v8::internal::NativeContextInferrer::Infer+27502 12: 00007FF683376E0B v8::internal::NativeContextInferrer::Infer+43963 13: 00007FF683380802 v8::internal::ItemParallelJob::Task::RunInternal+18 14: 00007FF683380791 v8::internal::ItemParallelJob::Run+641 15: 00007FF683353DF3 v8::internal::MarkingWorklists::SwitchToContextSlow+7683 24: 00007FF6833A5705 v8::internal::Factory::AllocateRaw+37 25: 00007FF6833B9D7F v8::internal::FactoryBasev8::internal::Factory::NewRawTwoByteString+79 26: 00007FF6833B4135 v8::internal::Factory::NewStringFromUtf8+181 27: 00007FF6834FD7FF v8::String::NewFromUtf8+287 28: 00007FF682B39B31 v8::internal::WasmTableObject::WasmTableObject+33409 29: 00007FF682C3968B v8::internal::Malloced::operator delete+4107 30: 00007FF683523FAC v8::internal::SetupIsolateDelegate::SetupHeap+44252 31: 000000539E73595B error Command failed with exit code 134.
Still got this problem… Looks something plays in infinite loop but I don’t know what it is.
An alternative to modifying the script commands:
NODE_OPTIONS=--max_old_space_size=4096 npm run buildIn my case this was only a build issue that i needed to do on a one offThank you @clarkdo for your fix ! Unfortunately I still have memory leaks troubles 😕
My server crashed again today with this error:
Thanks for help
Fresh install here, runs for like 10 minutes and the crashes over and over again with the same memory issue.
@ajahongir i traced it to tailwind css module https://github.com/nuxt-modules/tailwindcss/issues/745#issuecomment-1817920731 not using nuxt anymore it’s better to be safe than sorry
In my case everything works fine, the build and dev process, but when I build the project and it creates the dist folder, and then run npm run dev, the project shows the out of memory error.
So you need to delete all files created by nuxt, install again and run npm run dev
But I dont know why
I solved the problem like this. LINK // nginx config