Fatal Error: “Allowed Memory Size Exhausted” (Fixed)

Memory size Exhausted Error

You must have faced an “allowed memory size exhausted” fatal error in WordPress and you don’t know how to resolve this error?

Don’t worry! This is a normal error in WordPress. You can fix it yourself. To resolve this error simply increase the memory limit for WordPress. You can do it in wp-config and .htaccess file.

In this article, I’ll show you how to fix this error in WordPress.

What is Memory Size Exhausted Error in WordPress?

The default memory size in wordpress is 64M which is not sufficient to run multiple files at the same time. In order to resolve this error we need to increase the memory.

WordPress is a server side programming language. It means it executes on the server. WordPress needs enough memory to execute the files written in PHP, It requires more memory size to execute the files if multiple files are running at the same time.

How this error look like: 

Fatal error: Allowed memory size of 35795260 bytes exhausted (tried to allocate 1341258 bytes) in C:\xampp\htdocs\wordpress\wp-includes\functions.php on line 3685

How to Fix the error?

In WordPress, you can fix this error using the following three ways.

  • Using wp-config.php file
  • Using .htaccess file
  • And using php.ini file

  1. Using wp-config.php file

There is a configuration file called wp-config.php file. It contains all the sensitive information of your WordPress. When you install WordPress, this file is automatically created. It stores database information. Your website will not work without this file.

To fix this error we need to write a line of code in the wp-config.php file. I recommend you take a backup of this file before making any changes to it. 

Now, add the following one line code in your wp-config.php file.

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

The above code will increase the memory limit to 256M. Here M denotes megabyte. 256 Megabyte is enough to run any file.  If you need more memory you can increase it further according to your requirement, replace 256M with 512M in the code.

  1. Using .htaccess file

The other high configuration file is the .htaccess file, you can  change the configuration of your website through this file.

This (.htaccess) file is present in WordPress root directory. This file is hidden sometimes, you can make it visible in the settings tab in the cpanel file manager.

Add the following code in the .htaccess file at the bottom of the line.

php_value memory_limit 256M

Save the file and check your website. This error will be resolved now.

  1. Using php.ini file

You can fix the error by increasing the memory size in the php.ini file also. This is also a configuration file, which reads once a PHP script is executed.

If you work on a local host, then to edit this file use the path xampp/php/php.ini and wamp/php/php.ini.

If you have cpanel hosting, then you can find this file in the cpanel main section. 

Search for php configuration and you will find it. If not found, contact your hosting provider and they will help you with that.

Once you find the file, then search for “memory limit” and change its value. 

memory_limit 512M

Save the file and restart your apache server. Check your file, the error will be resolved.

Conclusion:

So, these were the three ways through which you can resolve this error. Try and find which works well for you. In case the above method does not work for you, or you do not want to use these methods, so you can contact your hosting provider so they can increase your memory limit.

Author Info

admin

admin

Share This Post...
Table of Contents

Add a Comment

Share This Post...