PHP Memory Limit in WordPress: What It Is, Why It Breaks, and How to Fix It

performance

Most WordPress site owners don't think about the php memory limit until something breaks. It's a per-process ceiling that controls how much RAM a single PHP script can use, and it has nothing to do with how much total RAM your server has. That gap between what the server has and what a single script is allowed to use is where most memory errors come from, and the sections below explain how to find it, understand it, and fix it correctly.

PHP Memory Limit in WordPress: What It Is, Why It Breaks, and How to Fix It

Key Takeaways

Key Takeaways
Photo by RealToughCandy.com on Pexels

What PHP Memory Allocation Really Means and Why Errors Happen

PHP memory allocation works at the script level, not the server level. Each time your server handles a request, it runs a PHP process and caps that process at a set memory amount. If the script needs more than that cap allows, it fails, regardless of how much RAM the server has sitting unused.

This is why the error can feel confusing. You might be on a hosting plan with 8GB or 16GB of RAM and still see a memory exhausted message. The server's total RAM is not the limit. The per-process ceiling is.

Default values vary. Some shared hosts set the limit at 32MB or 64MB. Others start at 128MB or 256MB. The number your host chose often reflects their server density and how many accounts share the same machine, not what your site actually needs.

Is the "Allowed Memory Size Exhausted" Error Different From a White Screen?

Both symptoms come from the same cause, but they look different depending on one setting. When WordPress debug mode is on, PHP prints the error directly: "Allowed memory size of X bytes exhausted." When debug mode is off, the page goes blank instead.

The white screen of death is more common on live sites because most production environments run with debug mode disabled. A blank page after installing a plugin or running a large import is a strong signal to check memory first.

The WordPress Site Health tool is the fastest way to see your current PHP memory limit without editing any files. Go to Tools, then Site Health, then the Info tab. The Server section lists the PHP memory limit your host has configured.

( )

Site Health shows you the PHP-level limit, not the WordPress-level limit. That's a separate number set by WordPress's own constants, and it's often lower than the PHP ceiling. If your PHP limit looks fine but errors keep appearing, the WordPress constants are the next place to check.

Before touching any configuration file, try deactivating plugins one at a time. If the error disappears after removing a specific plugin, that plugin is the source of the problem, not the memory ceiling itself.

WordPress Memory Constants: WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT Explained

WordPress memory constants add a second layer of memory configuration that sits inside the PHP-level ceiling. The server sets a hard ceiling with the PHP memory limit WordPress can use. WordPress then uses its own constants to request a specific amount within that ceiling. If the constant requests less than the ceiling allows, WordPress stops at the constant's value.

WP_MEMORY_LIMIT applies to front-end page loads. WP_MAX_MEMORY_LIMIT applies to wp-admin operations, which need more memory because they handle plugin updates, bulk actions, and media processing.

If you haven't defined these constants yourself, WordPress uses its own defaults. The front-end default has historically been 40MB. That number falls short of what most modern WordPress sites actually consume. The admin default is higher but still often not enough for plugin-heavy setups.

Why WooCommerce and Page Builders Push Memory Limits Harder Than Standard Sites

A basic WordPress blog loads a manageable set of PHP files per request. A WooCommerce store is a different situation. Every page load may trigger product lookups, pricing calculations, cart checks, and calls to third-party payment or shipping integrations.

Page builders add a similar load. They assemble pages from components at runtime, which means more PHP, more CSS, and more database calls happening at the same time.

WordPress's recommended memory minimums have gone up over time to reflect this. The old defaults of 32MB and 64MB were set when WordPress was primarily a blogging platform. Today, 256MB is widely treated as a starting point for any site running WooCommerce or a page builder, not a high-end allocation.

( )

The fix is to define both constants explicitly in your wp-config.php file. Setting them yourself means you know exactly what WordPress is requesting, and you're not relying on fallback values that may not match your site's actual needs.

How to Increase PHP Memory Limit in WordPress and Which Method Wins

