Opening huge archives without huge memory
Two days in, Purrchiver could read and write nearly everything — but it did some of it the naive way, holding a whole file in memory before writing it out. That’s fine for a 2 MB ZIP and a real problem for a 20 GB one. On May 22 the engine switched to streaming, everywhere.
Extracting
Each file inside an archive is now read and written in 64 KiB chunks, straight from the archive to disk. How big the archive is stops mattering: memory use is set by the chunk size, not the file size.
The test suite got a gate to keep it that way. Extracting a 1 GiB archive was required to raise the app’s peak memory by less than 16 MiB. The first measured run came in at 0.28 MiB.
Compressing
The write side got the same treatment, reading source files in 1 MiB chunks and feeding them to the compressor as they arrive. Compression also moved off the main thread, so a long job no longer freezes the window you started it from.
The gate there: compress 1 GiB in under 60 seconds without memory running away. The first run took 18.5 seconds.
Update, October 23: the chunks didn’t keep memory flat after all. Each 1 MiB read came back in a buffer that nothing released until the whole job ended, so compressing a 1 GiB file could still peak at about 1 GB. Purrchiver 1.1 New in 1.1 frees each chunk as soon as it’s written, and tests now check that adding a 512 MiB file to an archive, or hashing one, stays flat.
No half-written files
Streaming creates a new risk. If an extraction is cancelled, or the disk fills up, halfway through a large file, you don’t want a truncated file sitting there with the real name, looking complete.
So Purrchiver writes each file to a temporary name next to its destination and only renames it into place once it’s finished. Cancel at any point and what’s left behind is either a complete file or nothing — never a convincing-looking partial one.