node.js - Memory leak while uploading files -


i'm trying upload file(30gb) using formidable.whenever upload starts ram increases drastically , it's using 99% of ram. here upload logic..

app.post('/upload', function (req, res) { var path; var randomfilename; var uuid; var form = new formidable.incomingform(); encodingmodule.generateuuid(function(uuid){     uuid = uuid; }); form.on('filebegin', function(name, file) {   console.log(file.name);         file.path = null;   randomfilename = uuid+'.'+file.name.split('.').pop();   path = file.path = "./contentcache/"+randomfilename; });  form.on('end', function(){     encodingmodule.getmetadata(path,function(data){             parseapp.update('contentfile', req.query.objectid, {'fileid':randomfilename, 'videocodec':data.streams[0].codec_name, 'videobitrate':data.format.bit_rate, 'audiocodec':data.streams[1].codec_name, 'audiobitrate':data.streams[1].bit_rate, 'resolutionx':data.streams[0].width, 'resolutiony':data.streams[0].height}, function(err,response){             if(err){                 console.log("metadata:error updating object");             }             console.log(response);          });      });          console.log('local: upload successfull..!');     res.send({msg: "local: uploaded!", objectid: req.query.objectid});      videoqueue.add({video: path, filename:randomfilename, objectid:req.query.objectid});   });   //on upload error form.on('error', function(err) {   console.log('local: error occured while uploading: '+err); });  //on abort form.on('aborted', function(){    console.log('upload aborted');  });  //azure upload onfinished(req, function (err, req) {          azureupload(req.query.objectid, randomfilename, path, function(result){             console.log(result);     });        });        //parse incoming nodejs request form.parse(req); }); 

here pick file pc , upload virtual machine node server hosted.after upload ends encodes(logic in file dont want).so whenever upload starts ram usage drastically increases 10% 99% within 15 minutes.how solve this? there problem upload logic.here use express don't use body parser

first, how ram machine have ?

i'm not familiar internals of formidable maybe should try open file streamwriter , write file chunks coming in.

from formidable documentation :

form.onpart = function(part) {   part.addlistener('data', function() {     // here should write 'part' streamwriter   }); } 

this might take off load ram , have file on disk


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -