preloader

Understanding PHP Memory Limits in WordPress: What They Mean and How to Fix Them

PHP memory errors in WordPress are among the most common fatal errors. WP Server Stats shows your current memory usage and limit at a glance. Here is how to understand and act on that information.

What the PHP Memory Limit Controls

The PHP memory limit (memory_limit in php.ini) sets the maximum amount of RAM a single PHP process can use. WordPress and its plugins run as PHP processes. If a page or operation requires more memory than the limit allows, PHP terminates with a fatal error: Allowed memory size of X bytes exhausted.

WordPress itself recommends a memory limit of at least 64MB. Plugins like WooCommerce, Elementor, and heavy page builders typically require 128MB to 256MB. Sites with many active plugins may need 256MB or more.

Checking Your Current Memory with WP Server Stats

Install and activate WP Server Stats. Go to the WordPress dashboard and look for the Server Stats widget. It shows your current PHP memory usage for loading the admin page, your PHP memory limit, and the percentage used. If memory usage is consistently above 80% of the limit, you are at risk of hitting the limit on complex operations.

Finding the Memory Limit Configuration

PHP memory limit can be set in several places with different priorities:

  1. php.ini — the main PHP configuration file. Set by your host. Has the highest priority.
  2. wp-config.php — WordPress can request a higher memory limit with define( 'WP_MEMORY_LIMIT', '256M' );. PHP only honours this if the host allows it.
  3. .htaccess — On Apache, php_value memory_limit 256M may work on some host configurations.

Increasing PHP Memory Limit

The most reliable approach is to contact your host and ask them to increase the PHP memory limit for your account. Most hosts support 256MB or 512MB on standard plans. On managed hosts, there is often a setting in the hosting control panel.

If your host allows PHP configuration overrides, try adding this to wp-config.php before the line that says /* That’s all, stop editing! */:

define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );

Reducing Memory Usage Instead of Increasing the Limit

If you cannot increase the limit or want to be more efficient, identify which plugins consume the most memory. Deactivate plugins one at a time and check the WP Server Stats memory reading after each deactivation. The reading will drop noticeably when you deactivate a memory-heavy plugin. This identifies plugins worth replacing with lighter alternatives.

Also consider: switching from a heavy page builder to a lighter builder, deactivating plugins on pages where they are not needed (using Asset CleanUp), and checking whether your theme loads large amounts of data on every page.

WP_DEBUG and Memory Error Visibility

If you are getting memory errors on the front end but not seeing them clearly, enable WP_DEBUG temporarily in wp-config.php to see the full error message. The error message includes which file triggered the memory exhaustion, which points to which plugin or theme component is responsible.

For server configuration, PHP optimisation, and performance analysis on resource-constrained hosting environments, a WordPress developer can identify bottlenecks and recommend the right configuration for your site’s needs.

Keep Reading

Previous Post WordPress Comment Avatars: Setup, Styling, and Common Issues Next Post WordPress Database Size: What Is Taking Up Space and How to Clean It Up

Need Help With Your WordPress Site?

If you need help with WordPress fixes, plugin issues, theme customization, or development work, feel free to get in touch.

Get a Free Estimate