I want to know how I can destroy a Buffer in order to free memory.
I have the code below, it creates a Buffer and send this one as response. This works fine but when I play with a big array like with 75 000 rows, I can see my memory takes over 1Go, it's ok but when the response is sent, this memory is kept and not free... I try to set var buffer
to null
at the end of the script but nothing append... Is there a solution to free this memory ?
var xlsxexport = require('node-xlsx');
module.exports = {
exportExcel: function (req, res) {
var excelData = []
// ...
// Construction of the array excelData
// ...
var buffer = xlsxexport.build([{name:'export', data:excelData}])
res.set 'Content-Type', 'application/vnd.openxmlformats'
res.set 'Content-Disposition', 'attachment; filename=' + filename
res.send buffer
}
}