maennchen/ZipStream-PHP

Allowed memory size of ... bytes exhausted

cgebhard opened this issue · 1 comments

Description of the problem

ZipStream dies in mid stream with error:
[message] => Allowed memory size of 402653184 bytes exhausted (tried to allocate 131072 bytes)
[file] => vendor/maennchen/zipstream-php/src/File.php
[line] => 131

ZipStream works fine for smaller archives. This one dies at around 19.6MB. 10Ks of small files around 7000 bytes each.

Example code

$Opt = new ZipStream\Option\Archive();
$Opt->setComment('Test');
$Opt->setSendHttpHeaders(true);
$Opt->setFlushOutput(true);

 $Zip = new ZipStream\ZipStream('test.zip', $Opt);
// loop 10Ks of iterations... {
$this->Zip->addFileFromPath('testloop.html', '/filesystem/file_location');
// endloop }
$Zip->finish(); 

Informations

  • ZipStream-PHP version: 2.1.0
  • PHP version: 7.3.28

Please include any supplemental information you deem relevant to this issue.

I've tried changing lots of options with no luck. These changes all produced the same error:

$Opt->setLargeFileMethod(ZipStream\Option\Method::STORE());
$Opt->setLargeFileSize(3000000);
$Opt->setDeflateLevel(-1); // tried 3 and 6 too
$Opt->setEnableZip64(true); // tried false too

You need to edit your php.ini to allow more memory (memory_limit).