Node: Allocation failed - process out of memory

Created on 13 May 2017  路  18Comments  路  Source: nodejs/node

Not sure what caused the problem but node crashed with:

<--- Last few GCs --->

[20015:0x3447a40]  4599326 ms: Scavenge 1315.8 (1426.2) -> 1314.9 (1426.2) MB, 2.3 / 0.0 ms  (+ 2.7 ms in 1929 steps since last GC) allocation failure
[20015:0x3447a40]  4599335 ms: Scavenge 1315.9 (1426.2) -> 1315.0 (1426.2) MB, 2.2 / 0.0 ms  (+ 2.7 ms in 1945 steps since last GC) allocation failure
[20015:0x3447a40]  4599343 ms: Scavenge 1316.0 (1426.2) -> 1315.1 (1426.2) MB, 2.1 / 0.0 ms  (+ 2.5 ms in 1960 steps since last GC) allocation failure


<--- JS stacktrace --->
Cannot get stack trace in GC.
FATAL ERROR: Scavenger: promoting marked
 Allocation failed - process out of memory
 1: node::Abort() [ember]
 2: 0x126389c [ember]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [ember]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [ember]
 5: 0xa65f9b [ember]
 6: void v8::internal::ScavengingVisitor<(v8::internal::MarksHandling)0, (v8::internal::PromotionMode)0, (v8::internal::LoggingAndProfiling)1>::EvacuateObject<(v8::internal::ScavengingVisitor<(v8::internal::MarksHandling)0, (v8::internal::PromotionMode)0, (v8::internal::LoggingAndProfiling)1>::ObjectContents)1, (v8::internal::AllocationAlignment)0>(v8::internal::Map*, v8::internal::HeapObject**, v8::internal::HeapObject*, int) [ember]
 7: v8::internal::Scavenger::CheckAndScavengeObject(v8::internal::Heap*, unsigned char*) [ember]
 8: v8::internal::Heap::Scavenge() [ember]
 9: v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [ember]
10: v8::internal::Heap::CollectGarbage(v8::internal::GarbageCollector, char const*, char const*, v8::GCCallbackFlags) [ember]
11: v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [ember]
12: v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [ember]
13: 0x29ece76063a7
Aborted (core dumped)



npm ERR! Linux 4.10.0-20-generic
npm ERR! argv "/home/chrmod/.nvm/versions/node/v7.4.0/bin/node" "/home/chrmod/.nvm/versions/node/v7.4.0/bin/npm" "start"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `ember server -p 3000` 
npm ERR! Exit status 134                                            
npm ERR!   
question

Most helpful comment

@ganpatipaswan how angular-cli fixing it?

All 18 comments

General help questions should be posted on the nodejs/help issue tracker instead.

@chrmod By default, Node.js sets memory limit near 1.5 GB. Try to increase it by this key (this example sets 2 GB):

node --max_old_space_size=2048 test.js

Also, if you get this error trying to search with npm, you need to update npm, see https://github.com/npm/npm/blob/latest/CHANGELOG.md#v420-2017-01-26

Looks like this is caused by running ember server -p 3000, and the server run out of memory. One possible reason is that there could be a memory leak in that server. You can probably try to file an issue to https://github.com/ember-cli/ember-cli/issues

This issue has been inactive for sufficiently long that it seems like perhaps it should be closed. Feel free to re-open (or leave a comment requesting that it be re-opened) if you disagree. I'm just tidying up and not acting on a super-strong opinion or anything like that.

@chrmod
How did you resolve this?
I'm having this issue as well.

@janwerkhoven I did not. It appeared to be some sort of memory leak (maybe related to suspending the system), which never hit me again. But if you're getting this please consider allowing node to get more memory https://github.com/nodejs/node/issues/13018#issuecomment-301270172

I've upgrade Node to v8.9.3 LTS and that resolved this issue for me 馃憤

I am facing this issue on linux server
my node is v8.9.3 LTS
and below is my Linux configuration

description: System Memory physical id: 1000 size: 1GiB capacity: 1GiB

Could it be because of my RAM limitation?

solution-
rm -rf node_modules
npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest
npm install

@ganpatipaswan how angular-cli fixing it?

Had this issue and resolves it by adding swap memory to the server (turns out there wasn't any allocated. You can check this using free -h on Ubuntu).

A little more explanation here off the SO post that led me to the answer: https://stackoverflow.com/questions/26193654/node-js-catch-enomem-error-thrown-after-spawn

and a guide to setting it up here:
https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-18-04

Hope this helps anyone coming back to this!

FOR THE FUTURE:

I've solved this following this configurations about swap mem on my VPS:
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

Basically, consist in create a swap memory space and set up some params to improve it.

You ran out of memory on your machine. I had this same issue and solved it this way:

  1. I checked all the process that were running by using top command on linux
  2. Killed process that I wasn't running and were taking a lot of memory for me it was chrome by using pkill chrome
  3. Ran my node process once again and everything went well.

Hope it helps

Yes, as others have pointed, probably your server is out of memory. Try to stop (temporaly) the heavy processes and then build again; or add some swap memory.

I added swap memory, but how to run node build with swap memory ? i created node build using pkg npm module.

Crazy as it may sound, what i did was delete the project, clone it again, ran npm install then yarn run build.

Am suspecting just deleting the node_modules rm -rf node_modules could do the job.

Solution inspired by @grantgasp 's answer

solution-
rm -rf node_modules
...
npm install

FOR THE FUTURE:

I've solved this following this configurations about swap mem on my VPS:
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

Basically, consist in create a swap memory space and set up some params to improve it.

I had the same problem and it did not explain to me why when I executed npm build once it was successful and others not, the error appeared. Thanks to the answer above I found the reason.

I checked it because I did a "htop" to see the resources of the machine (in my Digital Ocean of 1G RAM). The execution build process was using 1GB of RAM. The solution was to create 4GB of the disk and assign it as a swap. After that everyone runs build they run successfully.

Tutorial for Ubuntu 18.04: https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-18-04
Tutorial in Spanish: https://www.wdiaz.org/me-quede-sin-memoria-ram-digital-ocean/

Just get to the next part to make it work:
Add the swap file information to the end of your /etc/fstab file by typing:
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

PD: Just get to the next part to make it work:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

akdor1154 picture akdor1154  路  3Comments

danialkhansari picture danialkhansari  路  3Comments

stevenvachon picture stevenvachon  路  3Comments

willnwhite picture willnwhite  路  3Comments

Icemic picture Icemic  路  3Comments