Skip to content

[System.IO.Compression] ZipArchive copies Stream to MemoryStream #32577

Closed
@ThomasGoulet73

Description

@ThomasGoulet73

I am extracting multiple multiple large zip files asynchronously using ZipArchive with the constructor ZipArchive(Stream, ZipArchiveMode.Read) and I get an OutOfMemoryException because the constructor copies my stream to a memory stream entirely and it does not seem to do anything with it (https://github.com/dotnet/corefx/blob/bc115700c3ece60acd6b8dbe4b0bdb8f6f80c756/src/System.IO.Compression/src/System/IO/Compression/ZipArchive.cs#L146). I think it is just replacing the stream parameter with a new memory stream, copies the old stream parameter to the new stream parameter and seek to beginning so that the calling method can reuse the stream.

Would it be possible to avoid copying the stream to a memory stream to reduce memory usage ?

It would also be nice to have asynchonous methods like ZipArchive.ExtractToDirectoryAsync and ZipArchiveEntry.ExtractToFileAsync with events in ZipArchive like ArchiveEntryExtracted for progress.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions