Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory #10137

Closed
erossignon opened this issue Dec 6, 2016 · 44 comments
Labels
memory Issues and PRs related to the memory management or memory footprint.

Comments

@erossignon
Copy link

erossignon commented Dec 6, 2016

  • Version: 7.2.0
  • Platform: MacOS, Ubuntu 16.04, Windows
  • Subsystem:
  testing add new ObjectType 

<--- Last few GCs --->

[8138:0x102801600]   145460 ms: Mark-sweep 1265.6 (1301.6) -> 1265.6 (1308.6) MB, 289.8 / 0.0 ms  allocation failure GC in old space requested
[8138:0x102801600]   145740 ms: Mark-sweep 1265.6 (1308.6) -> 1265.6 (1277.6) MB, 280.6 / 0.0 ms  last resort gc 
[8138:0x102801600]   146035 ms: Mark-sweep 1265.6 (1277.6) -> 1265.6 (1277.6) MB, 295.0 / 0.0 ms  last resort gc 


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x39c891dc0d31 <JS Object>
    1: DoJoin(aka DoJoin) [native array.js:~97] [pc=0x5d1facabad4](this=0x39c891d04311 <undefined>,q=0x5a024bf3be1 <JS Array[2241635]>,r=2241635,F=0x39c891d043b1 <true>,B=0x39c891ddafe9 <String[1]\: \n>,A=0x39c891d04421 <false>)
    2: Join(aka Join) [native array.js:~122] [pc=0x5d1fb5cde96](this=0x39c891d04311 <undefined>,q=0x5a024bf3be1 <JS Array[2241635]>,r=2241635,B=0x39c891ddafe9 <String[1...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/Users/erossignon/.nvm/versions/node/v7.2.0/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/Users/erossignon/.nvm/versions/node/v7.2.0/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/Users/erossignon/.nvm/versions/node/v7.2.0/bin/node]
 4: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/Users/erossignon/.nvm/versions/node/v7.2.0/bin/node]
 5: v8::internal::Runtime_StringBuilderJoin(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/erossignon/.nvm/versions/node/v7.2.0/bin/node]
 6: 0x5d1faa063a7
Abort trap: 6

  • How to reproduce:

On ubuntu 16.04 for instance, install node 7.20 , and run the following commands

git clone https://github.com/node-opcua/node-opcua
cd node-opcua
npm i
npm test
  • Note:
    Node-opcua only fails with node 7.2 and works perfecrlt with any version of node (0.12,4.xx,6.9.1)
@bnoordhuis
Copy link
Member

Does it work with v7.1.0? Does it work with --max_old_space_size=2048 or more?

By the way, the stack trace indicates that the process is running out of memory because it can't concatenate two (presumably large) strings. You might have just been lucky and skimmed the edge with older versions.

@abenhamdine
Copy link

abenhamdine commented Dec 6, 2016

I'm also running into something quite similar in our production instance since we updated from 6.9.1 to 7.2.0 :

