#32306 [Opn->Fbk]: gzcompress() function doesn't work on a large file

From: Date: Tue, 15 Mar 2005 05:04:45 +0000
Subject: #32306 [Opn->Fbk]: gzcompress() function doesn't work on a large file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-75352@lists.php.net to get a copy of this message
ID: 32306 Updated by: rasmus@php.net Reported By: jmcgutana at alliedbank dot com dot ph -Status: Open +Status: Feedback Bug Type: Zlib Related Operating System: Linux Fedora Core PHP Version: 4.3.8 New Comment: And if you increase the memory_limit in your php.ini file? Previous Comments: ------------------------------------------------------------------------ [2005-03-15 05:29:44] jmcgutana at alliedbank dot com dot ph Description: ------------ I tried using the ZipFile class I found somewhere else to compress files and produce a zip file. But when my input file is larger than 6 megabytes in size, I don't get a zip/compressed file. I debugged the ZipFile class and found out that gzcompress() function doesn't work with a large file e.g. 6 MB file. So, in order to compress my 6 MB file and produce a zip file, I just used the ff. line of code: system("zip $zipfile_name $file_name > /dev/null", $return_val); Reproduce code: --------------- #!/usr/bin/php #phptest.php <?php $file = "ATD335R1.208"; #some file here $fp = fopen($file, "r"); if($fp) { $data = fread($fp, filesize($file)); fclose($fp); } $unc_len = strlen($data); $crc = crc32($data); $zdata = gzcompress($data); #HERE'S WHERE AN ERROR OCCURS print "GZCOMPRESS DONE..".strlen($zdata); ?> Expected result: ---------------- "GZCOMPRESS DONE.." Actual result: -------------- PHP Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 6945661 bytes) in /var/www/html/phptest.php on line 17 Content-type: text/html X-Powered-By: PHP/4.3.8 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32306&edit=1

« previous php.bugs (#75352) next »