evanmiller / mod_zip

Streaming ZIP archiver for nginx 📦
https://www.nginx.com/resources/wiki/modules/zip/
BSD 3-Clause "New" or "Revised" License
215 stars 64 forks source link

Fix memory usage when reading input #94

Closed dimaryaz closed 1 year ago

dimaryaz commented 2 years ago

Currently, every time mod_zip reads 8KB, it allocates a new string, copies all existing data, and doesn't free the old string. This results in GBs of memory use for a 10MB input.

Just use an nginx array which automatically doubles in size as needed. (Still leaks memory, but not as much.)

Fixes https://github.com/evanmiller/mod_zip/issues/67

evanmiller commented 1 year ago

Thanks!