There are several configurable memory limits that control the maximum amount of memory used by WordPress. The following two values can be configured:
WP_MEMORY_LIMITsets the maximum amount of memory that WordPress will use on the front-end. The default is 40M for single sites and 64M for multi-sites.WP_MAX_MEMORY_LIMITsets the maximum amount of memory that WordPress will use on the backend. The default is 256M orWP_MEMORY_LIMIT, whichever is greater.
Both values can be configured in wp-config.php:
define('WP_MEMORY_LIMIT', '40M');
define('WP_MAX_MEMORY_LIMIT', '256M');You don’t need to define both if you are setting WP_MEMORY_LIMIT to a value greater than 256M. This is because WordPress will automatically set WP_MAX_MEMORY_LIMIT to the greater of WP_MEMORY_LIMIT or 256M.
Note that both values are constrained by the maximum memory permitted by your hosting provider. The maximum is often configured through settings in php.ini or .htaccess, but this will vary between hosting companies. Refer to your hosting documentation or contact support for assistance.
Instructions
- Always backup your site before changing wp-config.php
For guidance, see Build a good backup strategy for your WordPress website.
- Open wp-config.php (located in the root of your WordPress installation)
For guidance, see Edit wp‑config.php on WordPress – 3 easy ways.
- Look for a definition of WP_MEMORY_LIMIT
The memory limit is defined with a constant named
WP_MEMORY_LIMIT.This constant is not defined by default. However, you should check whether it was defined by a prior admin. If you find the entry, edit it instead of creating a duplicate definition. - Ensure WP_MEMORY_LIMIT will be defined early enough
Before inserting or editing the definition, make sure you are above the comment that says
/* That's all, stop editing! Happy publishing. */. If the comment has been removed, make sure you are above the line that includes wp-settings.php. If you define the memory limit after this, it may be ignored. - Define WP_MEMORY_LIMIT
The syntax is
define('WP_MEMORY_LIMIT', '32M');where32Mcan be set to your preferred limit. Do not forget the semicolon at the end of the line. Do not forget to enclose both parameters in single quotes. The keyworddefineis case-sensitive, do not use DEFINE. You can put spacing between the parameters if you prefer. - Save and confirm
From the side menu, go to Tools > Site Health and click the Info tab. Expand the WordPress Constants section and confirm WP_MEMORY_LIMIT is your desired limit.
- If you enabled debug mode, be sure to turn it back off.
You may have enabled DEBUG mode when diagnosing the memory issue. You should not leave debug mode on permanently as it will consume extra resources and may leak sensitive information to visitors.
Frequently Asked Questions
WP_MEMORY_LIMIT is a constant in WordPress that defines the maximum amount of memory the application can use during normal operations. It helps ensure your site has enough resources to run plugins, themes, and core functions smoothly.
You might need to increase it if you’re seeing errors like “Allowed memory size exhausted,” or if you’re running resource-intensive plugins (e.g., WooCommerce, page builders, security scanners). A higher memory limit can improve performance and reduce crashes or slowdowns.
WP_MEMORY_LIMIT sets the memory available for regular WordPress operations. WP_MAX_MEMORY_LIMIT sets the memory available for administrative tasks, like running updates or importing large files.
The default value when not specified is 40M (40 megabytes) for single sites, and 64M for multi-sites.
To view the current limit without opening wp-config.php, go to Tools > Site Health and click the Info tab. Expand the WordPress Constants section and confirm WP_MEMORY_LIMIT is your desired limit.
Yes. WordPress cannot exceed the PHP memory_limit set in your server’s configuration. For example, if PHP is limited to 128M, setting WP_MEMORY_LIMIT to 256M won’t work unless you also increase the PHP limit via php.ini, .htaccess, or your hosting control panel.
The default values for WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT are defined in wp-includes/default-constants.php. The same section of code constrains the values to the maximum limit defined in php.ini.

Leave a Reply