WordPress Errors & Fixes

Complete Guide to Fixing WordPress Memory Limit Errors

WordPress Memory Limit Solutions

“Allowed memory size exhausted” errors are among the most common WordPress performance issues. This comprehensive guide will walk you through understanding memory limits, diagnosing the root causes, and implementing professional solutions to fix these errors permanently.

Step-by-step solutions
Beginner-friendly guide
Expert-approved methods

Understanding WordPress Memory Limit Errors

WordPress memory limit errors occur when your PHP scripts attempt to use more memory than allocated by your server configuration. These errors typically appear as:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /wp-admin/includes/post.php on line 632

Primary Causes of Memory Errors

Plugin Overload

Poorly coded plugins or having too many active plugins can consume excessive memory. Common culprits include:

  • Page builders (Elementor, Divi, WPBakery)
  • Security plugins (Wordfence, Sucuri)
  • Backup solutions (UpdraftPlus, BackupBuddy)
  • SEO plugins with extensive features

Theme Issues

Bloated themes can significantly impact memory usage through:

  • Excessive bundled plugins
  • Poorly optimized code
  • Unnecessary features running in background
  • Compatibility problems with WordPress core

Traffic Spikes

Sudden increases in visitors can overwhelm your allocated memory during:

  • Product launches or sales
  • Viral content periods
  • Seasonal traffic peaks
  • Marketing campaign spikes

Memory Allocation Standards

Hosting Type Default Memory Recommended Max Available Typical Cost
Shared Hosting 40-64MB 128MB 256MB $3-$10/month
Managed WordPress 128MB 256MB 512MB+ $20-$100/month
VPS Hosting 128MB 256-512MB Custom $10-$50/month
Dedicated Server 256MB 512MB-1GB Custom $80-$300+/month

Diagnosing Memory Issues

Before attempting to increase memory limits, proper diagnosis helps identify the root cause and appropriate solution.

Method 1: Using WordPress Debug Mode

Enable debug mode by adding these lines to your wp-config.php file (above the “That’s all, stop editing!” line):

// Enable WP_DEBUG mode
define('WP_DEBUG', true);

// Enable Debug logging to /wp-content/debug.log
define('WP_DEBUG_LOG', true);

// Disable display of errors
define('WP_DEBUG_DISPLAY', false);

// Enable script debugging
define('SCRIPT_DEBUG', true);

After triggering the error, check /wp-content/debug.log for memory-related warnings and the specific files/plugins causing issues.

Method 2: Using Diagnostic Plugins

Query Monitor

Query Monitor

Developer Tools Panel

The developer-grade plugin for analyzing performance, including memory usage, PHP errors, hooks, and database queries.

4.9/5 ★★★★★
Install Now
Health Check

Health Check

Troubleshooting Mode

Official WordPress plugin that includes memory usage monitoring and troubleshooting mode to test with default theme.

4.8/5 ★★★★★
Install Now

Method 1: wp-config.php Solution (Recommended)

The most reliable method for increasing WordPress memory allocation through the configuration file.

Step 1: Access Your wp-config.php File

Locate the file in your WordPress root directory using:

  • FTP/SFTP: FileZilla, WinSCP, or your preferred client
  • cPanel File Manager: Navigate to public_html or your WordPress directory
  • SSH: Use commands like nano wp-config.php

Step 2: Add Memory Constants

Insert this code before the line that says “That’s all, stop editing! Happy publishing.”:

// Increase WordPress memory limit
define('WP_MEMORY_LIMIT', '256M');
define('WP_MAX_MEMORY_LIMIT', '256M');

For multisite installations, add define('WP_ALLOW_MULTISITE', true); before the memory limits.

Recommended Memory Limits

Small Sites

64M – 128M

Medium Sites

128M – 256M

Large Sites

256M – 512M

E-commerce

256M – 1G

Step 3: Verify the Changes

After saving the file, verify the new memory limit is active:

