PHP Allowed Memory Size Exchausted Fatal Error

A functional PHP script returns the following error either on the web page or in Apache error log file when it exchausted and used up the default memory requirement of 8 MB memory allocation:

PHP Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate … bytes) in …

The error normally occurs when PHP tries to process a big database records or when importing or exporting. To solve the error, there are two resolutions. One is to change and increase the memory limit of the particular PHP script by adding or including an additional line at the top of the script:

ini_set(”memory_limit”,”16M”);

You can assign the memory limit to any amount you like by changing the 16M to other number, such as 12M or 24M. 16M will set the memory limit to 16 megabytes. If this doesn’t work and the PHP error still appearing, increase the memory limit until the PHP scripts running perfectly or the limit of your system hardware.

To change the memory allocation limit permanently for all PHP scripts running on the server, modify the PHP.INI configuration file of the server (location depending on your OS and installation method). Search for memory_limit after opening the file in an editor. If the memory_limit doesn’t exist, add the following line. If it’s there, modify the value of the memory_limit:

memory_limit = 12M

The 12M sets the limit to 12 megabytes (12582912 bytes). Change to the value you desirable.

An alternative way is to modify your PHP scripts that generate the error for more efficiency and better data handling.


10 Responses to “PHP Allowed Memory Size Exchausted Fatal Error”

  1. Maya75
    August 12th, 2009 00:08
    10

    To catch PHP’s fatal errors, like “Out of memory” or “PHP Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate … bytes) in”, see here : http://php.net/manual/en/function.set-error-handler.php#88401

  2. nakul
    April 16th, 2009 17:31
    9

    I want to increase my memory limit in php server where is i write the script ini_set(”memory_limit”,”16M”);

    If u have any other option then send me plz.

  3. Angelo
    November 8th, 2008 08:41
    8

    THANKS VERY MUCH….

  4. online information
    May 22nd, 2008 11:15
    7

    I have ever got the same problem, but this ini_set(”memory_limit”,”12M”); line could not solved my problems. I just removed all waste plugin. And walah, It worked.

  5. albachtimi
    May 1st, 2008 13:34
    6

    where is PHP.INI location???

  6. Peter
    March 6th, 2008 10:32
    5

    After trying many solutions in order to get Wordpress to co-operate with Microsoft live writer. I finally came here and after editing “/wp-admin/includes/image.php”, the problem was solved.

    I just needed to add…

    ini_set(”memory_limit”,”12M”);

    … right under the <?php tag

  7. jawarh
    February 16th, 2008 19:50
    4

    thanks

  8. Relieved
    January 31st, 2008 11:20
    3

    Exactly what I was looking for to solve my problems! Thanks for the simple and clear instruction!

  9. Angel
    January 27th, 2008 17:35
    2

    I follow your instruction by modifying php.ini and it works. Thanks for sharing this information.

  10. freelovers
    December 19th, 2007 09:58
    1

    I have same problem with yours. Can this problem solved by editing any wordpress file? or….
    without configuring php.ini?
    thanks before

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.
Custom Search

New Articles

Incoming Search Terms for the Article

php set memory limit - ini_set memory limit - php ini_set memory - ini_set memory - php set memory - php ini_set memory limit - php ini_set memory_limit - set memory limit php - php memory - ini set memory limit - php ini set memory limit - php allowed memory size - memory php - ini set memory - catch php out of memory error - allowed memory size exhausted - php memory exhausted - php Fatal error: Allowed memory size of - php ini set memory - php allowed memory size exhausted - php set memory size - php increase memory size - PHP Fatal error: Allowed memory size - PHP Fatal error: Allowed memory size of - php increase allowed memory size - allowed memory size php - ini_set php memory - ini_set php memory limit - php memory size - set memory php - php Fatal error: Allowed memory size - ini_set allowed memory - increase php memory size - php ini set memory size - php fatal error allowed memory size of - Allowed memory size of 12582912 bytes exhausted - apache allowed memory size - php set mem - set php script memory limit - allowed memory size exhausted php - ini set memory limit php - php exhausted memory - set memory limit in php - ini_set memory limit php - memory limit php ini set - php memory limit ini_set - set php memory limit - apache allowed memory size exhausted - php memory limit - set memory size php -