How to Increase WordPress Memory Limit

Published on July 20, 2023 by Simon Wright

At some point in time, most WordPress site owners will encounter a memory limit issue. Often referred to as PHP memory limit errors, these are where the allotted memory size is exhausted, and the system cannot continue. Often appearing as “fatal errors,” these can strike fear in many people, but they needn’t, as the fix is quite straightforward. So, in today’s article, we will show you how to increase the WordPress memory limit.

Why Increase the WordPress Memory Limit?

Each and every website hosted on a server has a specific memory allocation that it can use. The WordPress memory limit refers to the maximum amount of memory a WordPress installation can use on a host server. By default, WordPress sets the memory limit to 64MB, which is usually enough for most smaller websites. However, as your website grows and you add more media, features, and plugins, you may need more memory to ensure optimal performance.

Increasing the WordPress memory limit can help prevent common issues such as getting stuck in the maintenance mode, the frozen “white screen of death,” or other annoying WordPress error messages. It can also improve website speed and performance, which is crucial for user experience and search engine optimization.

How to Increase the WordPress Memory Limit

There are two main methods for increasing the memory limit used by your WordPress installation:

Let’s now explore each in detail.

Method 1: Editing the wp-config.php File

The wp-config.php file plays a crucial role in your WordPress installation as it houses vital configuration settings, including the memory limit. If you wish to expand the memory limit using this approach, you can follow the step-by-step instructions outlined below:

  • Create a backup

Creating a backup copy is a good idea before making changes to your WordPress installation. This ensures that you have a safeguard in case any issues arise during the process.

  • Locate the wp-config.php file

The wp-config.php is typically located in the root directory of your WordPress installation. You can access it through an FTP client or the file manager used by your hosting company, such as cPanel or Plesk.

  • Open the wp-config.php file

Next, using a text editor such as WordPad, Notepad, Sublime Text, or any other preferred tool, open the wp-config.php file by right-clicking on the file and selecting the “Edit” option.

  • Locate the code line defining the WordPress memory limit

Within the wp-config.php file, you will come across a line that defines the memory limit. It typically appears as follows:

define(‘WP_MEMORY_LIMIT’, ’64M’);

where ’64M’ is the current memory limit. In this example, the limit is 64 megabytes, although the actual number in your WordPress may differ.

  • Increase the WordPress memory limit

To increase the WordPress memory limit, simply modify the numeric value in the code line mentioned above based on your requirements. For example, to raise the limit to 128 megabytes, the line should look like this:

define(‘WP_MEMORY_LIMIT’, ‘128M’);

  • Save the changes

Once you have made the necessary adjustment, save the wp-config.php file.

  • Upload the modified file

If you accessed the wp-config.php file via an FTP client or file manager, you may now upload the modified version into the root directory of your WordPress installation, replacing the original file.

You have now successfully increased the WordPress memory limit by adjusting the wp-config.php file. Easy, right?

Method 2: Editing the PHP.ini File

The PHP.ini file is a vital configuration file utilized by PHP, the programming language that powers WordPress. By editing this file, you can effectively raise the memory limit for all PHP applications on your server, extending beyond just WordPress. Here’s a comprehensive guide on how to accomplish this:

  • Create a backup

We strongly advise backing up your WordPress site prior to making changes to the php.ini file. Doing so gives you something to fall back on should you encounter any unexpected issues during the memory limit increase process.

  • Log in to the hosting account of your WordPress installation

How you log into you’re the hosting panel of your WordPress hosting account varies depending on the host company you use. However, typically, it involves accessing the control panel (e.g., cPanel or Plesk) or using FTP credentials to connect to your server.

  • Go to the root directory of your WordPress site

The root directory of your website is usually the main folder where your WordPress files and directories are stored.

  • Locate the PHP.ini file within the root directory.

If it already exists, you can proceed to download a copy of it to your local computer. However, if the PHP.ini file is absent, you can create a new one using a text editor.

  • Open the PHP.ini file

Using the text editor, open the PHP.ini file to view its contents.

  • Locate the WordPress memory limit code within the PHP.ini file

Look for the line of code within the PHP.ini file that denotes the current memory limit. It will look something like this:

