|  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
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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
49 - 26 = ?
Subscribe to this entry?

 [2005-03-15 05:29 UTC] jmcgutana at alliedbank dot com dot ph
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
$file = "ATD335R1.208";  #some file here
$fp = fopen($file, "r");
if($fp) {
        $data = fread($fp, filesize($file));
$unc_len = strlen($data);
$crc = crc32($data);
$zdata = gzcompress($data); #HERE'S WHERE AN ERROR OCCURS
print "GZCOMPRESS DONE..".strlen($zdata);

Expected result:

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-15 06:04 UTC]
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.

 [2005-03-15 08:49 UTC]
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 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-2021 The PHP Group
All rights reserved.
Last updated: Sun Dec 05 10:03:38 2021 UTC