<--- Last few GCs --->
2016-12-06T12:56:26.431+01:00[1024:0x27c39d0] 5842206 ms: Scavenge 66.5 (97.0) -> 66.3 (97.0) MB, 73.2 / 2.7 ms allocation failure
2016-12-06T12:56:26.525+01:00[1024:0x27c39d0] 5842305 ms: Scavenge 66.5 (97.0) -> 66.5 (98.0) MB, 58.4 / 6.1 ms allocation failure
2016-12-06T12:56:26.590+01:00[1024:0x27c39d0] 5843081 ms: Scavenge 67.2 (98.0) -> 66.9 (98.0) MB, 35.2 / 1.2 ms allocation failure
2016-12-06T12:56:26.685+01:00[1024:0x27c39d0] 5843100 ms: Scavenge 66.9 (98.0) -> 66.9 (99.0) MB, 4.6 / 0.0 ms allocation failure
2016-12-06T12:56:26.749+01:00<--- JS stacktrace --->
2016-12-06T12:56:26.841+01:00==== JS stack trace =========================================
2016-12-06T12:56:26.905+01:00Security context: 0x159c394c0d31 <JS Object>
2016-12-06T12:56:26.996+01:00 1: indexOf [native string.js:~32] [pc=0x273af67a6f02](this=0xc5afded4551 <Very long string[112385]>,s=0x159c394da1e1 <String[1]\: \n>,t=0)
2016-12-06T12:56:27.160+01:00 2: onread [internal/child_process.js:454] [pc=0x273af752eddd](this=0x29cdf048ab09 <a Pipe with map 0x2458e015769>,nread=65536,pool=0xc5afdeb4649 <an Uint8Array with map 0x2c1c515a13d9>,recvHandle=0x159c39404311 <undefined>)
2016-12-06T12:56:27.235+01:00==== Details ============...
2016-12-06T12:56:27.326+01:00FATAL ERROR: Committing semi space failed. Allocation failed - process out of memory
2016-12-06T12:56:27.424+01:001: node::Abort() [node]
2016-12-06T12:56:27.488+01:002: 0x126492c [node]
2016-12-06T12:56:27.585+01:003: v8::Utils::ReportOOMFailure(char const*, bool) [node]
2016-12-06T12:56:27.603+01:004: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
2016-12-06T12:56:28.275+01:005: v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
2016-12-06T12:56:28.381+01:006: v8::internal::Heap::CollectGarbage(v8::internal::GarbageCollector, char const*, char const*, v8::GCCallbackFlags) [node]
2016-12-06T12:56:28.500+01:007: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [node]
2016-12-06T12:56:28.748+01:00ANOM_ABEND auid=4294967295 uid=1000 gid=1000 ses=4294967295 subj=kernel pid=1024 comm="node" exe="/home/bas/.nvm/versions/node/v7.2.0/bin/node" sig=6
2016-12-06T12:56:29.391+01:008: v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [node]
2016-12-06T12:56:29.436+01:009: v8::internal::String::Flatten(v8::internal::Handle<v8::internal::String>, v8::internal::PretenureFlag) [node]
2016-12-06T12:56:29.491+01:0010: v8::internal::String::IndexOf(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::String>, int) [node]
2016-12-06T12:56:29.539+01:0011: v8::internal::Runtime_StringIndexOf(int, v8::internal::Object**, v8::internal::Isolate*) [node]
2016-12-06T12:56:29.541+01:0012: 0x273af37063a7
2016-12-06T12:56:35.317+01:00ANOM_ABEND auid=4294967295 uid=1000 gid=1000 ses=4294967295 subj=kernel pid=1014 comm="npm" exe="/home/bas/.nvm/versions/node/v7.2.0/bin/node" sig=6
2016-12-06T12:56:35.576+01:00/home/bas/rubydeployer/scripts/deploy-node.sh: line 23: 1014 Aborted (core dumped) npm start

The instance has 2048Mo of memory.

I'm currently investigating if the problem is present when we go back on 6.9.1

@erossignon
Copy link
Author

erossignon commented Dec 6, 2016

  • Version : 7.10 same error

With or without

Command run (to narrow the issue a little bit):

node  --max_old_space_size=2048  ./node_modules/.bin/mocha test/address_space/test_address_space_add_object_type.js 
<--- Last few GCs --->

[9296:0x103000c00]   139535 ms: Mark-sweep 1286.0 (1315.8) -> 1265.5 (1311.6) MB, 298.8 / 0.0 ms  allocation failure GC in old space requested
[9296:0x103000c00]   139814 ms: Mark-sweep 1265.5 (1311.6) -> 1265.5 (1277.6) MB, 278.9 / 0.0 ms  last resort gc 
[9296:0x103000c00]   140104 ms: Mark-sweep 1265.5 (1277.6) -> 1265.5 (1277.6) MB, 290.7 / 0.0 ms  last resort gc 


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x19c04f0c0d11 <JS Object>
    1: DoJoin(aka DoJoin) [native array.js:~97] [pc=0x3d004bbadbf4](this=0x19c04f004311 <undefined>,q=0x17a8c2085899 <JS Array[2241635]>,r=2241635,F=0x19c04f0043b1 <true>,B=0x19c04f0dafc9 <String[1]\: \n>,A=0x19c04f004421 <false>)
    2: Join(aka Join) [native array.js:~122] [pc=0x3d004c4970b6](this=0x19c04f004311 <undefined>,q=0x17a8c2085899 <JS Array[2241635]>,r=2241635,B=0x19c04f0dafc9 <Stri...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/Users/erossignon/.nvm/versions/node/v7.1.0/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/Users/erossignon/.nvm/versions/node/v7.1.0/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/Users/erossignon/.nvm/versions/node/v7.1.0/bin/node]
 4: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/Users/erossignon/.nvm/versions/node/v7.1.0/bin/node]
 5: v8::internal::Runtime_StringBuilderJoin(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/erossignon/.nvm/versions/node/v7.1.0/bin/node]
 6: 0x3d004b9063a7
Abort trap: 6

@bnoordhuis
Copy link
Member

By the looks of it, you have a call to Array.prototype.join somewhere that hits the memory limit. Increase --max_old_space_size enough and it should eventually pass, if the system has enough real memory.

