How to fix WordPress memory limit errors

How to fix WordPress memory limit errors

Sometimes when installing or using themes and plugins in WordPress, you might run into errors related to the memory limit assigned to PHP. Some common messages include:

  • Allowed memory size of xxx bytes exhausted...
  • Fatal error: Out of memory...

These errors mean that WordPress has reached the allowed memory limit and needs more resources to function properly. Fortunately, you can fix this by editing a key file: wp-config.php.


What is memory_limit and why are there two values?

In WordPress, there are two important memory settings you can define:

  • WP_MEMORY_LIMIT: Sets how much memory WordPress can use for site visitors (frontend).
  • WP_MAX_MEMORY_LIMIT: Sets how much memory WordPress can use in the admin area (backend).

This allows the admin panel to run heavier tasks, such as installing themes or updating plugins, without affecting performance for regular site visitors.


How to adjust the memory_limit in wp-config.php?

Follow these steps to make the change:

1. Log in to your cPanel

Go to your cPanel at https://cpanel.yourdomain.com and log in with your username and password.

2. Open the File Manager

From the cPanel dashboard, go to File Manager and navigate to the folder where WordPress is installed (usually the public_html folder).

3. Edit the wp-config.php file

  1. Locate the file named wp-config.php.
  2. Right-click on it and select Edit.
  3. Inside the file, add the following two lines at the end:
define('WP_MEMORY_LIMIT', '128M');
define('WP_MAX_MEMORY_LIMIT', '256M');

Note: You can adjust the values based on your site's needs. For example, 256M or even 512M if you're running heavy tasks and your hosting plan allows it.


When will the changes take effect?

Changes take effect immediately. You can reload your site or retry the action that triggered the error. If the issue persists, your hosting account might have a server-level limit. In that case, feel free to contact us so we can investigate and help you resolve it.


Recommendations

  • Avoid using excessive values without reason (e.g., 1024M), as it may negatively impact your hosting account's performance.
  • If you're on a shared hosting plan, consider optimizing your plugins and themes before increasing the memory limit.
  • Always back up your site before editing system files.
    • Related Articles

    • How to Configure WP Super Cache Correctly

      WP Super Cache is one of the most efficient caching plugins for WordPress. If your site loads slowly or visitors see outdated content, a proper configuration can fix it. This guide shows you how to set it up correctly. When Do You Need to Adjust WP ...
    • What Is WP Accelerate and How to Configure It?

      WP Accelerate is a plugin designed for WordPress that includes a set of optimizations designed to improve the performance of WordPress sites hosted in environments with cPanel and CloudLinux. It integrates various techniques and tools that speed up ...
    • What Are Inodes and Why Do They Matter in Your Hosting?

      An inode is an identifier for each file or folder in your hosting account. It doesn't matter if the file is large or small: every file, image, email, or folder counts as an inode. If you reach the inode limit of your plan, you won't be able to upload ...
    • Why Is My SSL Certificate Expiring in 6 Months Instead of 1 Year?

      If you recently renewed or requested an SSL/TLS certificate and noticed that its expiration date is approximately 6 months away instead of the full year you were used to, this is not an error. It is an official, industry-wide change that applies to ...