Php unpack huge files

I am trying to unzip a huge file (400 + M compressed over 4G unzipped) using the zpp zip archive. I only unzip one csv file in a zip file. The file that I am interested in is unpacked, exceeds 4G .. I get up to 3 entries from the end of the file, and the process takes off to the ground. I mean, the process just continues .. there is no output .. there are no errors, its cycle just continues ... I don’t know what it does .. my code is simple:

$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) 
{
   $num = $zip->numFiles;
   for($i = 0; $i < $zip->numFiles; $i++) 
   {
      $filename = $zip->getNameIndex($i);
  // if its the file I want then...
      $content = '';
  // my output file  .. yes I've already checked to make sure the dir exists
      $unzipped = fopen($dir ."/2" . $filename  , 'wb');         
      $fp = $zip->getStream($filename);
      if(!$fp) exit("failed\n");
      while (!feof($fp))
      {
    $chunkSize = 10240;
    $contents = fread($fp, $chunkSize);
        $fwrite = fwrite($unzipped, $contents);
      }
      fclose($fp);
      fclose($unzipped);
    }

    $zip->close();
    fclose($filename);

}  

, , . . ( , 3 )... , , -.. , , .. .. ( is_source ($ fp) fread.. .. .. apache.. , ...

+3
3

, ( php).

memory_get_usage(), . , , . stream_copy_to_stream(), . intresteting, , , , , .

+1

, , script. gzip, .

ini_set('memory_limit', '512M');
+1
$filename = '/media/file.gz';

$unzipped_content = '';   
$zd = gzopen($filename, "r");
while ($zip_file = gzread($zd, 10000000)){
    $unzipped_content.= $zip_file;
}
gzclose($zd);

echo $unzipped_content;
0
source