Hostxpeed
Login Get Started →
Troubleshooting

Fix PHP "Allowed Memory Size Exhausted"

4 min read
26 views
Jun 10, 2026

Understanding the Error

Similar to "Memory Exhausted" but often indicates WordPress or CMS issues.

WordPress Solutions

# Add to wp-config.php
define('WP_MEMORY_LIMIT', '256M');
define('WP_MAX_MEMORY_LIMIT', '512M');

If still failing, disable all plugins:

# Via WP-CLI
wp plugin deactivate --all

# Or rename plugins folder
sudo mv wp-content/plugins wp-content/plugins.bak

Re-enable one by one to find culprit.

Switch to Default Theme

wp theme activate twentytwentyfour

Check for Memory Leak in Loop

// Add to debug
error_log(memory_get_usage());
// After suspect code
unset($large_variable);

Increase for Specific Scripts

// Top of specific heavy script
ini_set('memory_limit', '512M');

Check PHP Configuration Files

# All PHP ini files
grep -r "memory_limit" /etc/php/

Ensure no conflicting settings.

Was this article helpful?