node-archiver icon indicating copy to clipboard operation
node-archiver copied to clipboard

Heap out of memory with archiver.append()

Open Dirshant opened this issue 1 year ago • 1 comments

Got a Heap out of memory error, I am appending 1,000,000 file streams to the archive.append(file_stream, { name: file_name }) one by one in a loop seems like the archiver keeps the reference of all streams in heap memory finally throwing the Heap out of memory error.

// After archiver initialization and pipe to the output stream ... ... for (const file of files) { const result = await S3Service.createLazyDownloadStream(file); if (result.fileResponse) { try { archive.append(result.stream, {name: getKeyPath(result)}); } catch (error) { Logger.logInfo('Error appending to archive:'+ error); } } } await archive.finalize(); ... ...

Dirshant avatar Feb 01 '24 18:02 Dirshant

Have you found the reason?

yrx00go avatar Apr 16 '24 08:04 yrx00go