Fixing WordPress Memory Limit Errors (Firstserv Guide)

Occasionally, a WordPress website may run out of available memory. This is uncommon but can occur on:

  • High-traffic websites
  • Feature-rich sites with many plugins
  • Sites with inefficient or problematic code (themes/plugins)

Common Error Messages

You may see errors such as:

Allowed memory size of xxxxxx bytes exhausted

or

Fatal error: Out of memory

These messages often include details about:

  • How much memory was used
  • Which file or process triggered the error

This information can help identify whether a plugin, theme, or script is causing the issue.


Step 1: Ensure Everything Is Up to Date

Before making changes, check that you are running:

  • The latest version of WordPress
  • Updated themes and plugins
  • A modern PHP version

✅ Newer versions are typically more efficient and may reduce memory usage.


Step 2: Check Memory Limits via WordPress

WordPress includes a built-in Site Health tool (version 5.0+), which shows your current memory limits.

How to Check

  1. Log in to your WordPress dashboard
  2. Go to Tools → Site Health
  3. Click the Info tab
  4. Expand the Server section

Here you’ll see the server PHP memory limit.


Important

  • The WordPress memory limit cannot exceed the server limit
  • If the server limit is too low, you must increase it in your hosting settings first

Step 3: Increase Server PHP Memory Limit

If required:

  1. Log in to cPanel
  2. Go to Select PHP Version → Options
  3. Increase:
    • memory_limit to 256MB or 512MB

After updating:

  • Refresh the Site Health page to confirm the new limit

Step 4: Check WordPress Memory Settings

WordPress can define its own memory limits, separate from the server.

In Site Health → Info → WordPress Constants, you may see:

  • WP_MEMORY_LIMIT (used for the frontend)
  • WP_MAX_MEMORY_LIMIT (used for the admin area)

Step 5: Update wp-config.php (If Needed)

To adjust or remove these limits:

  1. Open cPanel → File Manager
  2. Locate your WordPress root directory (e.g. /public_html)
  3. Open the wp-config.php file

Check for Existing Entries

 
 
 
 
 
 
PHP
 
 
define('WP_MEMORY_LIMIT', 'xxxM');
define('WP_MAX_MEMORY_LIMIT', 'xxxM');
 
 

Option A: Remove Limits

  • Delete these lines to allow WordPress to automatically use the server memory limit

Option B: Set Custom Limits

If required, you can define them manually:

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

⚠️ Important:

  • These values cannot exceed the server limit
  • Add them above this line in the file:
 
 
 
 
 
 
PHP
 
 
/* That's all, stop editing! Happy blogging. */
 
 

Step 6: Test and Verify

  • Save your changes
  • Refresh the Site Health page
  • Confirm the updated limits are applied
  • Test your website and admin area

When Higher Memory Isn’t the Solution

If your site still experiences memory issues even with higher limits:

  • A plugin or theme may be inefficient
  • There could be a coding issue or memory leak

✅ In these cases:

  • Disable plugins one by one to identify the cause
  • Replace or update problematic components
  • Consider consulting a developer if needed

Summary

To resolve WordPress memory errors:

  1. Update WordPress, plugins, and PHP
  2. Check current limits using Site Health
  3. Increase server memory via cPanel
  4. Adjust WordPress memory settings if needed
  5. Test thoroughly after changes

If you continue to experience memory issues, the Firstserv support team is always available to help investigate further.

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to install the Wordpress Litespeed cache plugin

  LiteSpeed Cache – What It Is and How It Helps If you’re running a WordPress website and...

How to disable the WordPress CRON job and set it up in cPanel

  Optimising WordPress Cron (wp-cron) – Firstserv WordPress does not...

Fixing WordPress mixed content issues

  Fixing Mixed Content Warnings When you visit a website using https://, your browser expects...

How to optimise your WordPress site

Optimising Your WordPress Website (Firstserv Guide) WordPress is a...

Configuring Redis Object Caching using Litespeed Cache

Object Caching and Redis (Firstserv Guide) What is Object Caching? Object caching is a...