Increase the WordPress Memory Limit [7 Easy Methods]

Some WordPress users run into the Memory Exhausted error. Today we will show you how to fix it and increase allocated memory in WordPress.

Updated: 04 Jul, 24 by linda Y 8 Min

List of content you will read in this article:

As your WordPress site grows, you might encounter performance issues, particularly when running resource-intensive themes or plugins. One common solution to address these performance hiccups is to increase the WordPress memory limit. This adjustment can help ensure your site runs smoothly, offering a better experience for both administrators and visitors. In this guide, we'll explore why increasing the WordPress memory limit is essential and how you can easily do it.

WordPress is written in PHP, a server-side programming language. Web servers are just like any other computer. They need memory to efficiently run multiple applications at the same time. Server administrators allocate specific memory sizes to different applications, including PHP.

When the allowed memory size of an allocated amount of bytes is exhausted it means the PHP script responsible for running a process or function has been exceeded. This can occur when there are poorly optimized scripts or too many resources (like plugins) attempt to allocate too much or all of the memory available on a server. When this happens, WordPress gives you the following error: “Allowed memory size of bytes exhausted”.

It will look something like this:

There are a few possible reasons why this error could occur and it is very important to fix it because increasing the allocated memory in WordPress can improve performance and handle larger tasks. Here's how you can do it:

Edit wp-config.php 

By default, WordPress sometimes sets a WP_MEMORY_LIMIT that can be too low for the required operations and lead to memory-related errors. Therefore, you need to increase WP_MEMORY_LIMIT by editing the wp-config.php file. To do so, follow these simple steps:

Step 1: Go to your control panel first.
Step 2: Enter the File Manager section or use an FTP client

Step 3: Then go to the Public_html folder
Step 4: Open the wp-config.php file with the editor which is in the root directory of your WordPress installation.

Step 5: Add the following code before the line that says /* That's all, stop editing! Happy publishing. */: 

define ('WP_MEMORY_LIMIT', '128M');

Step6: Then save the file and upload the wp-config.php file back to your server if you are using FTP.

Change your server settings via PHP.ini

To put it simply, the php.ini file controls how PHP works and it may have a huge impact on your website’s functionality. However, php.ini is not a WordPress core file, it is located in a file that controls your PHP settings, including the PHP version and PHP scripts. This file is usually managed by your hosting provider and you can find this file by FTP client or plugins like WP File Manager. 

When you gain access to your PHP.ini file, change the line responsible for memory allocation in it. If your line shows 32M try 128M:
memory_limit = 128M ;

It is important to mention that this is an advanced method and you may face some other errors in the process. In that case, please contact your web hosting provider.

Edit your .htaccess file

If you don't have access to PHP.ini try editing your .htaccess file. To do so:
Step 1: Access your WordPress file through your hosting provider's file manager.

Step 2: find the .htaccess file. which is located in the root directory of your WordPress installation.

Step 3: Edit the file by adding the following line:

php_value memory_limit 128M

Disable all plugins

Here’s a general rule for WordPress site management: If you have just updated a plugin or theme and you're seeing errors, try rolling back to a previous version.

In most cases, if you get a memory limit error it's due to a faulty plugin or theme. If you set it to 128 M using one of the previous methods and are still getting the error, then you for sure know it's due to a faulty plugin. So the key question is what plugin did you install prior to this and uninstall it?

If this still doesn’t work, disable all plugins and start re-activating them one by one until you run into the error again. This way you will know that the plugin you enabled last is the culprit.

Optimize Images

Uploading and processing large media files including images and videos can affect memory significantly. To increase WordPress Memory Limit, use plugins to optimize images and other media files and reduce their size and memory. 

Check Your Caching Settings

Another reason behind the WordPress memory exhausted error is the huge cache. To fix this problem, implement a caching plugin like W3 Total Cache or WP Super Cache to reduce the load on the server.

Upgrade Your Hosting Plan

If none of the aforementioned methods helped you get rid of the error, it is time to contact your hosting provider. They can look into it and help you with any further steps you need to take. If you have a web hosting service from Monovm and are facing this error, you can contact us via live chat, email, or our advanced ticketing system and we will assist you in solving this problem.

WordPress Memory Exhausted Error can occur due to several reasons, simply because WordPress needs more memory than it's been allocated. Here are some common causes:

  1. Large plugins: Some plugins are memory-intensive, especially if they include complex features, heavy caching, or extensive functionality. 
  2. Large themes: Similar to large plugins, some themes require more memory to operate, particularly those that handle extensive data processing, backups, or scripts.
  3. Poorly Coded Plugins/Themes: Inefficient or poorly coded plugins and themes may cause memory leaks or excessive memory usage which leads to WordPress Memory Exhausted Error.
  4. High Traffic: Websites with high traffic encounter memory issues due to the increased number of simultaneous requests, which can overwhelm the server's resources. A high volume of traffic can increase memory usage as more processes are handled simultaneously.
  5. Heavy Media Files: Handling large media files such as images, and videos need higher memory usage, especially if the server tries to resize or manipulate them.
  6. Complex Queries: Complex database queries, particularly those generated by plugins, can consume a lot of memory. This is common with plugins that involve reporting, analytics, or custom post types.
  7. WordPress Core Updates: Updates to WordPress core, plugins, or themes might temporarily increase memory usage, particularly during the update process.
  8. Server Configuration: The server’s PHP memory limit may be set too low. This can be adjusted in the `php.ini` file or via the `.htaccess` file.
  9. Database Issues: An inefficient database schema or large database size can lead to memory issues, especially if there are large options or transient records.
  10. Background Processes: Scheduled tasks (WP-Cron jobs) or background processes such as backups, automated updates, or email sending can spike memory usage. 

It is very important to keep track of your WordPress’s memory usage. Mainly because if your server runs out of memory, it can have negative effects on your website’s function. Therefore, you need to pay attention to your system memory before anything serious happens. Many plugins can help you with that. One of these plugins is called TPC! Memory Usage. This plugin tracks the memory usage in your WordPress and is extremely helpful when testing new plugins, or if there are a lot of modifications, plugins, or large language files. It will show your current and peak memory usage and notify you through email when you are running out of memory. 

While there are also other possible causes for the WordPress Memory Exhausted error to occur, for the majority of cases, the methods outlined in this tutorial are more than sufficient to get rid of it. If you were able to resolve this error in a different way, have any questions about the methods show in this blog, or have other suggestions, please leave them in the comment section below.

Many different ways can help you to fix the memory exhausted error in WordPress, including increasing wp memory limit, changing the server setting, disabling plugins, optimizing media, and upgrading the hosting plan.

To fix the fatal error allowed memory size exhausted, try increasing wp memory limit by editing wp-config.php file, changing the server setting, disabling plugins, optimizing media, and upgrading the hosting plan.

To increase the WP memory limit in WordPress, you need to edit the wp-config.php file by adding this line: define ('WP_MEMORY_LIMIT', '128M');

WP_MEMORY_LIMIT defines the maximum amount of memory that PHP scripts can allocate in WordPress. This is an important feature for running complex operations within WordPress, such as large plugins, themes, or importing/exporting large amounts of data.

linda Y

linda Y

My name is Linda, I have Master degree in Information Technology Engineering. I have some experiences in working with Windows and Linux VPS and I have been working for 2 years on Virtualization and Hosting.