The “Allowed Memory Size Exhausted” error is the quintessential WordPress crash. It happens when a PHP script tries to allocate more RAM than the server allows. At CODE TOT, we see this most often on sites using heavy page builders like **Elementor** or running huge WooCommerce inventory syncs. Fixing it for good requires more than just a quick limit increase—it requires identifying the “leaking” plugin.

Professional Insight: Even if your server has 32GB of RAM, a single PHP script is still limited by the memory_limit in your php.ini. You should aim for a healthy balance—setting it to 256MB is standard for modern WordPress, but 512MB might be necessary for enterprise-level builds.

1. How to Increase the Limit Properly

WordPress has its own memory setting that it *proposes* to the server. Add these lines to your wp-config.php file *above* the “stop editing” line:

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

If this doesn’t work, your server’s main PHP configuration is overriding WordPress. On RunCloud, you can change this in your Web App settings under “PHP Settings”.

2. Finding the “Memory Hungry” Plugins

Increasing the limit is just a band-aid if you have a **memory leak**. Use the Query Monitor plugin to see which plugin is consuming the most memory on a single page load. If you have SSH access, you can also use `top` or `htop` to identify PHP workers that are consuming high amounts of RSS memory:

# Sort processes by memory usage
top -o %MEM

3. The “mu-plugins” Trap

Sometimes you might deactivate all plugins and still see memory errors. Check your wp-content/mu-plugins/ (Must-Use Plugins) folder. These plugins cannot be deactivated from the dashboard and they load before everything else. Many hosting platforms (including managed RunCloud setups) place optimization scripts here that might conflict with your site’s codebase.

4. Object Caching and Memory

If you use Redis or Memcached, unoptimized queries can fill up your object cache and cause memory spikes during the “cache hydration” phase. If you’re seeing persistent memory issues on a high-traffic site, flushing your object cache via WP-CLI might provide temporary relief while you debug your database queries:

# Purge Redis/Memcached data
wp cache flush

Conclusion

Memory errors are a sign that your site’s demands are exceeding its resources. By balancing your PHP limits and auditing your plugin stack with tools like Query Monitor, you can maintain a fast and stable WordPress environment. For a deeper audit of your site’s performance, explore our Infrastructure Consulting services.