How to Increase WordPress Memory Limit

How-to-increase-memory-limit-in-WordPress_Wpmet

Are you getting a WordPress error that says “Allowed Memory Size Exhausted”?

This is one of the most popular WordPress errors. However, it is simple to increase the WordPress memory limit in just a few steps. 

It’s a WordPress rite of passage to deal with fatal errors. It happens to everybody at some point. 

If you have a hypermedia-heavy website, the regular WP setup will not be sufficient for you, and you will need to upgrade at some stage.

In this article, we’ll guide you on how to increase the WordPress PHP memory limit to correct memory exhaustion error in five methods:

  1. Edit wp-config memory limit file.
  2. Change the limit of PHP.ini file.
  3. Alter .htaccess file.
  4. Use the memory extend plugin.
  5. Contact the hosting provider.

So, let’s dive into all these methods one by one after exploring the basics of WordPress memory limit

How much memory does WordPress need?

The memory requirements for WordPress can vary depending on several factors such as the size and complexity of your website, the number of plugins and themes you use, and the amount of traffic your site receives. Therefore it is not that simple to answer how much memory WordPress needs.

WordPress itself has a minimum memory requirement of 64MB, but this is typically not enough for most websites. A recommended minimum is around 128MB, although many hosting providers recommend allocating 256MB or more for optimal performance.

If you have a small website with basic functionality and a low level of traffic, 256MB of memory should be sufficient. However, as your website grows and you add more plugins, themes, and traffic increases, you may need to allocate more memory.

It’s worth noting that memory requirements can also vary depending on the hosting environment. Shared hosting plans may have stricter memory limitations compared to dedicated or cloud hosting solutions.

To determine the exact memory requirements for your WordPress website, you can monitor your site’s memory usage using tools provided by your hosting provider or WordPress plugins. Those tools can help you identify if your site is running out of memory and if additional resources need to be allocated.

It’s always recommended to consult with your hosting provider or system administrator to determine the optimal memory allocation for your specific WordPress installation, as they can provide guidance based on your website’s requirements and the hosting environment.

What is a WordPress Memory Exhausted Error?

PHP is a server-side programming language, and WordPress is written in it. For PHP to work properly, every website needs a WordPress hosting provider.

Web servers operate in the same way as any other device. They need memory to run several applications effectively at the same time. Different programs in WP are allotted different amounts of memory limit by server administrators.

When WordPress runs, it needs a certain amount of memory (RAM) to handle various tasks, such as processing themes, and plugins, and executing PHP scripts. By default, WordPress sets a limit on the amount of memory it can use. If your website surpasses this limit, you’ll encounter the “Memory Exhausted Error”.

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 2348617 bytes) in /home4/xxx/public_html/wp-includes/plugin.php on line xxx

Or

Fatal error: Allowed memory size of 41943040 bytes exhausted fatal error allowed memory size WordPress

This error message appears when your WordPress code needs more memory limit than the default allocated memory limitation.

What is “Allowed memory size of bytes exhausted” in WordPress

The error message “Allowed memory size of bytes exhausted” in WordPress indicates that your WordPress site has exceeded the memory limit allocated to it. Each WordPress site has a predefined memory limit that restricts the amount of memory PHP can use while running scripts.

When a script, such as a plugin or a theme, tries to allocate more memory than the allowed limit, this error occurs. The error message usually includes the specific memory size that has been exhausted.

For example, the error message might look like this:

 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate  123456 bytes) in /path/to/wordpress/wp-includes/some-file.php on line 123

What is the WordPress PHP memory limit?

PHP is the server-side programming language that creates the website’s HTML pages. 

PHP is a versatile, dynamic programming language that can process WordPress interrogations, perform calculations, and more, but it requires memory to do so.

WordPress’s default memory limit is 32MB, but it’s normal if you’re in need to raise it. For example, WooCommerce recommends a WordPress memory limit of 64MB.

How to Increase WordPress PHP Memory Limit that is set to 40MB
WordPress Minimum Memory

As WordPress hits the default memory limit, it will try to raise it to 40MB for single-site installations and 64MB for multisite installations. If that isn’t enough, a fatal error message line will appear.

