[SOLUTION] Fatal error: Allowed memory size of X bytes exhausted [SOLUTION] Fatal error: Allowed memory size of X bytes exhausted
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

[SOLUTION] Fatal error: Allowed memory size of X bytes exhausted

Started by Johnneke, July 08, 2007, 06:49:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Johnneke

Hello everyone, just like many others I had the Fatal error: Allowed memory size of X bytes exhausted. Quickly finding the stickied post but that was a huge bummer as this was what it said:

QuoteAlternative 1 (ideal):Increase the memory limit allocation in php.ini. You must be the server's administrator to do this. Also, .htaccess files cannot change this configuration setting, and it cannot be changed using ini_set().

I tried the other alternatives but even pictures at 640x480 didnt got through the standard 8M that php is set at.
Now out of curiosity I went to the Gallery 2 forums to see what they said about this error (It's a php error so every gallery using gd will do the same) and I was amazed to see them stating the opposite of the admin on this board!

.htaccess CAN CHANGE this setting
and it CAN BE CHANGED using ini_set().

I'm running coppermine integrated in a joomla installation with search engine friendly links so I was already using a .htaccess file so I went ahead and tried what they said at Gallery 2 FAQ. Here it is, it DID fix the solution to me completely, while not being able to upload 640x480 pics I can now upload high res photo's as you can see on http://www.huisdierengedrag.be/gallerij. As a sight note, the ini_set() command shown here is specific for gallery 2 installations, if anyone can figure out if which php file it goes of the cpg installation that would be great ;)

Quote from Gallery 2 FAQ:

You are exhausting the available memory that PHP has access to. In php.ini there is a config variable named memory_limit that by default is set to 8MB. Edit php.ini and increase it to a larger value (restart Apache afterwards). If you don't have access to php.ini, you can add this line to your .htaccess file in your gallery2 folder. Usually, unless you are the owner of the server, you don't have access to change php.ini. If there is no .htaccess file yet, you can create one (it's just a text file with the name '.htaccess').
php_value memory_limit [new memory limit]

To change it to 24 MB, write:
php_value memory_limit 24M

If the .htaccess method does not work or if you get an internal server error after adding this line, remove the line from the .htaccess again. You can also try to change the memory_limit by adding the following line right after '<?php ' in install/index.php and in main.php:
ini_set("memory_limit","32M");

Johnneke

Oh BTW I'm not the server administrator or anything, I use paid hosting on a shared enviroment and the .htaccess fixed it for me, it will most likely NOT work on free hosts

Joachim Müller

Thanks for sharing your insight. However, your solution will not work for most on shared webhosting. The amount of allowed memory consumption is crucial for the number of shared hosting accounts a webhost can have on one server, that's why most webhosts disable both the .htaccess method as well as the PHP-method. However, for some your suggestion may work, so you're right: we should review the corresponding section in the sticky thread and clartify that there may be an option for some to overcome the memory limitations using the methods discussed.