Welcome Guest, Not a member yet? Register   Sign In
Allowed memory size exhausted
#1

[eluser]Arpanet[/eluser]
Hi there,

I've been receiving this error message when trying to upload photos;

Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 11328 bytes) in /user/htdocs/CodeIgniter/libraries/Image_lib.php on line 1157

Obviously this is something to do with the memory limit set in php. My website is on a shared hosting platform and the memory_limit in php is set to 20mb.

What I don't understand is that the photo I have been uploading is only 2mb. I have tried a couple of solutions that I found online, but these don't seem to have had any effect;

1. Set the following in the index.php;
Code:
ini_set("memory_limit","30M");

2. Set the following in the .htaccess;
Code:
<IfModule mod_php5.c>
############################################
php_value memory_limit 30M
php_value max_execution_time 18000
</IfModule>

Has anyone else had this issue?

Thank you.
#2

[eluser]mddd[/eluser]
First question: the photo you uploaded may only be 2 MB, but that is compressed JPEG format. PHP has to hold the picture in memory and expand it before it can work with it. Also, if you make a thumbnail or copy, the image is in memory twice: once the original, once the copy. So that is why it takes much more memory than the original file size.

Second question: both these statements should give you more memory space, unless your server is configured so you can't change your memory limit.
You can check, for instance using phpinfo(); to see what the default setting is and what the current value really is, after you have tried to set it to the bigger value.
#3

[eluser]Arpanet[/eluser]
Hey, thanks for the reply.

Yes, the 2mb photo that is uploaded is then resized two times to make a thumbnail and 'medium' version of the same photo.

I'm guessing the server default cannot be changed. Php info still tells me that the limit is 20mb and using both of the statements I used have no effect. Does this mean my only option would be to move it to a dedicated server where I can set the php memory limit to meet my requirements?
#4

[eluser]Jelmer[/eluser]
You could also try the following:
Code:
ini_set("memory_limit","96M");
#5

[eluser]Arpanet[/eluser]
Thanks man. I'm assuming this can just go anywhere in the index.php?
#6

[eluser]cahva[/eluser]
If you cant change it from .htaccess, you probably cant change it anywhere if you're on a shared server. I work in a hosting company and we sure dont like that our customers could set the memory limit by themselves on a shared server. But ofcourse we have it set to 32M by default so it is sufficient for most people Smile

But just ask your host to boost it a little, its that simple Smile
#7

[eluser]Arpanet[/eluser]
Heh, i'm with Fasthosts. Nothing is ever that simple. Wink




Theme © iAndrew 2016 - Forum software by © MyBB