Set PHP memory_limit first, then set WordPress WP_MEMORY_LIMIT at or below it. That is the clean rule. If PHP only allows 128 MB, WordPress cannot magically use 256 MB with one line in wp-config.php. The server still gets the final vote.
TLDR: PHP memory_limit is the ceiling for each PHP request. WP_MEMORY_LIMIT tells WordPress how much of that ceiling it may use. For example, if an online store raises PHP from 128 MB to 256 MB and sets WordPress to 256 MB, checkout errors may drop from 7% to under 1%. But raising memory will not fix bad plugins, huge queries, or slow hosting.
What is memory limit in plain English?
Think of memory as a workbench.
WordPress needs space on that bench to load core files, themes, plugins, images, orders, forms, and database results. More plugins means more tools on the bench. WooCommerce adds boxes. A page builder adds a giant toolbox. A backup plugin rolls in with a forklift.
At some point, there is no room left.
Then you see ugly errors like:
- Allowed memory size exhausted
- 500 Internal Server Error
- Critical error on this website
- White screen of doom
- Import failed
Honestly, it feels like WordPress waits until you are updating a live product page before it throws the worst error possible.
PHP memory_limit: the real ceiling
memory_limit is a PHP setting. It controls how much RAM one PHP process can use.
This is not only for WordPress. It affects any PHP app on the server.
You may find it in:
php.ini.user.ini.htaccess- cPanel or Plesk PHP settings
- Your hosting control panel
- Server config files, if you manage the server
If PHP says 128M, then one request can use up to 128 MB. Not the whole site. Not all visitors combined. One request.
That matters.
A normal blog page may need 40 MB. A WooCommerce product edit screen may need 180 MB. A big page builder save action may need 256 MB or more. A backup process may ask for even more and still complain like it pays rent.
WordPress WP_MEMORY_LIMIT: the WordPress request
WP_MEMORY_LIMIT is a WordPress constant. You usually add it to wp-config.php.
It looks like this:
define( 'WP_MEMORY_LIMIT', '256M' );
This tells WordPress, “You may use up to 256 MB.”
But here is the annoying part.
If PHP is set to 128M, WordPress cannot go past it. The line still sits there looking useful. But PHP blocks it.
So this:
define( 'WP_MEMORY_LIMIT', '512M' );
does not beat this:
memory_limit = 128M
PHP wins.
WP_MAX_MEMORY_LIMIT: the admin area boost
WordPress also has WP_MAX_MEMORY_LIMIT.
This is used for admin tasks. It helps with heavier jobs like updates, image edits, plugin screens, imports, and WooCommerce order management.
Example:
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
This setup means the public site can use 256 MB. The admin area can use up to 512 MB.
Again, PHP must allow it. If PHP is set to 256M, then WP_MAX_MEMORY_LIMIT cannot reach 512M.
Which one should you change first?
Change the server setting first.
That means PHP memory_limit.
Then match WordPress to it.
A sane setup looks like this:
- Small blog: PHP 128 MB, WordPress 128 MB
- Business site: PHP 256 MB, WordPress 256 MB
- WooCommerce store: PHP 512 MB, WordPress 256 MB to 512 MB
- Large store or LMS: PHP 512 MB to 1024 MB, tested carefully
Do not just slam everything to 2048 MB and call it a day.
That is like buying a bigger bucket because your roof leaks. It helps for five minutes. Then the floor is wet again.
Does more memory make WordPress faster?
Sometimes. Not always.
More memory can stop crashes. It can help heavy admin screens load. It can make imports, exports, and image processing complete instead of dying halfway through.
But memory is not a magic speed button.
If your homepage takes 6 seconds because it loads 90 scripts, more memory may do almost nothing. If your database has 80,000 expired transients, more memory may hide the pain for a while. If a plugin runs a wasteful query, more memory lets it waste more space.
Expect to waste time on false fixes if you only raise limits and never check the real cause.
Good signs your memory limit is too low
Memory problems leave clues.
- Your site breaks during plugin updates.
- The admin area is fine until you open WooCommerce orders.
- Image uploads fail at random.
- Page builder edits crash on large pages.
- Imports stop after a few hundred rows.
- Error logs mention
Allowed memory size exhausted.
That last one is the smoking toaster.
Check your error log. It often tells you the exact limit and file. Example:
Allowed memory size of 134217728 bytes exhausted
That number is 128 MB. PHP reports it in bytes because apparently humans do not deserve joy.
How to check your current memory limits
You have a few easy options.
- Go to Tools > Site Health > Info in WordPress.
- Check your hosting control panel.
- Ask support what PHP
memory_limitis set to. - Use a trusted system info plugin.
- Check with
phpinfo()if you know what you are doing.
In Site Health, look under the server section. You may see PHP memory limit there. WordPress memory may be shown by some plugins too.
Do not rely on one screen only. Hosting panels can show one value while the actual site uses another. Container setups and per-folder config can be weird.
How to set WordPress memory safely
Add this above the line that says “That’s all, stop editing!” in wp-config.php:
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
Use quotes. Use M. Do not add spaces inside the number.
If your host allows PHP changes, set PHP memory_limit to match or exceed your WordPress values.
For example:
memory_limit = 512M
On shared hosting, you may not be allowed to change this. In that case, ask support. If they refuse to raise a 128 MB limit for a WooCommerce store, that is useful information. Painful, yes. Useful, also yes.
What values should most sites use?
Here is a simple guide.
- 128 MB: Fine for small blogs with few plugins.
- 256 MB: Good default for most WordPress sites.
- 512 MB: Good for WooCommerce, memberships, LMS, and builders.
- 1024 MB: Only for heavy sites, imports, or special workloads.
More memory means each PHP request can use more RAM. If many visitors hit the site at once, total server memory can fill up fast.
Example time.
If one request uses 256 MB and 20 requests run at the same time, that could be 5 GB of RAM. Real usage may be lower. But the risk is real.
This is why limits matter. They protect the server from one messy request eating the whole fridge.
Best setup for performance
Use enough memory to prevent crashes. Then fix the site.
A strong setup includes:
- PHP 8.2 or newer, if your stack supports it.
- Object caching, such as Redis or Memcached.
- Page caching for public pages.
- Clean plugins with no duplicate features.
- Database cleanup for junk options and expired transients.
- Image compression for large media files.
- Error log checks after every big change.
Memory is one knob. It is not the whole machine.
The simple rule to remember
PHP memory_limit is the hard cap.
WP_MEMORY_LIMIT is the WordPress cap inside that hard cap.
WP_MAX_MEMORY_LIMIT is the bigger admin cap, still trapped by PHP.
Set PHP high enough. Set WordPress clearly. Watch the logs. Test admin tasks. Then hunt slow plugins and heavy queries.
That is the sane path. Fewer crashes. Less guessing. Fewer “why is this broken now?” moments.

