WordPress Memory Limit – How to Fix or Increase the PHP Memory Limit

The WordPress memory limit is the maximum amount of memory (RAM) that your site can use at one time. If your site exceeds this limit, you may experience slow loading times, error messages, or even a white screen of death.

Fortunately, it’s easy to increase the WordPress memory limit. All you need to do is edit your wp-config.php file and add the following line of code:

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

This will increase the memory limit to 256MB. You can also increase the limit to 512MB or even higher if needed.

If you’re not comfortable editing your wp-config.php file, you can also increase the memory limit by adding the following line of code to your .htaccess file:

php_value memory_limit 256M

Once you’ve added the code, save the file and upload it to your server.

If you’re still having issues with your WordPress memory limit, you may need to contact your web hosting provider and ask them to increase the limit for you.

If your WordPress website has a lot of media content or is running large scripts, you may encounter the following error message while editing it:

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

This means that your WordPress code needs more memory than the given default value. However, fixing the issue is not as complicated as it might seem, and it doesn’t require any technical experience.

Read on as this article will explain what the WordPress memory limit is, how to increase it, and why you may find one of the error messages above.

What Is the WordPress Memory Limit?

The WordPress memory limit is also known as WordPress PHP memory limit or simply PHP memory limit. It mainly sets the maximum amount of memory that a script can use on the website.

Servers store all the data and files of websites. Thus, a server must have the necessary storage capacity, processors, and RAM or memory in order to keep the site running.

The RAM capacity of a server varies depending on the hosting provider and plan used. A starter plan usually offers a low amount of RAM compared to a business or professional plan.

Every web application and function takes up some memory. The more plugins installed or media files uploaded, the more memory the site will require. If it runs out of memory, the site’s loading speed may decrease, or worse, it won’t load at all.

Hence, the WordPress memory limit is there to ensure that the website scripts don’t exceed the server’s RAM capacity.

How to Increase the WordPress Memory Limit?

By default, the memory limit is set to only 32 MB, which may not be enough for your site. However, there are several methods to increase it.

You can modify the .htaccess or wp-config.php file, set it using the hPanel PHP Configuration, or upgrade your hosting plan.

FTP

One way to edit the .htaccess or wp-config.php file is via an FTP client like FileZilla. Make sure to connect FileZilla with your site’s FTP account before continuing with one of the following tutorials:

Editing the .htaccess file

  1. Access the site’s public_html folder or root directory and find the .htaccess file.
  2. Right-click on the file and select View/Edit to be directed to the text editor.
Selecting to View/Edit the .htaccess file on FileZilla.
  1. Look for the line:

# END WordPress

Add the following code beneath it:

php_value memory_limit 256M

Editing the .htaccess file by adding the code.
  1. Save the file and close the editor.
  2. Click Yes when FileZilla asks whether to upload the modified file, then reload the site.

Modifying the wp-config.php file

  1. In the root folder, right-click on the wp-config.php file and select View/Edit.
Selecting to View/Edit the wp-config.php file on FileZilla.
  1. Find the line containing WP_MEMORY_LIMIT and change 64M to 256M.
  2. If it doesn’t exist, insert the following code above the line /* That’s all, stop editing! Happy publishing. */ or /* That’s all, stop editing! Happy blogging. */:

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

Modifying the wp-config.php file by adding the code.
  1. Save the changes and upload the file.

When visiting the site, you shouldn’t experience the “memory limit exhausted” error again.

File Manager

A more straightforward method to modify the .htaccess or wp-config.php file is via the file manager on your control panel. For this tutorial, we’ll be using hPanel:

  1. Access hPanel, navigate to the Files section, and select File Manager.
Screenshot of the File Manager on hPanel
  1. Open the public_html folder or root directory, and double click on the .htaccess or wp-config.php file.
Clicking on the .htaccess or wp-config.php files in the public_html folder.
  1. Insert the code mentioned on the FTP tutorial based on the file chosen, then press SAVE & CLOSE when done.

Though you won’t be making any significant changes using the methods above, you should back up your site before editing it. This ensures you won’t lose your WordPress site if something goes wrong.