// Create a test file (memory-test.php) in your root directory with:
<?php
// Output current memory limit
echo 'Current memory limit: ' . ini_get('memory_limit');
?>

Access this file via your browser (e.g., yoursite.com/memory-test.php) to confirm the new limit.

Troubleshooting Tips

  • If changes don’t take effect, your hosting provider may have server-level restrictions
  • Check for syntax errors in wp-config.php – a single typo can break your site
  • For WordPress Multisite, you may need higher limits (256M-512M recommended)
  • If you get 500 errors after editing, restore from backup and try again

Method 2: Server Configuration Solutions

When wp-config.php modifications aren’t sufficient or when you need system-wide changes.

Option A: php.ini Modification

; WordPress optimized PHP configuration
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 180
max_input_time = 180
max_input_vars = 3000

Locate php.ini in your root directory or create one if it doesn’t exist. Common locations:

  • /public_html/php.ini
  • /etc/php/8.1/fpm/php.ini (version may vary)
  • Your hosting control panel’s PHP configuration section

Option B: .htaccess Configuration

# WordPress memory configuration
php_value memory_limit 256M
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 180
php_value max_input_time 180

Note: Some hosting providers disable .htaccess memory overrides. If changes don’t take effect, contact your host or use php.ini instead.

Advanced Troubleshooting

1. Plugin Conflict Analysis

  1. Deactivate all plugins via FTP by renaming the /wp-content/plugins folder to plugins_deactivated
  2. Create a new empty plugins folder
  3. Reactivate plugins one by one while checking memory usage
  4. Use the Health Check plugin’s troubleshooting mode for safer testing

2. Theme Testing

  1. Switch to a default WordPress theme (Twenty Twenty-Three)
  2. If the error disappears, your theme may be the culprit
  3. Check theme requirements and compatibility
  4. Contact the theme developer with debug.log findings

3. PHP OpCache Configuration

[opcache]
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000
opcache.revalidate_freq=60
opcache.enable_cli=1

Add these settings to your php.ini file to optimize PHP’s built-in caching mechanism.

Performance Optimization

1. Database Optimization

  • Clean up post revisions, spam comments, and transients
  • Use WP-Optimize or similar plugins
  • Optimize database tables via phpMyAdmin
  • Limit post revisions in wp-config.php: define('WP_POST_REVISIONS', 5);

2. Media Optimization

  • Compress images before uploading (use Imagify or Smush)
  • Implement lazy loading for images
  • Serve WebP images with WebP Express
  • Use a CDN for media delivery

3. Caching Solutions

  • Object Caching: Redis or Memcached
  • Page Caching: WP Super Cache or W3 Total Cache
  • Browser Caching: Configure via .htaccess or hosting panel
  • OPcache: Enable in PHP configuration

Hosting Considerations

Shared Hosting

Budget-friendly but limited resources. Suitable for small sites with low traffic.

Max: 256MB $3-$10/mo

Managed WordPress

Optimized for WordPress with better performance and support.

Max: 512MB+ $20-$100/mo

VPS/Dedicated

Full control with customizable resources for high-traffic sites.

Custom Limits $50-$300+/mo

Expert FAQ

Conclusion

Resolving WordPress memory limit errors requires a systematic approach:

  1. Start with Method 1 (wp-config.php) – The most WordPress-friendly solution
  2. Implement Method 2 if needed – For server-level configuration changes
  3. Optimize rather than just increase – Address root causes through performance tuning
  4. Monitor continuously – Use tools mentioned in our FAQ section

When to Seek Professional Help

Consider consulting a WordPress specialist if:

  • Errors persist after trying all recommended solutions
  • Your site has complex custom functionality
  • You’re running a high-traffic eCommerce site
  • You need enterprise-grade optimization
Contact Our WordPress Experts

Need Immediate WordPress Help?

Our team of WordPress performance specialists can resolve your memory issues quickly and optimize your site for peak performance.