memory_limit = 64M

In this case, the memory limit is 64 megabytes.

  • Adjust the WordPress memory limit to your desired value

Change the value in the code line mentioned in 6 above to reflect your desired memory limit. For instance, if you wish to increase the limit from 64 megabytes to 256 megabytes, you would modify the line to read:

memory_limit = 256M

  • Save the changes to the PHP.ini file

After making the necessary changes, save the modified PHP.ini file.

  • Upload the updated PHP.ini file back to your server

Finally, upload the updated PHP.ini file into the same root directory where you initially located it.

Congratulations! You have successfully raised the PHP memory limit for your WordPress website by editing the PHP.ini file. However, it’s important to note that not all web hosts allow direct modification of the PHP.ini file. If you encounter any issues or restrictions, it’s advisable to contact your web hosting provider for further assistance.

6 Tips for Avoiding WordPress Memory Limit Issues

While increasing the WordPress memory limit is an effective measure to prevent common issues, it’s equally crucial to implement strategies that help mitigate memory limit problems altogether. Therefore, consider implementing some or all of the following tips to avoid encountering memory limit issues:

1. Use caching plugins

Employing caching plugins can significantly reduce the memory required to load your website. These plugins store frequently accessed data in a cache (temporary storage,) helping improve website speed and reducing memory usage.

2. Optimize your code

Poorly optimized code can consume excessive memory resources. Ensure that your code is clean, efficient, and well-structured. Implement best coding practices and eliminate unnecessary or redundant code to minimize memory usage.

3. Limit the number of plugins

Installing numerous plugins and addons on your website can strain memory resources. To mitigate WordPress memory limit issues, evaluate and limit the number of plugins you use. Only install essential plugins that serve a specific purpose and regularly review and remove any plugins that are no longer necessary, or replace several plugins with a single, multifunction one.

4. Use a CDN (content delivery network)

Implementing a CDN can alleviate the load on your host server, thereby reducing memory usage. A CDN caches your website’s content on multiple servers distributed across different locations worldwide. This results in decreased demand on your server’s memory, with the added advantage of improved page loading times.

For more information on CDNs, please check out the article “WordPress CDN Services: Improve Your Site’s Speed” on the WP Bolt Blog.

5. Use quality web hosting

Behind every successful website is high-quality web hosting. That is why WP Bolt offers VPS hosting packages with features that can help avoid memory limit issues in WordPress websites.

For example, WP Bolt provides ample server resources, including RAM, CPU, and disk space, which can handle high-traffic and resource-intensive WordPress sites that inherently require more memory.

Additionally, WP Bolt’s VPS hosting packages offer advanced caching solutions that can help reduce the load on the server and increase website performance. They also provide expert support from experienced WordPress developers able to assist with optimizing your WordPress installation and troubleshooting any issues you may encounter.

By choosing WP Bolt’s VPS hosting packages, WordPress website owners can ensure that their site always has enough memory to operate efficiently and avoid memory limit issues that can impact website performance.

6. If all else fails, seek expert help

If memory limit issues persist despite implementing the abovementioned measures, it may be prudent to consult WordPress experts to help pinpoint the cause of the problem and offer tailored solutions based on your specific requirements. Moreover, their knowledge and expertise can help optimize your website’s memory usage and address any underlying issues effectively. Mercifully, sensibly priced WordPress experts can be found on platforms like Fiverr or UpWork.

By following these five tips, you can proactively mitigate memory limit issues and ensure smooth operation and optimal performance for your WordPress website.

Conclusion

Running out of memory on your WordPress website can be frustrating, causing issues such as slow page load times, error messages, and site downtime. However, it’s a common issue that is easy to fix using the methods outlined in this article.

Moreover, it is also good practice to take active steps to reduce the likelihood of memory limit issues occurring in WordPress, such as using caching plugins, a CDN, optimizing your code, and reducing the number of plugins.

In the unlikely event that you continue to encounter WordPress memory limit issues, consider moving your site to WP Bolt and we’ll work with you to ensure that you don’t face this issue.

Want to speed up your web site?

WP Bolt makes it easy and affordable to have a High Performance WordPress VPS server.

View Pricing & Sign Up Now