node.js - How to make NodeJS use all the memory allocated -


this first time on project uses quite bit of memory , have observed strange phenomenon.

i reading in excel file of size 43mb , saving in array. think need way stream client i'm still curious.

i run code running node excelparsertool.js --max-old-space-size=10000 allocate 10gb of memory program.

the below code

let csvwriter = () => {     let workbook = new excel.workbook();      console.log(`before reading ${json.stringify(process.memoryusage())}`);     workbook.xlsx.readfile('myfile').then((err, data) => {         console.log(`after reading ${json.stringify(process.memoryusage())}`);          workbook.eachsheet((worksheet, sheetid) => {             let writestream = fs.createwritestream(`./sheet${sheetid}`);              worksheet.eachrow({includeempty: true}, (row, rownumber) => {                 let eachrow = '';                  row.eachcell({includeempty: true}, (cell, colnumber) => {                      if(cell.value !== null && typeof cell.value === 'object'){                         eachrow += json.stringify(cell.value) + ', ';                     }else if(cell.value === null){                         eachrow += ', ';                     }else {                         eachrow += cell.value + ', ';                     }                     console.log(`through each cycle ${json.stringify(process.memoryusage())}`)                 });                  eachrow += '\n';                 writestream.write(eachrow);             });             writestream.end();         })     }) }; 

the point each line read, printing process.memoryusage() can see how memory being consumed. when program dies saying javascript heap out of memory last memory usage says through each cycle {"rss":1549365248,"heaptotal":1509969920,"heapused":1479087128,"external":3724116}

heaptotal , heap used 1.5gb way below have allocated program. also, when see computer stats, more 7gbs available still used. why this?

you set memory flag in wrong place

node [options] [ -e script | script.js ] [arguments]

so should node --max-old-space-size=10000 excelparsertool.js in case


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -