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

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

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.