我试图解压缩大文件解压缩大转储文件,我遇到了这个常见问题:
local.ERROR:Symfony \ Component \ Debug \ Exception \ FatalErrorException: 允许的内存大小为134217728字节耗尽(尝试分配 123732000字节)在/ Users / ...
中
我知道我可以增加内存限制并且应该可以工作,但我认为问题出在我的代码中并且我做错了什么:
public function unzip() {
// unzip file
// set input and output files
$out = 'storage/app/dump/auct_lots_full.sql';
$in = 'storage/app/dump/auct_lots_full.sql.bz2';
// decompress file using BZIP2
if (file_exists($in)) {
$data = '';
$bz = bzopen($in, 'r') or die('ERROR: Cannot open input file!');
while (!feof($bz)) {
$data .= bzread($bz, 4096) or die('ERROR: Cannot read from input file');;
}
bzclose($bz);
file_put_contents($out, $data) or die('ERROR: Cannot write to output file!');
echo 'Decompression complete.';
}