@mscdex mscdex added the memory Issues and PRs related to the memory management or memory footprint. label Dec 6, 2016
@erossignon
Copy link
Author

it looks like the issue is coming from should-format when constructing assert messages of very large objects ( and ultimately calling Array.prototype.join ). I still don't understand why the same code is working well on nodejs 6.9.1 and crashing on newer version. I'll keep investigating.

@abenhamdine
Copy link

I still don't understand why the same code is working well on nodejs 6.9.1 and crashing on newer version.

Same here.
Since we went back on 6.9.1, we haven't runned any more in trouble. I'll try to investigate further.

@abenhamdine
Copy link

abenhamdine commented Dec 7, 2016

Ok, I found the culprit, it was the child.send function.
We used to send large messages between processes, and it looks like node 7 create perhaps more overhead on ipc communication.
Anyway, it was not relevant to send such messages, we fixed our code.
I will let you know if we still encounter the issue.

@bnoordhuis
Copy link
Member

Thanks for the update, @abenhamdine. I'll close out the issue; can reopen if necessary.

@erossignon
Copy link
Author

erossignon commented Dec 8, 2016

Ben, I think @abenhamdine issue was different but produced the same effect.
For the record, here is how fix the issue on my side.
The "should" package produces rich object output when an assert is raised.
In my case a error occurred in a unit test in a line looking like

var obj = getsomeobject();
should(obj).not.eql(null);

In my case, the object owns a back pointer to its parent object, which exposes thousand of complex objects.
When should raises the assert it tries to dump the whole object including the parent and the other sibling objects causing a large string to be constructed with Array.prototype.join.
The string contains more than 10 millions little fragments and causes the memory exhaustion.

I have fixed the issue using the following:

  • replace should(obj).not.eql(null); with should.exist(obj)
  • make the back pointer not enumerable using Object.defineProperty(this, "_parent", {configurable: true,value: parent, hidden:true,enumerable: false});

The problem existed in my original code and has been highlighted by the new behavior in nodeJS 7.x.
Ben, do you have any idea why the memory behavior has changed between 6.9 and 7.0?

@bnoordhuis
Copy link
Member

There's probably no single change that is responsible. V8 is working towards closer ES6 and ES7 conformance, the garbage collector got an overhaul, and so on.

@kazzkiq
Copy link

kazzkiq commented Mar 6, 2017

Also got the same problem working with big objects and JSON parsing in Node v7.7.1.

The stacktrace can be seen here:

Terminal stacktrace (click to open)
<--- Last few GCs --->

[21159:0x2343660]      991 ms: Mark-sweep 10.9 (524.0) -> 10.8 (532.5) MB, 12.1 / 0.0 ms  allocation failure GC in old space requested
[21159:0x2343660]     1004 ms: Mark-sweep 10.8 (783.0) -> 9.5 (768.0) MB, 12.4 / 0.0 ms  last resort 
[21159:0x2343660]     1017 ms: Mark-sweep 9.5 (768.0) -> 9.2 (766.0) MB, 13.4 / 0.0 ms  last resort 


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x1baf3cba66a1 <JS Object>
    1: slowToString(aka slowToString) [buffer.js:468] [pc=0x3055518b71b5](this=0x1e99c8182311 <undefined>,buf=0xa181f60b241 <an Uint8Array with map 0x2b3af6dac6d9>,encoding=0x1baf3cbaf2b9 <String[4]: utf8>,start=0,end=262668066)
    2: toString [buffer.js:~496] [pc=0x3055518d0716](this=0xa181f60b241 <an Uint8Array with map 0x2b3af6dac6d9>,encoding=0x1baf3cbaf2b9 <String[4]: utf8>,start=0x1e99c8...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [node]
 2: 0x12b78dc [node]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
 5: v8::internal::Factory::NewRawOneByteString(int, v8::internal::PretenureFlag) [node]
 6: v8::internal::Factory::NewStringFromOneByte(v8::internal::Vector<unsigned char const>, v8::internal::PretenureFlag) [node]
 7: v8::internal::Factory::NewStringFromUtf8(v8::internal::Vector<char const>, v8::internal::PretenureFlag) [node]
 8: v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::String::NewStringType, int) [node]
 9: node::StringBytes::Encode(v8::Isolate*, char const*, unsigned long, node::encoding) [node]
10: void node::Buffer::StringSlice<(node::encoding)1>(v8::FunctionCallbackInfo<v8::Value> const&) [node]
11: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [node]
12: 0xb46eac [node]
13: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node]
14: 0x3055515843a7
Aborted (core dumped)

