title: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed — process out of memory
body: <p>To download as csv file, i dont know what is the issue, its working fine when users is 40,000 records, when ever im trying to hit the api(80,000 records) its showing process out of memory. please help me with this issue </p>
  
  <pre><code>  app.get('/excelData', function (req, result) {
   var fields = ['firstName','lastName','catalina_cardStatus','deviceType','appVerison','phoneNumber','emailAddress','language','state','lastLogin','dateOfBirth']
   var data = [];
     var status = true;
     User.find({accountType:'user',isDeleted: {$ne:{status}}}).sort({created: -1}).exec((err, res) =&gt; {
       var resultData = [];
           var len = res.length;
           res.map((user,key) =&gt;{
         var resData = {};
         if(user) {
           resData.firstName = user.firstName;
           resData.lastName = user.lastName;
           resData.catalina_cardStatus = user.catalina_cardStatus;
           resData.language = user.language;
           resData.phoneNumber = user.phoneNumber;
           resData.deviceType = user.deviceType;
           resData.appVerison = user.appVerison;
           resData.emailAddress = user.emailAddress;
           resData.state = user.state;
           resData.dateOfBirth = user.dateOfBirth;
           if(user.lastLogin){
             var date = new Date(user.lastLogin);
             var utcDate = new Date(date.toISOString());
             var utc = utcDate.setHours(utcDate.getHours()-8);
             var usDate = utc;
               var time = moment(utc).format("DD-MM-YYYY");
               resData.lastLogin = time;
           }
   }
            resultData.push(resData);
            len--;
            if(len==0){
                  var csv = json2csv({ data:resultData , fields: fields });
                  fs.writeFile('path', csv, function(err,data) {
                    setTimeout(function () {
                        fs.unlinkSync('path'.csv');
                      }, 30000);
                      result.send({msg: "saved sucessfully",path :'path.csv'});
                    if (err)
                    {
                      throw err;
                      console.log("Error: "+err);
                    }
                  })
            }
  
       })
   })
  
   });
  </code></pre>