Skip to content

How To Solve Problem of PHP Fatal error: Allowed memory size of 8388608 bytes exhausted…

I had a previously working PHP script, but it threw this error message that said: “PHP Fatal error: Allowed memory size of 8388608 bytes exhausted…”. This is something that happens when the memory requirements exceed the default 8MB limit in PHP.

If you’re getting this error message, don’t worry because it’s easy to solve.

If you want to change the memory limit for a specific script, you just need to include a line at the top of the script:

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

By doing so, you increase the memory limit to 12M (or 12 megabytes, which is 12582912 bytes). If it still gives you the same error, keep increasing the memory limit. You don’t want to give PHP too much because your server has a fixed amount of memory, and giving PHP more memory means an overall decrease in the amount of memory for any other task.

If you have several PHP scripts running on the server that require more memory, or if you don’t know which script file to edit, you can make a site-wide change by adding a line to the server’s php.ini file:

memory_limit = 12M

OR

You can also create your changes in a .htaccess file and put it in your site’s root. Include these lines:

php_value upload_max_filesize 16M
php_value max_execution_time 200
php_value post_max_size 16M
php_value max_input_time 100
php_value memory_limit 16M

That’s it! You’re all set, and you shouldn’t see the error message anymore 🙂

3 thoughts on “How To Solve Problem of PHP Fatal error: Allowed memory size of 8388608 bytes exhausted…”

  1. Hi,
    i have the same problem. and this effected the Arts category when i try to open that from admin side that wont’, and when i do any update/edit from admin this show me the same error on next page. you cannot believe that i had to set the Memory size to 256M then it stopped showing me that error. but an other problem this redirected me to the front end in stead of taking effect on the edit command.
    and didn’t still show that category on front end.
    then i had to create an other category shifted the sub categories in that and rename to arts. but the real one still didn’t open even its empty now.
    honestly i am not only disappointed but pissed off too on Link Directory that behave. that cannot be a reliable code(i was so stupid to consider this php link directory code as best product)

    by the way can this be a reason if you submit your directory to many link directories same time? just having idea why that happens?

Leave a Reply

Your email address will not be published. Required fields are marked *