Gulp - CALL_AND_RETRY_LAST Allocation failed - process out of memory

江枫思渺然 提交于 2019-11-30 20:17:01

I just found out today that gulp can be given any V8 option and it will be passed to node. For example, do gulp yourTask --max_old_space_size=2000 and it will give you the results you want. To see a list of V8 flags to pass, type node --v8-options in your terminal.

In our case First time it was Fine when i was executing gulp build command. I have Four separate tasks. Each task creates separate built files for each modules. we have been running Gulp command for the final build.

There we faced the process out of memory issue continuously. Even though if we allocate large memory to the process. Like below - around 8GB. But, still it was failing.

gulp --max-old-space-size=8192

Solution:

  1. Just delete the previous built files which is created already. And the above command creates the new file. So the process works seamlessly.

For example: Delete main-built.js Manually / Through automation commands.

  1. In other case just clear the cache by executing the below command.

npm cache clean

  1. Since we had large amount of JS files. that is also another case, it could cause this kind of problems. Remove unwanted and unused Js files.

Hope this helps.

I was able to solve this issue by manually deleting my built js/css (dest) files, then re-running the gulp task. This goes along with RJK's answer above, but did not have to allocate new memory.

I believe you should run this kind of command when you start the bash script build

node --max-old-space-size=2000 ./node_modules/.bin/gulp {your gulp script e.g gulb.js}

Search for gulp.cmd and modify that file like this:

@IF EXIST "%~dp0\node.exe" ( "%~dp0\node.exe" "%~dp0\node_modules\gulp-cli\bin\gulp.js --max-old-space-size=1400" %* ) ELSE ( @SETLOCAL @SET PATHEXT=%PATHEXT:;.JS;=;% node "%~dp0\node_modules\gulp-cli\bin\gulp.js --max-old-space-size=1400" %* )

Give more memory not solved to me. What happen:

I lost some days with this problem, until I found that in some file I was importing a class from one static file, a builded file. It make the build process to never end. Something like:

import PropTypes from "../static/build/prop-types"; 

Fixing to the real source solved all the problem.

I had a simple project that ended up using gulp-imagemin, and had the same issue. The root issue was having LARGE marketing images and Gulp/Node just ran out of memory.

I could of course perform the accepted answer here. But these 4,000+ by 3,000+ pixel images had no business going up on the web anyways, and this error really just reminded me I missed re-sizing some of my images.

So if you get a similar error, check that you have appropriate sized images as gulp/node shouldn't choke on most normal sized builds.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!