php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32306 gzcompress() function doesn't work on a large file
Submitted: 2005-03-15 05:29 UTC Modified: 2005-03-15 08:49 UTC
Votes:5
Avg. Score:3.4 ± 0.5
Reproduced:5 of 5 (100.0%)
Same Version:3 (60.0%)
Same OS:1 (20.0%)
From: jmcgutana at alliedbank dot com dot ph Assigned:
Status: Not a bug Package: Zlib related
PHP Version: 4.3.8 OS: Linux Fedora Core
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jmcgutana at alliedbank dot com dot ph
New email:
PHP Version: OS:

 

 [2005-03-15 05:29 UTC] 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
                                                                                                                             


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-15 06:04 UTC] rasmus@php.net
And if you increase the memory_limit in your php.ini file?
 [2005-03-15 08:42 UTC] jmcgutana at alliedbank dot com dot ph
I edited php.ini file to contain the ff. line:

memory_limit = 30M ; Maximum amount of memory a script may consume

and it worked now.

THANKS!
 [2005-03-15 08:49 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Even if you think it is not a bug, we often know better than you,
please consult the support channels first before even considering
to reopen this report.

Thank you for your interest in PHP.

No bug then.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 00:01:30 2024 UTC