Unless you installed a plugin that requires more memory, a memory limit of 128MB should suffice for most pages. Install the Server IP & Memory Use Display plugin to see how much memory each plugin consumes.

You can deactivate plugins to see how they affect memory use after you activate the Server IP and Memory Usage Display plugin. To avoid overloading your server, high-quality, all-in-one plugins can make efficient use of memory.

Why does WordPress demand more memory limit, to start with?

To increase the memory limit one needs to increase the maximum upload size in the WordPress wp-config.php memory limit file. 

However, there’s an issue you should be cautious about. Increasing the memory limit will make WordPress inefficiencies harder to identify.

Before you increase the WordPress Memory Limit, I recommend that you first try to figure out what is consuming more memory. More resources thrown at a problem can sometimes end up costing much more in the long term, particularly if you have plans to upgrade the host.

Inefficiencies in WordPress can lead to a sluggish site and a bad user experience. But to get the solution you need to identify the root of the problem, which can help you solve a variety of problems down the road.

Just 4.4% of WordPress websites use the most recent version of PHP, and 64% uses the older version that no longer receives active updates.

Upgrading your hosting server’s PHP to the most recent version would make WordPress more effective and eliminate the need to raise the memory capacity in WordPress.

What is the Maximum Upload Limit in WordPress? 

The maximum upload limit in WordPress refers to the largest file size that WordPress can accept for uploads. The maximum upload capacity in WordPress can be found on the media library upload screen

Although this is beneficial to your host, it also improves the efficiency of your site. Large image file uploads, for example, perform poorly on your web because they take a long time to download and present.

🤷‍♀️ Do keep in mind:
Before you spend more money on the issue and raise the WP memory limit, see if there’s anything you can do to diminish the file size first, just as you did with the memory limit.

If your images are a little too big for their container or you haven’t compressed them, you can fix those issues first because they address the root of the problem, which is not properly enhancing your assets. For more details, see our guide on how you can speed up your website.

How to Increase PHP Memory Limit and Maximum Upload Limit in WordPress:

How to Increase PHP WordPress Memory Limit

There are five options you can use to resolve WordPress Memory Exhausted Errors and raise the memory capacity and uploading limit in WordPress.

🚨 Always keep a new backup of your site files and database before making any significant changes so that you can recover your site if you make a mistake.


Now let’s get started with the guide on how to increase the PHP memory limit in WordPress! 😃

Edit your wp-config.php WordPress memory limit file

Since it contains your basic configuration information, wp-config.php memory is one of the essential files for a WordPress website. This WP config memory limit file is in the root directory of your WordPress file system.

Edit wp-config.php memory limit file to increase WordPress memory allocated to PHP file
wp-config.php file

Look for this line to edit the memory and upload limits on the wp-config.php memory limit file:

WordPress Minimum Memory:

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

Change the value to a higher limit, such as ‘128M’ or ‘256M’. Save the WP config memory limit file and check if the error is resolved. Note that some hosting providers may limit the maximum memory you can allocate, so you might not be able to set it to an arbitrarily high value.

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

You’re good to go with this wp config.php memory limit increase method. However, If you’re still having a fatal error, you might need to increase it again. But don’t go too far or your server will crash. Or you can seek assistance from your host.

Edit your PHP.ini file to increase WP memory limit

If changing the wp-config.php file doesn’t solve the problem, you’ll have to deal with the problem in your server settings. WordPress PHP memory limit increase method may work here.

You won’t be able to access your PHP.ini file if you’re using shared hosting. If you do have access to PHP.ini. It’s most likely in the root folder, but the file’s location varies by the host. 

Here’s what you need to do:

  • Locate or find your php.ini file. If you can’t find it, simply build your php.ini file and save it in the WordPress installation’s root directory.
  • Use your favorite editor to open and edit your php.ini file.
  • Look for the line that says ‘memory limit = 32M’.
  • Change the 32M or some other number to the desired limit (e.g. 256M or 512M).
  • Restart your local host or server after saving your changes.

Note: If you’ve made your own php.ini file, you’ll need to add the following line to it:

memory_limit = 256M (or 512M)

In certain instances, as you progress down the list from line one to line three, the values you add can grow larger. The ‘memory limit’ should be the biggest, while the ‘upload max filesize’ should be the lowest. And the post max size’ should be the median.