There are four places where you can set the memory limit, and they don't all carry the same weight. The method that works for one hosting environment may do nothing on another. Knowing the precedence order is what makes the difference.

From highest to lowest authority on most setups: the hosting control panel, php.ini, .htaccess, and wp-config.php. The control panel wins on shared hosting. On a VPS or dedicated server, php.ini is typically the authoritative source.

Why Your Memory Limit Change Might Not Be Taking Effect

If you added a line to wp-config.php and nothing changed, your host's server configuration is overriding it. On shared hosting, many hosts lock php.ini at the server level. A wp-config.php change only controls what WordPress requests — it can't push past a ceiling the server has already set.

This tells you something useful about your host. A host that gives you access to PHP settings through a control panel or a custom php.ini gives you real control. A host that locks those settings means any change requires a support ticket or a plan upgrade.

wp-config.php is the right starting point for WordPress-specific changes. Adding define('WP_MEMORY_LIMIT', '256M'); tells WordPress to request up to 256MB for front-end processes. It works within whatever the server allows.

php.ini sets the PHP-level ceiling directly. Adding memory_limit = 256M to a php.ini file in your site's root applies to all PHP processes on that account, not just WordPress. It takes precedence over wp-config.php.

.htaccess works on Apache-based servers using php_value memory_limit 256M. On servers running Nginx or OpenLiteSpeed, this directive is ignored. If your host uses either of those, skip this method.

Setting the limit to -1 removes the ceiling entirely. PHP will use as much memory as the script requests. This is occasionally useful for debugging a single session, but it's not safe to leave in place on a live site. A script with a memory leak will consume everything available and can take down other processes on the same machine.

( )

Raising the limit solves the immediate error. It doesn't fix what caused it. Deactivating plugins one at a time is still the most direct way to find the source. Object caching reduces repeated database calls by storing results in memory for reuse, which lowers overall consumption. Running PHP 8.x instead of an older version also helps — newer PHP versions process the same code using less memory.

The Bottom Line

There are three things happening at once when a WordPress memory error appears: the server's PHP ceiling, WordPress's own memory constants, and whatever plugin or process is pushing usage past the limit. Fixing only one of them, usually by raising the ceiling, stops the error temporarily. Fixing all three means checking your constants, finding what's consuming the memory, and making sure your hosting environment gives you the control to adjust settings without filing a support ticket. If you're not sure which of these applies to your setup,.

FAQs

Is 256MB enough for a WordPress site?

For most WordPress sites, 256MB is a workable starting point. Sites running WooCommerce, page builders, or a large number of active plugins may need more. The right number depends on your plugin stack. WordPress's recommended minimums have increased over time, and 256MB is now a baseline, not a ceiling.

What does setting the PHP memory limit to -1 actually do?

Setting the limit to -1 removes the per-process cap entirely. PHP will use as much server memory as the script requests. This is sometimes useful for a single debugging session but shouldn't stay in place on a live site. A script with a memory leak will consume all available memory.

What's the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?

WP_MEMORY_LIMIT sets the memory WordPress requests for front-end page loads. WP_MAX_MEMORY_LIMIT sets the higher amount it requests for wp-admin operations. Both work within the server's PHP ceiling. Setting them explicitly in wp-config.php gives you control over both values.

Can upgrading to a newer PHP version reduce memory errors?

Yes. PHP 8.x processes the same code using less memory than older versions. Upgrading your PHP version can bring memory usage below your current limit without changing the limit itself. It's worth checking which PHP version your host currently runs on your account.

Does object caching lower PHP memory usage in WordPress?

Object caching stores database query results in memory so they don't need to be fetched again within the same request or across requests. This reduces the number of memory-intensive operations per page load. It won't replace a properly set memory limit but can reduce how close your site gets to that limit.

See What's Included With Nova Managed Hosting

Nova runs every managed WordPress tenant in an isolated Kubernetes namespace with daily automated backups and managed core/plugin updates. If you're troubleshooting a specific issue on your own site, our team can help.