Skip to content

fix: use temp file for non-seekable zip bodies to reduce memory (fixes #22) - #36

Open
AruneshDwivedi wants to merge 2 commits into
codeclysm:masterfrom
AruneshDwivedi:issue-22-zip-memory-fix
Open

fix: use temp file for non-seekable zip bodies to reduce memory (fixes #22)#36
AruneshDwivedi wants to merge 2 commits into
codeclysm:masterfrom
AruneshDwivedi:issue-22-zip-memory-fix

Conversation

@AruneshDwivedi

Copy link
Copy Markdown

Fixes issue #22: Heavy memory usage when extracting large zip files

Previously, when the zip body was not a seekable Reader, the entire archive was
loaded into a bytes.Buffer in memory, which could cause OOM errors for large
archives. This fix streams the body to a temporary file instead, significantly
reducing memory usage.

The temp file is automatically cleaned up via defer. The approach maintains
compatibility with zip.NewReader which requires a ReaderAt, while avoiding
the memory overhead of buffering the entire archive.

Test suite passes with this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant