Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory in angular

I'm using Angular 7.2. When I enter ng serve, I'm facing the following issue:

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

What does that mean? How do I fix that?

The full error message is:

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x8f9d10 node::Abort() [ng serve --aot --proxy-config proxy.conf.json --host 0.0.0.0 --disable-host-check --live-reload --progress]
2: 0x8f9d5c  [ng serve --aot --proxy-config proxy.conf.json --host 0.0.0.0 --disable-host-check --live-reload --progress]
3: 0xaffd0e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [ng serve --aot --proxy-config proxy.conf.json --host 0.0.0.0 --disable-host-check --live-reload --progress]
4: 0xafff44 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [ng serve --aot --proxy-config proxy.conf.json --host 0.0.0.0 --disable-host-check --live-reload --progress]
5: 0xef4152  [ng serve --aot --proxy-config proxy.conf.json --host 0.0.0.0 --disable-host-check --live-reload --progress]
6: 0xef4258 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [ng serve --aot --proxy-config proxy.conf.json --host 0.0.0.0 --disable-host-check --live-reload --progress]
7: 0xf00332 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [ng serve --aot --proxy-config proxy.conf.json --host 0.0.0.0 --disable-host-check --live-reload --progress]
8: 0xf00c64 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [ng serve --aot --proxy-config proxy.conf.json --host 0.0.0.0 --disable-host-check --live-reload --progress]
9: 0xf038d1 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [ng serve --aot --proxy-config proxy.conf.json --host 0.0.0.0 --disable-host-check --live-reload --progress]
10: 0xeccd54 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [ng serve --aot --proxy-config proxy.conf.json --host 0.0.0.0 --disable-host-check --live-reload --progress]
11: 0x116cede v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [ng serve --aot --proxy-config proxy.conf.json --host 0.0.0.0 --disable-host-check --live-reload --progress]
12: 0x19f62a4dbe1d
Aborted (core dumped) 
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! [email protected] start: `ng serve --aot --proxy-config proxy.conf.json --host 0.0.0.0 --disable-host-check --live-reload --progress `
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-01-29T07_09_21_844Z-debug.log
like image 315
Rahul Avatar asked Jan 29 '20 11:01

Rahul


2 Answers

Issue: While building(compiling), memory exceeds allocated memory for compilation.

Fix: Increase allocation memory. 8192 is the size used in the below script. You can vary this according to your need.

Try to run commands like this:

Serving:

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

Building:

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

Custom script:

Your script command(as mentioned in comment):

ng serve --aot --proxy-config proxy.conf.json --host 0.0.0.0 --disable-host-check --live-reload --progress

Modify to:

node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng serve --aot --proxy-config proxy.conf.json --host 0.0.0.0 --disable-host-check --live-reload --progress
like image 63
Jins Thomas Shaji Avatar answered Oct 01 '22 22:10

Jins Thomas Shaji


try running the build with this

node --max_old_space_size=8048 ./node_modules/@angular/cli/bin/ng serve

or other way is to add this to the package.json

"build-serve": "node --max_old_space_size=8048 ./node_modules/@angular/cli/bin/ng serve"

where 8048 is the max heap size.

like image 22
Vaibhav Kumar Goyal Avatar answered Oct 01 '22 20:10

Vaibhav Kumar Goyal