How do i fix fatal error allowed memory size in wordpress?

Are you seeing an allowed memory size exhausted error in WordPress? This is one of the most common WordPress errors, and you can easily fix it by increasing the php memory limit in WordPress. In this article, we will show you how to fix WordPress memory exhausted error by increasing PHP memory.

How do i fix fatal error allowed memory size in wordpress?

What is WordPress Memory Exhausted Error?

WordPress is written in PHP, which is a server-side programming language. Every website needs a WordPress hosting server for it to function properly.

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 size to different applications including PHP.

When your WordPress code requires more memory than the default allocated memory, you get to see this error.

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

How do i fix fatal error allowed memory size in wordpress?

By default, WordPress automatically tries to increase PHP memory limit if it is less than 64MB. However, 64MB is often not high enough.

Having said that, let’s see how to easily increase PHP memory limit in WordPress to avoid memory exhausted error.

Increase PHP Memory Limit in WordPress

First you need to edit the wp-config.php file on your WordPress site. It is located in your WordPress site’s root folder, and you will need to use an FTP client or file manager in your web hosting control panel.

Next, you need to paste this code in wp-config.php file just before the line that says ‘That’s all, stop editing! Happy blogging.’

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

This code tells WordPress to increase the PHP memory limit to 256MB.

Once you are done, you need to save your changes and upload your wp-config.php file back to your server.

You can now visit your WordPress site and memory exhausted error should disappear now.

If you are new to WordPress, then take a look at our beginners guide on how to copy and paste code from the web.

We also have a step by step guide on how to find and edit wp-config.php file.

Note: If this solution does not work for you, then this means your web hosting service provider does not allow WordPress to increase PHP memory limit. You will need to ask your web hosting provider to increase your PHP memory limit manually.

That’s all we hope this article helped you solve WordPress memory exhausted error by increasing PHP memory limit. You may also want to see our step-by-step beginner’s guide to troubleshooting WordPress errors.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

How do i fix fatal error allowed memory size in wordpress?

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. We have been creating WordPress tutorials since 2009, and WPBeginner has become the largest free WordPress resource site in the industry.

Reader Interactions

This article we will cover one of the most common WordPress errors: “Fatal error: Allowed memory size exhausted”. What causes it and the different ways to resolve it.

Analyzing the Error

By default, a new WordPress install will have an allocation of 64M, but this is not always enough.

In most cases, once you install a new theme or plugin that requires a higher server memory limit, of which is not allocated within your WordPress environment, then you are likely to encounter this error within your browser, once you try accessing your website.

A sample format of the error would be rendered as:

Fatal error: Allowed memory size of 33455443 bytes exhausted (tried to allocate 2211214 bytes) in C:\wamp64\www\wp-includes\functions.php on line 5231

Note that you will only be in a position to have a view of the error if you have enabled debugging within your WordPress environment. Otherwise, a “White Screen” would be rendered. Enabling debugging within your WordPress environment can be accomplished from the wp-config.php file.

You can access the wp-config.php file within the root of your WordPress install. As per the sample error above, of which is within a local install, the file will be within the directory path C:\wamp64\www\

If your website is already uploaded, you can access the file using an FTP client software such as Filezilla or WinSCP. Connecting to your website via FTP requires a specific set of credentials. You can consult your host on the required FTP login details if you are not in a position to trace these on your end.

As an alternative, you can also access the file via the control panel provided by your web hosting and navigate to the /public_html/ folder where you will find the file in place.

Once you are in a position to replicate the error, then you can proceed to determine a way on how to go about fixing the error.

Fixing the Error

There are a couple of ways on how to go about resolving this error. These include:

  • Editing the wp-config.php file
  • Editing the php.ini file
  • Editing the .htaccess file

In these three methods, the first step would be in analyzing the amount of additional memory required. This would be different across different installs.

Let’s cover each of these methods:

1. Editing the wp-config.php file

Here you will need to edit the wp-config.php file. Prior to this, I would recommend creating a backup of this file by downloading it your local computer or else saving it to your desktop if your website is within a local install. This would serve as a safety precaution in case you would wish to restore to an earlier state.

With this accomplished, you can then add the code below just prior to the line that says “That’s all, stop editing! Happy blogging”

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

The M means megabytes. A 256M memory allocation would be appropriate for most installs. You can, however, have the value raised higher to 512M, depending on the extra memory allocated needed.

Once this is done, save your changes and try accessing your website URL to see if the error is resolved. If so, you should have a view of your site content or else the accessed URL content.

In some instances, this method may not work. This happens in instances whereby you are on a shared hosting and the hosting provider does not allow such a change. In such a situation you may need to consult your hosting provider on this issue.

2. Editing the php.ini file

The php.ini file is a configuration file that is read once a PHP script is executed or else when PHP starts.

You can use this file to control resource limits such as the required memory in our case here.

On a live install, the file can be accessed within the root of your install, that is within the /public_html/ folder. Note that the file is not installed by WordPress but in most cases set up by your host. If you are using CPanel as your control panel, for example, make sure the checkbox for “Show Hidden Files” is checked and then click Go. You may check into this article on how to go about editing the file.

Before editing the file, kindly preserve a backup to it by downloading it to your computer.

Once this is done, open the file, add or edit the following line:

memory_limit 512M

After, press save and close.

As for local installs, the location of the file will depend on the Local server in use. In our sample here using WAMP, you will need to:

  • Start WAMP server and wait for the WAMP icon in the taskbar to turn green.
  • Left click on the icon.
  • Select PHP > php settings > memory limit.
  • Change the value to 256.

This will by default change the setting in php.ini.

3. Editing the .htaccess file

The .htaccess file is a file located within the root of your WordPress files.

Again we would advise you to carry out a backup of this file.

If the alteration to the php.ini file did not work, you can choose to edit this file.

You will need to add or edit the following code to the bottom of the file:

php_value memory_limit 256M

With this done, you can then save your changes and check if the error is resolved.

Conclusion

In any case, the methods above do not work out for you, or else you would not wish to carry out these changes yourself, I would recommend on consulting your hosting provider on this so that they can have the limit increased from their end.

How do I fix my WordPress memory limit?

How to increase WordPress memory limit.
Edit wp-config. php and increase wp_memory_limit. ... .
Change your server settings via PHP. ini. ... .
Edit your . htaccess file. ... .
Upgrade your website's hosting plan. While you can often increase the memory that's available to your site, you're ultimately restricted by your hosting plan..

How do I fix fatal error allowed memory size?

To fix the error, you have to manually increase the default PHP memory limit set for your server.

How do I increase memory size in WordPress?

Here's what you need to do:.
Locate or find your php. ini file. ... .
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 localhost or server after saving your changes..

What is the default memory limit for WordPress?

So, by default the limit is set to 40MB (and 64MB when it comes to multisite). This limit is coded in a file: default-constants.