PHP Classes

Fatal error: Allowed memory size exhausted

Recommend this page to a friend!

      TAR/GZIP/BZIP2/ZIP Archives  >  All threads  >  Fatal error: Allowed memory size...  >  (Un) Subscribe thread alerts  
Subject:Fatal error: Allowed memory size...
Summary:*.tgz file ok. error when create *.zip
Messages:5
Author:Joćo
Date:2007-02-03 13:11:54
Update:2007-07-17 16:28:15
 

  1. Fatal error: Allowed memory size...   Reply   Report abuse  
Picture of Joćo Joćo - 2007-02-03 13:11:54
Hello.

I am using this package at WXP+apache+php4.4 and WXP+IIS+php4.4 and every thing is fine.

But when I try to use Kubuntu6.10+apache+php5 i have this error when trying create a *.zip file:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 3694306 bytes) in archive.php on line 635

I am not understanding what is wrong because *.zip file is create just after a *.tgz file. *.tgz file is created with no errors.

Can you help me?

  2. Re: Fatal error: Allowed memory size...   Reply   Report abuse  
Picture of Lee Moberly Lee Moberly - 2007-07-17 08:19:53 - In reply to message 1 from Joćo
Did you ever find a solution?

I'm experiencing the exact same error:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 5811902 bytes) in /homepages/11/d89117087/htdocs/onoffrecords/archive.php on line 635

  3. Re: Fatal error: Allowed memory size...   Reply   Report abuse  
Picture of Joćo Joćo - 2007-07-17 11:51:50 - In reply to message 2 from Lee Moberly
I won’t name it a solution.

I enlarged the memory limit to the script adding the line

ini_set("memory_limit","---M");

where ‘---‘ is the limit value (ex. 64). This value depends on the size of the file you are compressing.

In my case, the size of the files has a maximum value.
If this is not your case, you can find the size of the file (ex. use filesize() function) and then set the value of the ini_set() function.

Hope this help.

  4. Re: Fatal error: Allowed memory size...   Reply   Report abuse  
Picture of Lee Moberly Lee Moberly - 2007-07-17 15:13:41 - In reply to message 3 from Joćo
Thanks for the tip!

Adding the line:

$old=ini_set(memory_limit,"35M");

...helps. But there still seems to be a size limit for individual files being zipped: 10mgs.

If I zip 4 files, each having a size <10mgs your in_set() solution works; if just one of those files is >10mgs, server error. Bleh.

I've tried several combinations of things (my host allows certain PHP.INI variables to be superceded) and nothing seems to overcome the 10mg file size limit.

If you find any more solutions, please let me know - I'd certainly appreciate the help.

  5. Re: Fatal error: Allowed memory size...   Reply   Report abuse  
Picture of Joćo Joćo - 2007-07-17 16:28:15 - In reply to message 4 from Lee Moberly
Hello

1 - I don’t know if it makes difference but all parameters in the function are strings, so memory_limit must be in quotes, ie, “memory_limit”. See http://pt.php.net/ini_set.

2 - Make the value stupidly big like 128 (or even more stupid).

Probably you tried all this possibilities already. But, for now, I don’t have better ideas.

ini_set() function returns the old value on success and FALSE on failure. So, print the value of $old
var_dump($old);
to know if a failure occurred.

Reading your post, I suppose that you are using a host service and have no full control on it. So I would suggest you to ask your host service if php host let you do what you want.

Good luck.