How to check and increase your WordPress site's memory limit? Print

  • wordpress, memory, limit, error, exhausted
  • 0

WordPress can sometimes run out of memory. This isn't very common, and usually only happens on either extremely busy or fully featured sites (lots of plug-ins and/or functionality) or if there's a code issue with a theme or plug-in being used.

You'll often see an error something like -

Allowed memory size of xxxxxx bytes exhausted.

or

Fatal error: Out of memory

followed by some detail about what was allocated/attempted to be allocated and what file was making the request - this can often be a clue as to where to look for any code issues.

Sometimes, however, it may just be a case that the site needs more memory available in order to run.

 

How to fix?

 

  1. WordPress has two memory limits you can set.

    WP_MEMORY_LIMIT - this sets the PHP limit for the front-end of the site - this would usually be what you'd need to set if your site was experiencing fatal errors.
    WP_MAX_MEMORY_LIMIT - this sets the PHP limit for the admin area of the site - this can be set higher, or lower than WP_MEMORY_LIMIT 

  2. To confirm, or set these limits if they are lower than your server PHP limit you'll need to edit the WordPress wp-config.php file.
    You'll find this file in the root directory of your site. You can access it via cPanel File Manager or FTP.

    Check your wp-config.php for either of the following lines:

    define( 'WP_MEMORY_LIMIT', '512M' );
    define( 'WP_MAX_MEMORY_LIMIT', '512M' );

    However, should you require a different limit you can add either line, with your required memory limit. Please ensure you add any additional entries above the "stop editing" line -
    /* That's all, stop editing! Happy publishing. */

    Remember the limits you set can't exceed the server limit.
    Save your wp-config.php file and refresh the Site Health page to confirm the new limits are in place.

  3. Login to your cPanel account and go to Select PHP Version, then go to options, then make sure memory_limit is set to the same number you set in wp-config.php file ( In step 2 )

Was this answer helpful?

« Back

Powered by WHMCompleteSolution