How to fix Fatal Error: Allowed Memory size Exhausted WordPress error? Increase PHP memory_limit

Last updated
App Shah

Crunchify » Blogging Tips » How to fix Fatal Error: Allowed Memory size Exhausted WordPress error? Increase PHP memory_limit

Sometimes based on your hosting provider and wrong PHP setting you may get similar error like this:

Fatal error: Allowed memory size of 52349183 bytes exhausted

How to solve this PHP fatal error?

  • Fix PHP fatal error
  • How to increase PHP memory limit?
  • WordPress increase memory limit to 1GB

First let’s understand why we are getting this error. Sometimes in order to load page WordPress has to load some of the objects into the memory. Like, post data, references, WordPress hooks information, and lot more. Everything is handled by PHP in memory. Now, while loading a specific page request, if PHP doesn’t have enough memory to store all of these data then page will crash and throws fatal error saying, Allowed Memory size Exhausted.

This is not a good scenario for your users. Solution is very simple.

Solution-1

Open wp-config.php file and add below line to file.

define( 'WP_MEMORY_LIMIT', '1024M' );

Solution-2

  • Using cPanel. Click on Click on Switch to PHP Options link.
  • Look for memory_limit key and increase value to 1G.

 

That’s it. 1G is enough and you shouldn’t see any memory exhausted error any more. I would suggest avoid modifying php.ini file because if you messed up with it, your whole site won’t load until you fix it.

cPanel method is the best, recommended and right way to increase php memory limit.

Leave a Comment