Categories: Miscellaneous

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 🙂

Alvin Poh

I've over 17 years of entrepreneurship experience, having built a tech company to be the top in the country, which was subsequently acquired for an 8-figure sum. As CEO, I led the company through robust growth to 150 employees across 4 countries. After the acquisition, I embraced minimalism, sold off my personal possessions, and started living around the world. Read more about my story here.

View Comments

  • But taking care not too make it too big, as several similtaneous events will cause choking.

  • 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?

Recent Posts

Best Protein Bar Review: Which Is The Healthiest Of Them All?

Protein bars have become the go-to snack for fitness enthusiasts, busy professionals, and health-conscious snackers…

1 day ago

What Salary Raise To Give Your Philippines Team

A salary raise can significantly enhance the motivation and loyalty of your Philippines team members.…

2 weeks ago

3 Myths About Venture Capital and Entrepreneurship

The narrative of young entrepreneurs securing vast sums from venture capitalists for their startups, particularly…

3 weeks ago

Ultimate List of Top 80 Sites to Submit Your Startup to Promote It in 2024

Launching a startup is challenging. Despite many founders having innovative ideas, only a handful successfully…

3 weeks ago

Why Retirement Isn’t What It’s Cut Out To Be

What is retirement after all? A better way of looking at retirement is that it’s…

4 weeks ago

Fix ElementsKit Mega Menu On Mobile Problems

ElementsKit has a very simple and easy-to-use Mega Menu for Elementor, but it has a…

7 months ago