读写大文件导致内存溢出(FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory)
菜鸟请教各位,下面的代码有问题吗?有没有另外一种可能,服务器网速慢,读写速度不一致导致内存溢出呢?
self._init(filePath, function() {
var config = self.config;
resp = self.resp;
fReadStream = fs.createReadStream(filePath, {
encoding : 'binary',
bufferSize : 1024 * 1024,
start : config.startPos,
end : config.fileSize
});
fReadStream.on('data', function(chunk) {
resp.write(chunk, 'binary');
});
fReadStream.on('end', function() {
resp.end();
});
});