Search code examples
javascriptreactjstypescriptcreate-react-appyarnpkg

How do I find out what code is causing JavaScript heap out of memory


I'm trying to run yarn start but get this:

Starting the development server...

ts-loader: Using typescript@3.9.10 and C:\DevTools\git\mymoto\tsconfig.json

<--- Last few GCs --->

[9076:000001F4910F0DA0] 120343 ms: Mark-sweep (reduce) 2045.0 (2051.8) -> 2044.3 (2053.0) MB, 1410.7 / 0.0 ms (average mu = 0.123, current mu = 0.011) allocation failure scavenge might not succeed [9076:000001F4910F0DA0] 122662 ms: Mark-sweep (reduce) 2045.4 (2052.0) -> 2044.6 (2053.0) MB, 2288.3 / 0.0 ms (average mu = 0.057, current mu = 0.013) allocation failure scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 00007FF79BA7021F napi_wrap+109311 2: 00007FF79BA15286 v8::internal::OrderedHashTable<v8::internal::OrderedHashSet,1>::NumberOfElementsOffset+33302 3: 00007FF79BA16056 node::OnFatalError+294 4: 00007FF79C2E054E v8::Isolate::ReportExternalAllocationLimitReached+94 5: 00007FF79C2C53CD v8::SharedArrayBuffer::Externalize+781 6: 00007FF79C16F85C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1516 7: 00007FF79C17AB9A v8::internal::Heap::ProtectUnprotectedMemoryChunks+1258 8: 00007FF79C177D49 v8::internal::Heap::PageFlagsAreConsistent+2457 9: 00007FF79C16C971 v8::internal::Heap::CollectGarbage+2033 10: 00007FF79C16AB75 v8::internal::Heap::AllocateExternalBackingStore+1317 11: 00007FF79C18AF67 v8::internal::Factory::NewFillerObject+183 12: 00007FF79BEBAFF1 v8::internal::interpreter::JumpTableTargetOffsets::iterator::operator=+1409 13: 00007FF79C368EFD v8::internal::SetupIsolateDelegate::SetupHeap+463949 14: 000001177FAE26D4

I've seen a few questions on here they all seem to suggest something along the lines of node --max_old_space_size=8048. In most cases the question has highlighted the code which causes this. I can't figure out what this is. How do I find out what is causing the issue? I'd like to initially see if there's anything wrong there rather than blindly trying something.

Could having a copy of my node_modules folder in the project folder cause this in any way?


Solution

  • I had my node_modules folder and also a node_modules_backup. When I deleted node_modules_backup the issue was resolved.