Haz Issac
Haz Issac

Reputation: 1

React Native : FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory in React

I got this problem in my project. I have already searched all solutions available online but can't find anything that can solve my issue..

<--- Last few GCs --->

[1884:0x105805200]   415338 ms: Mark-sweep 2010.8 (2087.2) -> 1994.5 (2087.5) MB, 5902.5 / 0.1 ms  (average mu = 0.149, current mu = 0.059) allocation failure scavenge might not succeed
[1884:0x105805200]   425392 ms: Mark-sweep 2010.9 (2087.5) -> 1994.6 (2087.2) MB, 9442.2 / 0.1 ms  (average mu = 0.101, current mu = 0.061) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10135cf15 node::Abort() (.cold.1) [/usr/local/bin/node]
 2: 0x1000bcbe9 node::Abort() [/usr/local/bin/node]
 3: 0x1000bcd4f node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x10022cbc7 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0x10022cb63 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 6: 0x1003e7205 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 7: 0x1003e8dc3 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
 8: 0x1003e4e2f v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
 9: 0x1003e27bd v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
10: 0x1003f041a v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
11: 0x1003f04a1 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
12: 0x1003bd3cd v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
13: 0x100742def v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
14: 0x100abf679 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
15: 0x3c7a98d52181 
16: 0x3c7a9916806c 
Abort trap:  6

how can I fixed this?

Upvotes: 0

Views: 450

Answers (1)

Oskar
Oskar

Reputation: 366

There are two ways you can increase the memory allocated to node:

In your terminal, export NODE_OPTIONS="--max-old-space-size=4096". As explained here, be mindful of how much memory you allocate.

You can also specify this as a setting in your app level build.gradle file:

project.ext.react = [
    nodeExecutableAndArgs: ["node", "--max-old-space-size=4096"]
]

Upvotes: 1

Related Questions