Clear your browser’s cookies before checking if the error has disappeared.

Edit your .htaccess file

If you don’t have access to PHP.ini, you’ll have to edit your .htaccess file as a last resort. Since it is a secret file, the .htaccess file begins with a mark. Check to see if your SFTP file manager is keeping some files hidden from view if you don’t see them in your root folder.

Here are the details you need to add to your .htaccess file to increase the WordPress memory limit:

php_value memory_limit 256M


php_value upload_max_filesize 12M


php_value post_max_size 13M

Increase the PHP memory capacity if it hasn’t already been set. You can use the following code to increase the PHP WordPress memory limit:

ini_set('memory_limit', '512M');
However, it only works for the file where it is written.

Use the memory extend plugin

Other than editing wp-config.php, PHP.ini, and .htaccess files, you can extend the limit by utilizing the WP memory increase plugin. There are numerous memory extend plugins such as WPMemory, WP Tools, etc. These plugins let you increase limits without touching your memory limit files. It is a friendly process for beginners and non-coders. So, try to optimize the memory limit by adopting a memory extend plugin if you want to avoid coding hassle.

Through hosting provider

Contacting your hosting provider to increase your memory limit is the easiest among all methods. Most of the popular hosting providers include this service. However, their services may vary depending on the type of package you’re using. Also, some might not include this option. In this case, you need to adopt any one of the four methods mentioned above to enhance the memory capacity of your WordPress site.

For more detailed information please check out our video on Fatal Error Solution below:

How do you check WordPress memory limit?

You can check the WP memory limit from wp-config.php file. In this file, you will find a line similar ( ‘WP_MEMORY_LIMIT’ , ‘128MB’ ). This means your WordPress memory limit is 128MB that you can further change by editing your PHP or other files.

What is the difference between WP_memory_limit and WP_max_memory_limit?

WP_memory_limit indicates to the frontend memory limit. On the other hand, WP_max_memory_limit refers to the PHP memory limit that is allocated for backend development.

What means by Memory_limit= -1 in PHP?

Memory_limit= -1 is set to avoid using all memory by poorly written PHP script. It means PHP script is not allowed to use excessive server resources and lead to performance issues.

Wrapping Up

It can be nerve-wracking to configure the server and deal with fatal errors of increasing the memory limit in the WordPress website. The procedure you must follow is highly dependent on the hosting company you choose, which is why getting a reliable host is so critical. They will assist you in locating and modifying the settings that need to be changed to increase the PHP WordPress memory limit.

However, increasing the wp memory limit for your website through the wp-config memory limit file is the easiest method you can count on, the other two can be a little down the line. 

Finally, hope you liked the article. If yes! Then please leave a comment down below as well as join our Wpmet Community on Facebook for more exciting updates.


Comments

  1. hirendra Avatar

    What is the Maximum Upload Limit in WordPress?

    1. Sanjida Avatar
      Sanjida

      Hi Hirendra,

      Hope you’re doing well.
      Well, the Maximum Upload Limit of WordPress is 2MB to infinity.

      This limit might be enough for small websites with a limited number of plugins and visitors.

      Thank you so much 💖

  2. Gayathri Reprographics Avatar
    Gayathri Reprographics

    Thanks

  3. Can't edit theme in WordPress? Here are 14 possible solutions!

    […] Read this resourceful blog post from Wpmet to learn how to increase your WordPress memory limit. […]

  4. Eileen Valdez Avatar
    Eileen Valdez

    Hi,
    Thanks for sharing nice post on how to increase wp memory limit.

    Thanks

  5. Mohit Bhargav Avatar
    Mohit Bhargav

    Hello

    I have set the limit to 256m via wp-config file.. Hope is ok?

    BTW, thanks for this valuable information.

    1. Sanjida Avatar
      Sanjida

      Anytime, Mohit!
      Happy holidays… 😄

      Wpmet team.

  6. […] Learn how to increase your WordPress memory limit from this resourceful blog post from Wpmet. […]

  7. Creativizt Avatar
    Creativizt

    This is sure gonna help us fix issues on our wordpress blogs. Thanks for sharing!

Leave a Reply

Your email address will not be published. Required fields are marked *