tags:

views:

122

answers:

1

Hi,

i have a 53 MB xml file that i want to gzip.

The code below gzip it

$gzFile = "my.gz";

        $data = IMPLODE("", FILE($filename)); 
        $gzdata = GZENCODE($data, 9); 

        //open gz -- 'w9' is highest compression
        $fp = gzopen ($gzFile, 'w9');       
        //loop through array and write each line into the compressed file       
        gzwrite ($fp, $gzdata);

        //close the file
        gzclose ($fp);

This cause

PHP Fatal error:  Out of memory (allocated 70516736) (tried to allocate 24 bytes) 

Any one have any suggestions.

I already have increase the memory in php.ini

+1  A: 

Increase the memory even further, or don't use PHP:

exec('gzip input_file.xml output_file.gzip');

Coronatus
i am not really sure that server permission allow me to run exec
ntan
toasted :-). Should be `gzip < input_file.xml > output_file.gzip` thought (edit: oh no it works your way too, forget this). Then just `readfile('output_file.gzip');` with appropriate gzip headers sent.
p4bl0
Does "not really sure" mean you haven't tried it...? How about trying first and THEN commenting.
Coronatus