最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

node.js - FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory error - Stack Overflow

programmeradmin3浏览0评论

Im getting this error when i run ng build --prod

92% chunk asset optimization <--- Last few GCs --->

[4136:0155D210] 443646 ms: Mark-sweep 703.5 (770.3) -> 703.6 (759.8) MB, 2162.2 / 0.0 ms (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 2163 ms) last resort GC in old space requested [4136:0155D210] 445794 ms: Mark-sweep 703.6 (759.8) -> 703.5 (759.8) MB, 2147.8 / 0.0 ms last resort GC in old space requested

<--- JS stacktrace --->

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

Security context: 0369632D 1: create(this=036856A9 ) 2: _walk [034841A1 :~764] [pc=1CCAED1F](this=3A11A619 ,visitor=3BCEFD7D ) 3: /* anonymous */ [034841A1 :~969] [pc=1D3728E3](this=3A11BCBD ) 4: _walk [034841A1 :~968] [pc=1CCC1F3B](this=3A11BCBD

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 1: node_module_register 2: v8::internal::Factory::NewStruct 3: v8::internal::Factory::NewPrototypeInfo

I tried everything. I reduced the usage of variables and checked for memory leaks and made very less callbacks in the ts file.

Im unable to figure out how to do it. I tried increasing the node memory by using 'npm i increase-memory-limit' and increased the limit to 2GB.

Im using angular 4. Node version is 8.9.4

Im getting this error when i run ng build --prod

92% chunk asset optimization <--- Last few GCs --->

[4136:0155D210] 443646 ms: Mark-sweep 703.5 (770.3) -> 703.6 (759.8) MB, 2162.2 / 0.0 ms (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 2163 ms) last resort GC in old space requested [4136:0155D210] 445794 ms: Mark-sweep 703.6 (759.8) -> 703.5 (759.8) MB, 2147.8 / 0.0 ms last resort GC in old space requested

<--- JS stacktrace --->

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

Security context: 0369632D 1: create(this=036856A9 ) 2: _walk [034841A1 :~764] [pc=1CCAED1F](this=3A11A619 ,visitor=3BCEFD7D ) 3: /* anonymous */ [034841A1 :~969] [pc=1D3728E3](this=3A11BCBD ) 4: _walk [034841A1 :~968] [pc=1CCC1F3B](this=3A11BCBD

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 1: node_module_register 2: v8::internal::Factory::NewStruct 3: v8::internal::Factory::NewPrototypeInfo

I tried everything. I reduced the usage of variables and checked for memory leaks and made very less callbacks in the ts file.

Im unable to figure out how to do it. I tried increasing the node memory by using 'npm i increase-memory-limit' and increased the limit to 2GB.

Im using angular 4. Node version is 8.9.4

Share Improve this question edited Nov 28, 2018 at 10:53 Ben Taliadoros 9,41118 gold badges66 silver badges105 bronze badges asked May 31, 2018 at 9:30 user9065878user9065878 1
  • check this answer: stackoverflow./questions/38558989/node-js-heap-out-of-memory/… – sidverma Commented Apr 2, 2021 at 6:44
Add a ment  | 

4 Answers 4

Reset to default 8

Try navigate to yourproject/node_modules and run following mand:

node --max_old_space_size=5048 "%~dp0\..\@angular\cli\bin\ng" build --aot --prod

And if you want to make your life easier you can insert this in your package.json file:

"scripts": {
   "build-prod": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --prod"
}

Then all you have to do now is running npm run build-prod.

You might want to look at how increase-memory-limit increases the heap size under the hood.

The usual way is as follows:

node --max-old-space-size=8192 server.js  

If it is somehow modifying the ng build mand you may want to try increasing the limit more.

I am getting this error while running

npm test run

For temporary, we can increase limit of --max_old_space_size

path: node_modules/@yarnpkg/index.js

then search for --max_old_space_size and then increase limit but it will be a temporary solution.

try this as it seems like permanent solution-- https://stackoverflow./a/57782016/1948482

I had the same problem once building a JS application and it turns out there's a limit of the memory a node module can consume.

simply using this npm package has solved it for me : https://www.npmjs./package/increase-memory-limit

发布评论

评论列表(0)

  1. 暂无评论