hPanel

An alternative solution for Hostinger clients is to set the memory limit via PHP Configuration on the hPanel:

  1. Log in to hPanel, scroll down to the Advanced section, and select PHP Configuration.
Selecting PHP Configuration under the Advanced section in hPanel.
  1. Choose PHP Options and find the memory_limit field.
  2. Click on the dropdown menu and pick the highest amount.
Screenshot of the memoryLimit settings on PHP Configurations on the hPanel

If the memory limit is already at the maximum, then the last option is to upgrade your hosting plan to get more RAM.

For example, our WordPress Business and Pro plans provide more RAM compared to the Single and Starter plans.

How to Check the WordPress Memory Limit?

Once you’ve configured the memory limit, you might want to see if it worked. The following steps apply to users who are running WordPress 5.2 and above:

  1. Access the WordPress dashboard, hover on Tools, and select Site Health.
Selecting Site Health in the WordPress dashboard.
  1. Choose the Info tab and click on Server.
Choosing the info tab and clicking on Server.
  1. Scroll down through all server settings until you find the PHP memory limit.
PHP memory limit - 256M.

What Causes the “WordPress Memory Limit Exhausted” Error?

The most common cause is that the memory limit may still be set to the default value instead of the highest option. Hence, it’s important to check it before you start fixing the problem.

If that’s not the case, then you might be outgrowing the hosting resources. As your WordPress website grows, the size of its database, plus the number of scripts and files, also increases. In addition, there might be plugins or themes that need extra memory to run as well.

Hosting providers allocate only a certain amount of resources, including the RAM limit, for different types of hosting plans. When starting your WordPress journey, you might have chosen a plan with limited RAM due to affordable prices, but it might be time to upgrade it.

Other than the memory limit exhausted error, you may also encounter the following issue:

yourfile.png exceeds the maximum upload size for this site

In this case, visit our How to Increase the Maximum File Upload Size article to find solutions other than increasing the memory limit to fix that specific issue.

Conclusion

The WordPress PHP memory limit is the amount of memory available for scripts to run on your WordPress site. It ensures that the site doesn’t exceed the server’s RAM capacity given by the hosting provider.

The limit is usually set to 32 MB, which may not be enough to run a media-rich site and all its plugins. Thus, you will receive the exhausted memory error message when a script goes over the limit.

Here’s a recap on how to increase the WordPress memory limit:

  • By editing the .htaccess or wp-config.php file via an FTP or file manager.
  • Set the size limit through PHP configurations on hPanel.
  • Upgrade your hosting plan to use more resources.

Don’t be afraid to contact our customer support team if you have additional questions or if the chosen method didn’t solve the problem.

WordPress Memory Limit – How to Fix or Increase the PHP Memory Limit

WordPress is a powerful content management system that allows users to create and manage websites with ease. However, it can be difficult to manage the memory limit of WordPress, especially if you are not familiar with the technical aspects of the platform. In this article, we will discuss how to fix or increase the PHP memory limit in WordPress.

What is the WordPress Memory Limit?

The WordPress memory limit is the maximum amount of memory that can be allocated to a single process. This limit is set by the hosting provider and can be adjusted in the wp-config.php file. If the memory limit is exceeded, WordPress will display an error message and the website will not be able to function properly.

How to Fix or Increase the PHP Memory Limit in WordPress

If you are experiencing issues with your WordPress website due to a low memory limit, you can try to fix or increase the PHP memory limit in WordPress. Here are the steps to do so:

  • Login to your WordPress dashboard.
  • Go to the “Settings” tab and click on “General”.
  • Scroll down to the “Memory Limit” section and enter the desired memory limit.
  • Click “Save Changes”.

If the above steps do not work, you can try to manually increase the memory limit in the wp-config.php file. To do this, open the file in a text editor and add the following line of code:

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

Save the changes and upload the file to your server. This should increase the memory limit for your WordPress website.

Conclusion

The WordPress memory limit is an important setting that can affect the performance of your website. If you are experiencing issues due to a low memory limit, you can try to fix or increase the PHP memory limit in WordPress. We hope this article has helped you understand how to do this.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?