Reputation: 110
Do you know any solucion to unpack large .gz in php (>200 MB .gz, >4GB original... maybe in packs of >1GB or >2GB inside) ?
Solucion of decode .gz part by part is needed.
Code
gzdecode(@file_get_contents($file))
gets PHP error:
PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate ...
of course.
I cannot increase the PHP memory limit of the webserver, and it seems to be no point in trying while data >>1GB.
Using inflate_add() isn't solution, it generates the same "PHP Fatal error: Allowed memory size ... exhausted ...".
Any idea? (I found no answers in 1, 2 etc.)
Upvotes: 0
Views: 625
Reputation: 1002
came right here, my error might be different, but Google showed this page first. so for anyone coming here:
'gzdecode(): insufficient memory'
In my case this was due to a wrongly placed boolean that told gzdecode the length of decoding would be 1.
Upvotes: 0
Reputation: 112374
Use gzopen()
instead of gzdcode()
. Then you can read small chunks at a time with gzread()
.
Upvotes: 1