Snippet

Increase the WordPress Memory Limit

WordPress asks PHP for 40 MB of memory on a normal website and 64 MB on a multisite. That is enough for a simple blog, but page builders, online stores and big plugins often need more. When they run out, you see the “Allowed memory size exhausted” error or a blank white screen. You can raise the limit using the following code. For the full story on that error, read how to fix the WordPress memory exhausted error.

Where to place? wp-config.php, above the line that says /* That’s all, stop editing! */.

Usage

  • To fix the “Allowed memory size exhausted” error.
  • On websites that run page builders, WooCommerce or other heavy plugins.
  • To give the dashboard more room for big tasks like imports, updates and image processing.

Code


// Memory WordPress can use for your pages
define( 'WP_MEMORY_LIMIT', '256M' );

// Memory for heavier work in the dashboard
define( 'WP_MAX_MEMORY_LIMIT', '512M' );

These lines can only raise the limit as far as your hosting allows. If your plan caps PHP memory lower than this, ask your host to raise it.

Explanation

  1. A comment for the first line.
  2. Setting WP_MEMORY_LIMIT to 256 MB. This is the memory WordPress asks for when it builds your pages.
  3. A comment for the second line.
  4. Setting WP_MAX_MEMORY_LIMIT to 512 MB. WordPress uses this higher limit for heavy jobs in the dashboard.