Increase WordPress memory limit

Updated on October 29, 2025

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_LIMIT sets 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_LIMIT sets the maximum amount of memory that WordPress will use on the backend. The default is 256M or WP_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

  1. Always backup your site before changing wp-config.php

    For guidance, see Build a good backup strategy for your WordPress website.

  2. Open wp-config.php (located in the root of your WordPress installation)

    For guidance, see Edit wp‑config.php on WordPress – 3 easy ways.

  3. 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.

  4. 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.

  5. Define WP_MEMORY_LIMIT

    The syntax is define('WP_MEMORY_LIMIT', '32M'); where 32M can 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 keyword define is case-sensitive, do not use DEFINE. You can put spacing between the parameters if you prefer.

  6. 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.

  7. 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

What is WP_MEMORY_LIMIT?

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.

Why would I need to increase the WordPress memory limit?

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.

What’s the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?

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.

What is the default WP_MEMORY_LIMIT value?

The default value when not specified is 40M (40 megabytes) for single sites, and 64M for multi-sites.

How can I determine my current memory limit?

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.

Is WP_MEMORY_LIMIT affected by PHP settings like memory_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.

Where is WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT configured in the WordPress source code?

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.

Reference

License

Licensed under CC BY 4.0 You are free to share and adapt this content for any purpose as long as you give appropriate credit in a reasonable manner.

No affiliate links

We do not participate in affiliate marketing, and we are not paid to mention products.

Leave a Reply

Your email address will not be published. Required fields are marked *