Performance PHP Beginner

Raise the WordPress Memory Limit

Give WordPress more PHP memory for the front end and wp-admin, to fix "Allowed memory size exhausted" errors.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
wp-config.php 5 lines
// Memory for front-end requests.
define( 'WP_MEMORY_LIMIT', '256M' );

// Memory for wp-admin, imports and updates.
define( 'WP_MAX_MEMORY_LIMIT', '512M' );

Where to add this

Recommended wp-config.php Above the line that says "That's all, stop editing!" in your wp-config.php file.

When a page needs more memory than PHP allows, it stops with “Allowed memory size of … bytes exhausted”. WooCommerce, page builders and imports are common causes. WordPress lets you raise its own limits from wp-config.php.

How it works

WP_MEMORY_LIMIT sets the memory WordPress asks PHP for on normal requests (WordPress’s default is 40M, or 64M on multisite). WP_MAX_MEMORY_LIMIT is used for heavier admin work like image editing and updates (default 256M).

WordPress raises the limit with ini_set( 'memory_limit' ), but it can’t go above what your host allows.

Things to watch

  • If your host caps PHP memory at 128M, these settings can’t exceed it. Ask your host to raise memory_limit in the PHP settings.
  • A memory error often points to a plugin doing something inefficient. Raising the limit is a fix, but it’s worth finding the cause.

How to test it

Go to Tools → Site Health → Info → WordPress Constants. WP_MEMORY_LIMIT should show 256M.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only