PHP memory limit
The PHP memory limit is the most memory one request to a site may use before PHP stops it. WordPress asks for 40 MB on ordinary pages and 256 MB in the dashboard unless you set otherwise, and it can only raise the limit as far as the host allows.
- By
- WP Ministry
- Published
In short
- The limit is a ceiling for each request, not memory handed to your site. Raising it does not make pages faster.
- WP_MEMORY_LIMIT is what WordPress asks for on every page, and WP_MAX_MEMORY_LIMIT what it asks for in the dashboard. PHP's own memory_limit, set by the host, has the last word.
- If a line in wp-config.php changes nothing, the host does not let the limit be raised from there. Ask the host.
The PHP memory limit is the most memory one script may use. PHP, the language WordPress is written in, runs a separate script for each request to a site, and the limit applies to each one on its own. PHP's manual says it is there to stop a poorly written script from eating all the memory on a server. A script that asks for more is stopped where it stands.
It is a ceiling, not an allowance. A page that needs 30 MB uses 30 MB whether the limit is 64 MB or 512 MB, so raising the limit does not make a site faster. It only lets a request that was being stopped run to the end.
Three settings, one limit
| Setting | Where it is set | What it is | Default |
|---|---|---|---|
memory_limit | PHP's own configuration, by the host | The limit itself. | 128M in PHP. A host may set another. |
WP_MEMORY_LIMIT | wp-config.php | What WordPress asks for on every request. | 40M, or 64M on a multisite network |
WP_MAX_MEMORY_LIMIT | wp-config.php | What WordPress asks for when it has heavier work: dashboard screens opened by an administrator, image processing and scheduled tasks. | 256M |
Two rules decide what you get:
- WordPress only raises the limit. If PHP's own setting is already higher than
WP_MEMORY_LIMIT, WordPress leaves it alone. A site on a server set to 128M runs its pages at 128M, not 40M. - It can raise the limit only where the host lets a script change it. Where the host does not, WordPress takes the server's value as its own and the lines in wp-config.php change nothing. From PHP 8.5 a host can also set
max_memory_limit, a cap thatmemory_limitcannot be raised above.
Where you meet it
In an error, on screen or in the log:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1052672 bytes)The first number is the limit in bytes. 134217728 bytes is 128 MB.
And under Tools, then Site Health, on the Info tab. Server has the row "PHP memory limit" and, when the dashboard runs with a different one, "PHP memory limit (only for admin screens)". WordPress Constants has WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT.
What goes wrong
- A page runs out. Visitors see a critical error, a blank page or a 500. How to fix "Allowed memory size exhausted" has the line to add. If the screen does not show the message, how to fix a critical error says where to find it.
- An image will not upload. Making a picture's smaller sizes takes memory, and a large one can use all of it. See how to fix the "HTTP error" when uploading images.
- The line in wp-config.php does nothing. The host's setting cannot be raised from there, so ask the host to raise
memory_limit. Reaching a limit does not prove the plan is too small: see how to tell whether the fault is the host or the site. - Raising it hides the cause. WordPress's documentation warns that a higher limit can hide the root of a problem, which comes back as plugins are added. If a page fails at 256M, something is using memory it should not.
Common questions
What should the WordPress memory limit be?
Enough for the heaviest page your site builds. WordPress itself asks for 40M and raises that to 256M for dashboard work. WooCommerce's server requirements ask for a WordPress memory limit of 256 MB or greater. Past that, look for the cause before you raise the number again.
I set WP_MEMORY_LIMIT and the PHP memory limit did not change. Why?
There are three usual reasons. The value you set is lower than PHP's own limit, and WordPress never lowers it. The line sits below the stop-editing line in wp-config.php, where it is read too late. Or the host does not let the limit be changed from a script, and only the host can raise it.

