adm-zip icon indicating copy to clipboard operation
adm-zip copied to clipboard

The problem that adm-zip reads zip files takes up a lot of memory!

Open wangmings opened this issue 3 years ago • 9 comments

The problem that adm-zip reads zip files takes up a lot of memory

wangmings avatar Feb 17 '22 02:02 wangmings

I face the problem too, si that possible to make the get entities as a lazy iterator?

congzhangzh avatar Feb 20 '22 01:02 congzhangzh

It seems it already support it(do not use getEntities is a key part)?

https://github.com/cthackers/adm-zip/blob/bebbabf600a6ae5d64ee31cbc89a1274bd1d8c1f/zipFile.js#L140

https://github.com/cthackers/adm-zip/blob/bebbabf600a6ae5d64ee31cbc89a1274bd1d8c1f/zipFile.js#L148

https://github.com/cthackers/adm-zip/blob/bebbabf600a6ae5d64ee31cbc89a1274bd1d8c1f/zipFile.js#L25

@wangmings can you have a try?

congzhangzh avatar Feb 20 '22 02:02 congzhangzh

I tried to replace getEntries with getEntryCount and it couldn't be executed. I didn't study the specific source code! The process of decompressing zip files is a process from small to large! In this decompression process, a lot of operations are required, which will inevitably take up a lot of memory resources! I think this question should be unsolved!

wangmings avatar Feb 20 '22 02:02 wangmings

Currently adm-zip loads entire file into memory, and handles things there. Yes iterators exists but they are not lazy.

5saviahv avatar May 28 '22 01:05 5saviahv

I think there is also a memory leak present in adm-zip or memory fragmentation under Linux. Causing memory to increase every time I unzip the same file. And not giving the memory allocation back to the system. 😢

melroy89 avatar Feb 12 '23 22:02 melroy89

I'm trying to add support for Blob instead of Buffer so that only the needed data could be put into memory with .slice(...). This should allow opening huge zip files (e.g. 50GB) as well (as long as the single files to extract are still fitting into an ArrayBuffer.)

mbehr1 avatar Oct 15 '23 07:10 mbehr1

I'm trying to add support for Blob instead of Buffer so that only the needed data could be put into memory with .slice(...). This should allow opening huge zip files (e.g. 50GB) as well (as long as the single files to extract are still fitting into an ArrayBuffer.)

How did this go, anything merged?

lindstrm avatar Mar 18 '24 15:03 lindstrm