Michael Michael - 1 month ago 21x
Node.js Question

Gulp - CALL_AND_RETRY_LAST Allocation failed - process out of memory

When calling one of my gulp task, I get "

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

I found in this question that I can pass a parameter to node to increase the default memory limit :
node --max-old-space-size=2000 server.js
. But how can I tell gulp to pass a parameter to node.exe ? Here is the list of flags I can pass to gulp, I was hoping to find one that gulp passes to node when it launches it for a task.

The task causing the issue :

var gulp = require('gulp');
var imagemin = require('gulp-imagemin');

gulp.task('imagemin', function() {
var OUTPUT_FOLDER = '../Release_Prepared/';
var extensionsToOptimize = ['gif', 'jpeg', 'jpg', 'png', 'svg'];
var glob = [];

for(var i=0; extensionsToOptimize.length; i++){
glob.push(OUTPUT_FOLDER + '**/*.' + extensionsToOptimize[i]);

verbose: true


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.