@gomesNazareth
Copy link

I used --max_old_space_size and I again got the memory error. After doing some online research i realized it not underscore but dash like --max-old-space-size

@bnoordhuis
Copy link
Member

@gomesNazareth As mentioned in the other issue, dashes and underscores both work.

@buzzy3
Copy link

buzzy3 commented May 23, 2017

same here on debian jessy latest.

@ede0m
Copy link

ede0m commented Jul 27, 2017

Getting the same issue when running with v6.11.0. However, v7.5.0 has worked for me. I am required to use LTS version though :(

@cvbuelow
Copy link

using --max-old-space-size=16000 on node v6.11.0 fixed the issue for me

@nwaughachukwuma
Copy link

nwaughachukwuma commented Jan 5, 2018

Hey guys, I have read through this but don't get how to use this: --max-old-space-size=16000 Am I to insert that somewhere or run it on the command line? And how? Thanks.

@nwaughachukwuma
Copy link

@erossignon is there a way to use --max_old_space_size with npm run unit: cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run? I have been trying almost all day

@mmarchini
Copy link
Contributor

mmarchini commented Jan 5, 2018

@nwaughachukwuma you'll probably get better help by opening an issue on https://github.com/nodejs/help. Remember to follow the issue template there :)

@pete85
Copy link

pete85 commented Apr 4, 2018

Since @angular/cli@1.0.0-beta.28 they've made the AOT compilation the default for production builds. Running "ng build –prod –aot=false" helped me with this issue.

@bicibg
Copy link

bicibg commented May 17, 2018

how many of the people with this issue are using firebase? I found out in my case issue was with the firebase. as soon as I removed it, my project was built in no time

@asumaran
Copy link

asumaran commented Jun 8, 2018

I'm getting the same error with node v8.11.1 on my webpack app. It always crashes right after saving a file.

<--- Last few GCs --->

[8820:0x102801e00]  8839814 ms: Mark-sweep 1381.1 (1437.0) -> 1380.7 (1438.5) MB, 158.0 / 0.0 ms  allocation failure GC in old space requested
[8820:0x102801e00]  8840024 ms: Mark-sweep 1380.7 (1438.5) -> 1380.7 (1402.0) MB, 209.4 / 0.0 ms  last resort GC in old space requested
[8820:0x102801e00]  8840163 ms: Mark-sweep 1380.7 (1402.0) -> 1380.7 (1402.0) MB, 139.1 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x50494ba57c1 <JSObject>
    1: DoJoin(aka DoJoin) [native array.js:~94] [pc=0xbf86fe4fde2](this=0x5043e5822d1 <undefined>,o=0x50459937db1 <JSArray[31848]>,p=31848,D=0x5043e582371 <true>,z=0x5043e582431 <String[0]: >,y=0x5043e5823e1 <false>)
    2: Join(aka Join) [native array.js:~119] [pc=0xbf86fed4dde](this=0x5043e5822d1 <undefined>,o=0x50459937db1 <JSArray[31848]>,p=31848,z=0x5043e582431 <String[0]: >,y=0x5043e5823e1 ...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/usr/local/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
 4: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
 5: v8::internal::Runtime_StringBuilderConcat(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
 6: 0xbf86f1042fd
 7: 0xbf86fe4fde2
 8: 0xbf86fed4dde
 9: 0xbf86ff5c87b
10: 0xbf86f27a434
11: 0xbf86f1bd196
12: 0xbf86f1bd196
13: 0xbf86f1bd196

@mikerockett
Copy link

This is persisting for me as well on all my webpack projects (no matter the size). I often find that over time, SASS builds (via hot-reload) take longer and longer, and then it eventually crashes.

node -v && npm -v
v8.11.2
5.6.0

@bnoordhuis
Copy link
Member

Last two commenters: you should open an issue with webpack.

@rotaercz
Copy link

rotaercz commented Jul 23, 2018

node -v
v8.11.2

I'm also getting the same error:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - Javascript heap out of memory
1: node_module_register
2: v8::internal::FatalProcessOutOfMemory
3: v8::internal::FatalProcessOutOfMemory
4: v8::internal::Factory::NewRawTwoByteString
5: v8::internal::AsmJsScanner::IsNumberStart
6: 0000028B313843C1

@Deepanshutanejaco
Copy link

Deepanshutanejaco commented Aug 7, 2018

Facing the issue while generating build using webpack version = 2.7.0 ,node version = 10.6.0, yarn version = 1.7.0
<--- Last few GCs --->

[9124:0x2d55770] 3375368 ms: Mark-sweep 1369.3 (1450.8) -> 1369.3 (1450.8) MB, 1188.1 / 0.0 ms allocation failure GC in old space requested
[9124:0x2d55770] 3376296 ms: Mark-sweep 1369.3 (1450.8) -> 1369.3 (1442.8) MB, 926.9 / 0.0 ms last resort GC in old space requested
[9124:0x2d55770] 3377252 ms: Mark-sweep 1369.3 (1442.8) -> 1369.3 (1442.8) MB, 955.9 / 0.0 ms last resort GC in old space requested

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x2f7374225879
1: visit [0x3496c21822d1 :~7251] [pc=0x16d93426e27](this=0x3ad5cf969c51 ,node=0x2a681c3636a1 <AST_SymbolRef map = 0x3be4fc2569a1>,descend=0x1965f717dc21 <JSFunction noop (sfi = 0x1a57cc27c1d1)>)
2: _walk [0x3496c21822d1 :~479] [pc=0x16d9343bc97](this=0x2a681c3636a1 <AST_SymbolRef map = 0x3be4fc2569a1>,visitor=0x3ad5cf969c51 <TreeWalk...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [node]
2: 0x8c21ec [node]
3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
5: v8::internal::Factory::NewFixedArray(int, v8::internal::PretenureFlag) [node]
6: v8::internal::HashTable<v8::internal::SeededNumberDictionary, v8::internal::SeededNumberDictionaryShape>::NewInternal(v8::internal::Isolate*, int, v8::internal::PretenureFlag) [node]
7: v8::internal::HashTable<v8::internal::SeededNumberDictionary, v8::internal::SeededNumberDictionaryShape>::New(v8::internal::Isolate*, int, v8::internal::PretenureFlag, v8::internal::MinimumCapacity) [node]
8: v8::internal::HashTable<v8::internal::SeededNumberDictionary, v8::internal::SeededNumberDictionaryShape>::EnsureCapacity(v8::internal::Handlev8::internal::SeededNumberDictionary, int, v8::internal::PretenureFlag) [node]
9: v8::internal::Dictionary<v8::internal::SeededNumberDictionary, v8::internal::SeededNumberDictionaryShape>::Add(v8::internal::Handlev8::internal::SeededNumberDictionary, unsigned int, v8::internal::Handlev8::internal::Object, v8::internal::PropertyDetails, int*) [node]
10: 0xd47956 [node]
11: v8::internal::JSObject::AddDataElement(v8::internal::Handlev8::internal::JSObject, unsigned int, v8::internal::Handlev8::internal::Object, v8::internal::PropertyAttributes, v8::internal::Object::ShouldThrow) [node]
12: v8::internal::Object::AddDataProperty(v8::internal::LookupIterator*, v8::internal::Handlev8::internal::Object, v8::internal::PropertyAttributes, v8::internal::Object::ShouldThrow, v8::internal::Object::StoreFromKeyed) [node]
13: v8::internal::Object::SetProperty(v8::internal::LookupIterator*, v8::internal::Handlev8::internal::Object, v8::internal::LanguageMode, v8::internal::Object::StoreFromKeyed) [node]
14: v8::internal::Runtime_SetProperty(int, v8::internal::Object**, v8::internal::Isolate*) [node]
15: 0x16d924842fd

@gireeshpunathil
Copy link
Member

1369.3 (1450.8) -> 1369.3 (1450.8) would mean the heap is exhausted.

You could either increase it with --max_old_space_size at the node command line section or apply it to webpack if that module exposes option to receive node command line.

@Deepanshutanejaco
Copy link

Deepanshutanejaco commented Aug 7, 2018

using the command to build the app is

"build": "cross-env NODE_ENV=production webpack NODE_OPTIONS=-max_old_space_size=12000 --watch --progress --config internals/webpack/webpack.prod.babel.js --color -p --progress",

still getting the issue.

@jonmillar
Copy link

"build": "cross-env NODE_ENV=production webpack NODE_OPTIONS=--max_old_space_size=12000 --watch --progress --config internals/webpack/webpack.prod.babel.js --color -p --progress",

FTFY

@mikerockett
Copy link

I've noticed recently that this issue isn't persisting anymore... Interestingly, it’s been quite fine even since before I recently upgraded node/npm.

@tetreault
Copy link

I have this issue in node 10.4.0, working in react native and Viro Media AR library. I'm only loading 1 3d model and its textures, both of which are very reasonable in size.

Stack trace:

Loading dependency graph, done.
 BUNDLE  [ios, dev] ./index.js ▓▓▓▓▓░░░░░░░░░░░ 33.7% (194/334)
<--- Last few GCs --->

[59297:0x103000600]  4750606 ms: Mark-sweep 909.6 (997.2) -> 909.6 (962.7) MB, 87.7 / 0.0 ms  (average mu = 0.998, current mu = 0.000) last resort GC in old space requested
[59297:0x103000600]  4750680 ms: Mark-sweep 909.6 (962.7) -> 909.6 (961.7) MB, 73.9 / 0.0 ms  (average mu = 0.996, current mu = 0.000) last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x226d57a841bd]
Security context: 0x2f3fa351e589 <JSObject>
    1: _send [0x2f3f6d20cb79] [internal/child_process.js:715] [bytecode=0x2f3fb099b7a1 offset=606](this=0x2f3f35626259 <ChildProcess map = 0x2f3fd5608299>,message=0x2f3fe40d4039 <JSArray[4]>,handle=0x2f3fa08822e1 <undefined>,options=0x2f3fcff48da9 <Object map = 0x2f3fd5608871>,callback=0x2f3fa08822e1 <undefined>)
    2: send [0x2f3f6d20dcf1] [internal/child_...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/Users/stephentetreault/.nvm/versions/node/v10.4.0/bin/node]
 2: node::OnFatalError(char const*, char const*) [/Users/stephentetreault/.nvm/versions/node/v10.4.0/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/stephentetreault/.nvm/versions/node/v10.4.0/bin/node]
 4: v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/stephentetreault/.nvm/versions/node/v10.4.0/bin/node]
 5: v8::internal::Heap::AllocateRawWithRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/Users/stephentetreault/.nvm/versions/node/v10.4.0/bin/node]
 6: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/Users/stephentetreault/.nvm/versions/node/v10.4.0/bin/node]
 7: v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [/Users/stephentetreault/.nvm/versions/node/v10.4.0/bin/node]
 8: v8::String::Utf8Length() const [/Users/stephentetreault/.nvm/versions/node/v10.4.0/bin/node]
 9: node::StringBytes::Size(v8::Isolate*, v8::Local<v8::Value>, node::encoding) [/Users/stephentetreault/.nvm/versions/node/v10.4.0/bin/node]
10: int node::StreamBase::WriteString<(node::encoding)1>(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/stephentetreault/.nvm/versions/node/v10.4.0/bin/node]
11: void node::StreamBase::JSMethod<node::LibuvStreamWrap, &(int node::StreamBase::WriteString<(node::encoding)1>(v8::FunctionCallbackInfo<v8::Value> const&))>(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/stephentetreault/.nvm/versions/node/v10.4.0/bin/node]
12: v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) [/Users/stephentetreault/.nvm/versions/node/v10.4.0/bin/node]
13: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/Users/stephentetreault/.nvm/versions/node/v10.4.0/bin/node]
14: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/Users/stephentetreault/.nvm/versions/node/v10.4.0/bin/node]
15: 0x226d57a841bd
16: 0x226d57a93429
17: 0x226d57a93429
18: 0x226d57a8c223
/Users/stephentetreault/git/tetreault/react-native-arkit-demo/Viro3dModelDemo/node_modules/react-native/scripts/packager.sh: line 11: 59297 Abort trap: 6           node "./local-cli/cli.js" start "$@"
Process terminated. Press <enter> to close the window

@arunasank
Copy link

Seeing this issue on node v10.13.0:

<--- Last few GCs --->

[1161:0x3b5fa30]    73225 ms: Mark-sweep 965.6 (1263.6) -> 965.6 (1224.1) MB, 705.1 / 0.0 ms  (average mu = 0.587, current mu = 0.000) last resort GC in old space requested
[1161:0x3b5fa30]    73867 ms: Mark-sweep 965.6 (1224.1) -> 965.6 (1215.6) MB, 642.4 / 0.0 ms  (average mu = 0.412, current mu = 0.000) last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x20058a7dbe1d]
Security context: 0x23007d91e6e1 <JSObject>
    1: _send [0x346e48b3e8f9] [internal/child_process.js:716] [bytecode=0x16276671751 offset=607](this=0x07e807383c41 <process map = 0x91e7b48da1>,message=0x311a038d28b9 <Object map = 0x19b83d8ed919>,handle=0x39422da022b1 <null>,options=0x311a038d2951 <Object map = 0x19b83d8ed971>,callback=0x12a49e3b60e1 <JSFunction (sfi = 0x182bc32657a1)>)
    2: send [0x34...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: 0x8daaa0 node::Abort() [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
 2: 0x8daaec  [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
 3: 0xad73ce v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
 4: 0xad7604 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
 5: 0xec4c32  [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
 6: 0xed444f v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
 7: 0xea3ffb v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
 8: 0xfed8b3 v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
 9: 0xad49f4 v8::internal::String::Flatten(v8::internal::Handle<v8::internal::String>, v8::internal::PretenureFlag) [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
10: 0xae27a0 v8::String::Utf8Length() const [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
11: 0x99dfa1 node::StringBytes::Size(v8::Isolate*, v8::Local<v8::Value>, node::encoding) [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
12: 0x9a6d12 int node::StreamBase::WriteString<(node::encoding)1>(v8::FunctionCallbackInfo<v8::Value> const&) [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
13: 0x9ae651 void node::StreamBase::JSMethod<node::LibuvStreamWrap, &(int node::StreamBase::WriteString<(node::encoding)1>(v8::FunctionCallbackInfo<v8::Value> const&))>(v8::FunctionCallbackInfo<v8::Value> const&) [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
14: 0xb5faef  [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
15: 0xb60659 v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [/home/ec2-user/.nvm/versions/node/v10.13.0/bin/node]
16: 0x20058a7dbe1d

@tetreault
Copy link

following up on my post in this thread -- was a stupid mistake. I was building an AR app with Viro in React Native. One of my 3d asset texture files was 60mb+ which was the cause.

@rkumar1904
Copy link

I have tried 👍 the below code and its working fine✌.

  • open terminal from project root dir
  • execute the cmd to set new size.
    set NODE_OPTIONS=--max_old_space_size=8172

@w5688414
Copy link

w5688414 commented Jul 6, 2019

node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod

@zhuguocheng29
Copy link

I have the same problem in

node v8.14.1

I set --max_old_space_size=4096, however it still shows OOM.

<--- Last few GCs --->
04:54:13 08-01 30 PE10 D: TC-2071:  null
04:54:13 08-01 30 PE10 D: TC-2071:    [19:0x3ca2e20] 26371665 ms: Mark-sweep 3561.1 (4331.9) -> 3561.0 (4331.9) MB, 1213.2 / 0.0 ms  allocation failure GC in old space requested
04:54:13 08-01 30 PE10 D: TC-2071:    [19:0x3ca2e20] 26373076 ms: Mark-sweep 3561.0 (4331.9) -> 3560.9 (4294.4) MB, 1410.7 / 0.0 ms  last resort GC in old space requested
04:54:13 08-01 30 PE10 D: TC-2071:    [19:0x3ca2e20] 26374405 ms: Mark-sweep 3560.9 (4294.4) -> 3560.9 (4288.9) MB, 1329.1 / 0.0 ms  last resort GC in old space requested
04:54:13 08-01 30 PE10 D: TC-2071:  null
04:54:13 08-01 30 PE10 D: TC-2071:    <--- JS stacktrace --->
04:54:13 08-01 30 PE10 D: TC-2071:  null
04:54:13 08-01 30 PE10 D: TC-2071:    ==== JS stack trace =========================================
04:54:13 08-01 30 PE10 D: TC-2071:  null
04:54:13 08-01 30 PE10 D: TC-2071:    Security context: 0x3bcf0dd25879 <JSObject>
04:54:13 08-01 30 PE10 D: TC-2071:    1: set(this=0x18dbb0b8e921 <Map map = 0x3dd7fe3848d9>,603942,0x26562b940619 <Object map = 0x2e063b9ad701>)
04:54:13 08-01 30 PE10 D: TC-2071:    2: emitInitNative(aka emitInitNative) [internal/async_hooks.js:~128] [pc=0x3596f7d4cf05](this=0x27634cb022d1 <undefined>,asyncId=603942,type=0x1f93b16b0cf1 <String[9]: Immediate>,triggerAsyncId=603941,resource=0x26562b93ff51 <Immediate map = 0x35dc8667ef89>)
04:54:13 08-01 30 PE10 D: TC-2071:    3: next(aka next) [/...
04:54:13 08-01 30 PE10 D: TC-2071:  null
04:54:13 08-01 30 PE10 D: TC-2071:    FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
04:54:13 08-01 30 PE10 D: TC-2071:    1: node::Abort() [node]
04:54:13 08-01 30 PE10 D: TC-2071:    2: 0x8c21ec [node]
04:54:13 08-01 30 PE10 D: TC-2071:    3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
04:54:13 08-01 30 PE10 D: TC-2071:    4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
04:54:13 08-01 30 PE10 D: TC-2071:    5: v8::internal::Factory::NewFixedArray(int, v8::internal::PretenureFlag) [node]
04:54:13 08-01 30 PE10 D: TC-2071:    6: v8::internal::OrderedHashTable<v8::internal::OrderedHashMap, 2>::Allocate(v8::internal::Isolate*, int, v8::internal::PretenureFlag) [node]
04:54:13 08-01 30 PE10 D: TC-2071:    7: v8::internal::OrderedHashTable<v8::internal::OrderedHashMap, 2>::Rehash(v8::internal::Handle<v8::internal::OrderedHashMap>, int) [node]
04:54:13 08-01 30 PE10 D: TC-2071:    8: v8::internal::OrderedHashTable<v8::internal::OrderedHashMap, 2>::EnsureGrowable(v8::internal::Handle<v8::internal::OrderedHashMap>) [node]
04:54:13 08-01 30 PE10 D: TC-2071:    9: v8::internal::Runtime_MapGrow(int, v8::internal::Object**, v8::internal::Isolate*) [node]
04:54:13 08-01 30 PE10 D: TC-2071:    10: 0x3596f7c042fd
04:54:13 08-01 30 PE10 D: TC-2071:    mocha exit with code 134

@amark
Copy link

amark commented Sep 19, 2019

@bnoordhuis where can I find documentation on how to read the stack trace?

It isn't NodeJS's fault that memory is running out.

Tho it is hard for JS developers like me to use the V8 trace to find where in their code the string concat (or other) happened.

Do you have any tech talks, blogs, or docs that would help devs like me correctly read the trace?

@Adel-Magebinary
Copy link

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [node]
2: 0x8cd49c [node]
3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
5: v8::internal::Factory::NewCode(v8::internal::CodeDesc const&, unsigned int, v8::internal::Handlev8::internal::Object, bool, int) [node]
6: v8::internal::RegExpMacroAssemblerX64::GetCode(v8::internal::Handlev8::internal::String) [node]
7: v8::internal::RegExpCompiler::Assemble(v8::internal::RegExpMacroAssembler*, v8::internal::RegExpNode*, int, v8::internal::Handlev8::internal::String) [node]
8: v8::internal::RegExpEngine::Compile(v8::internal::Isolate*, v8::internal::Zone*, v8::internal::RegExpCompileData*, v8::base::Flags<v8::internal::JSRegExp::Flag, int>, v8::internal::Handlev8::internal::String, v8::internal::Handlev8::internal::String, bool) [node]
9: v8::internal::RegExpImpl::CompileIrregexp(v8::internal::Handlev8::internal::JSRegExp, v8::internal::Handlev8::internal::String, bool) [node]
10: v8::internal::RegExpImpl::IrregexpPrepare(v8::internal::Handlev8::internal::JSRegExp, v8::internal::Handlev8::internal::String) [node]
11: v8::internal::RegExpImpl::IrregexpExec(v8::internal::Handlev8::internal::JSRegExp, v8::internal::Handlev8::internal::String, int, v8::internal::Handlev8::internal::RegExpMatchInfo) [node]
12: v8::internal::RegExpImpl::Exec(v8::internal::Handlev8::internal::JSRegExp, v8::internal::Handlev8::internal::String, int, v8::internal::Handlev8::internal::RegExpMatchInfo) [node]
13: v8::internal::Runtime_RegExpExec(int, v8::internal::Object**, v8::internal::Isolate*) [node]
14: 0x160dc7f842fd

@ggcaponetto
Copy link

update to node v13.8.0 solved the issue for me

@alePanta
Copy link

update to node v13.8.0 solved the issue for me

Node v12.16.1 works for me

@orcunozbay1
Copy link

node command always entering to command line

@samourai
Copy link

This issue occur often when you update your node version, juste check your package.json and package-lock.json if there's {engine: node: 'xxxxx version', npm: 'xxx version'}. in this cae you should use the same version in your package.

@abdulmajidkazi
Copy link

it looks like the issue is coming from should-format when constructing assert messages of very large objects ( and ultimately calling Array.prototype.join ). I still don't understand why the same code is working well on nodejs 6.9.1 and crashing on newer version. I'll keep investigating.

Hi,
How did you trace the error back to your source code lines causing the leak?
I am getting exactly the same error with angular 7.2 and increasing the memory did not help. Any pointers?

@arunmeanssun
Copy link

Hi everyone,

I had this memory heap issue when I had node version 14.17.0 installed in my laptop. I downgraded it to version 14.15.4. the issue got solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
memory Issues and PRs related to the memory management or memory footprint.
Projects
None yet
Development

No branches or pull requests