How to troubleshoot FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Expo CLI 3.22.3 environment info:
OS: macOS 11.2
Shell: 3.2.57 - /bin/bash
Node: 12.18.3 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 7.5.4 - /usr/local/bin/npm
Android Studio: 3.6 AI-192.7142.36.36.6241897
Xcode: 12.3/12C33 - /usr/bin/xcodebuild
expo: ^40.0.0 => 40.0.1
react: 16.13.1 => 16.13.1
react-dom: 16.13.1 => 16.13.1
react-native: => 0.63.2
react-native-web: ~0.13.12 => 0.13.18
react-navigation: ^4.4.3 => 4.4.3
expo-cli: 3.22.3

Running the app with expo start and then connecting via a physical device or the ios simulator worked fine up until an npm update I did yesterday. I also updated my expo SDK version to 40. Since these updates I cannot run the app on a device or simulator. The dev server starts up fine, then when I connect a device it always gets to 99% then hangs - after about 5 mins I get the following (some paths redacted):

transform[stdout]: <— Last few GCs —>
transform[stdout]: [27672:0x102d56000] 139380 ms: Mark-sweep 2028.6 (2054.6) → 2028.6 (2054.6) MB, 3893.0 / 0.0 ms (average mu = 0.085, current mu = 0.000) allocation failure scavenge might not succeed
transform[stdout]: [27672:0x102d56000] 143468 ms: Mark-sweep 2028.6 (2054.6) → 2028.6 (2054.6) MB, 4088.1 / 0.0 ms (average mu = 0.039, current mu = 0.000) last resort GC in old space requested
transform[stdout]: <— JS stacktrace —>
transform[stdout]: ==== JS stack trace =========================================
transform[stdout]: 0: ExitFrame [pc: 0x1009d39b9]
transform[stdout]: Security context: 0x318f3d3408d1
transform[stdout]: 1: join [0x318f3d3555f9](this=0x318f651c9929 <JSArray[2830092]>,0x318f7de40731 <String[#0]: >)
transform[stdout]: 2: get [0x318febbf2d99] [/native/node_modules/@babel/generator/lib/buffer.js:34] [bytecode=0x318f700801c1 offset=47](this=0x318f835a68c1 )
transform[stdout]: 3: generate [0x318f537880a1] [/
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
transform[stderr]: 1: 0x1011c2ff5 node::Abort() (.cold.1) [/usr/local/bin/node]
transform[stderr]: 2: 0x10009fbc9 node::Abort() [/usr/local/bin/node]
transform[stderr]: 3: 0x10009fd2f node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
transform[stderr]: 4: 0x1001e3907 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
transform[stderr]: 5: 0x1001e38a7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
transform[stderr]: 6: 0x1003695e5 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
transform[stderr]: 7: 0x10036ae3a v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
transform[stderr]: 8: 0x1003678be v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
transform[stderr]: 9: 0x100365670 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
transform[stderr]: 10: 0x100365c43 v8::internal::Heap::CollectAllAvailableGarbage(v8::internal::GarbageCollectionReason) [/usr/local/bin/node]
transform[stderr]: 11: 0x10037155e v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
transform[stderr]: 12: 0x1003418eb v8::internal::factory::NewRawTwoByteString(int, v8::internal::AllocationType) [/usr/local/bin/node]
transform[stderr]: 13: 0x10068f6a7 v8::internal::Runtime_AllocateSeqTwoByteString(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
transform[stderr]: 14: 0x1009d39b9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
transform[stderr]: 15: 0x1009e7c3b Builtins_ArrayPrototypeJoin [/usr/local/bin/node]

As this only seems to have occured because of an update to my dependencies I’m wondering what the best way to troubleshoot this is. I’ve seen posts online about increasing --max-old-space-size when running but this doesn’t seem to make any difference. Other posts suggest hunting for a memory leak but seeing as this wasn’t a problem before I updated my dependencies and nothing else has changed this doesn’t seem likely. Is there anywhere I can find a more detailed log etc that will give me more information?

Hey @ewyllie, your expo-cli version is rather outdated. Could you try installing the latest version to see if that remedies the situation?


I have expo-cli 4.1.6 and have the same issue. It only happened after I tried to include the aws-sdk into my project

I updated expo-cli (4.3.0) and the same issue is happening with me when I run expo publish.

If anyone is interested, as avatarofwoo says the issue turned out to be related to the aws-sdk. I created a new project that contained nothing except an aws-sdk import and the issue still occurred. I can’t remember where I found the solution, but it was specifically when importing the S3 module that caused this to happen. When I created this issue the way to import S3 according to the aws documentation was something like:

import AWS from "aws-sdk";
const s3 = new AWS.S3({<config>});

It looks like they have now updated it (at least on NPM), as this problem will happen if you do the above. Instead use:

import S3 from "aws-sdk/clients/s3";
const s3 = new S3({<config>});

I hope this helps. To troubleshoot I’d recommend just trying each of your module imports (start with the biggest ones like SDK’s) in a new blank project to see if they cause the issue. I know it’s a pain and can take quite some time but it helped me start looking for the solution instead of looking for the problem.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.