fatal error: allowed memory size of bytes exhausted wordpress

Are you stuck with a Fatal Error Allowed Memory Size Exhausted in WordPress and you don’t know what to do next and how to resolve this error?

Don’t worry!

This is a normal common error in WordPress and you can fix it yourself. You just have to increase the memory limit for WordPress and you can easily do this in the wp-config.php and .htaccess file.

So, in this tutorial, I’ll show you how you can fix the allowed memory size exhausted error in WordPress.

Let’s get started!

Fatal Error

Also Read

Redirected too many times Fix 100% working

Free of cost Paid Course For Free

What is Memory Size Exhausted Error in WordPress?

When you install WordPress then its allowed default memory size is 64M but it’s not sufficient to run multiple files at the same time. So, we need to increase this memory.

WordPress is a server-side programming language and its execute on servers. So, when the server executes the WordPress files (written in PHP) and they need enough memory to execute the files. When it runs multiple files at the same time then it required more memory size to execute the files.

A sample format of memory size exhausted error in WordPress:

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

Fix the Memory Size Exhausted Error

There are three ways to fix this error in WordPress. Check the following ways to resolve this error.

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

Let’s fix the error with these above ways one by one.

Using wp-config.php file

The wp-config.php file is a configuration file and it holds the all sensitive information of your WordPress. This file will automatically be created when you process the WordPress installation and it stores the database information and other keys, constant and etc. Without this file, your site will not work.

So, to fix the memory size allowed error in WordPress, you have to write one line in this wp-config.php file. Before making any changes to this file I would recommend you take a backup of this file.

OK! So add the following one-line code just before it says “That’s all, stop editing! Happy blogging.”define( ‘WP_MEMORY_LIMIT’, ‘256M’ );

The above line of code tells to WordPress increase the memory limit to 256M. Here M is a megabyte and I think 256 megabytes is enough to run any file at the same time.

If you want to increase more then you can as per your requirements. Just write there like 256M, 512MB, etc.

Using .htaccess file

The .htaccess file is also a high-level configuration file. It is only on the Apache server and it allows you to change the configuration of your website through this file.

You can manipulate your website link, how it serves from the root directory. You can make pretty permalink with this file and much more stuff like redirection, cache enables, and increase the memory limit.

You can see this file (.htaccess) in your WordPress root directory. Sometimes it is hidden, you have to show this file from the settings tab in your cPanel file manager.

So open this file and add the following code at the bottom of the file.php_value memory_limit 256M

Save the file and check your webpage that was showing the memory size exhausted error and you will see the error is gone and the page is working.

Using php.ini file

You can also fix this error by increasing the memory limit in the php.ini file. This file is also a configuration file and you can increase the size in this file.

If you are working on localhost (xampp or wamp) then you can edit this file by this path xampp/php/php.ini and wamp/php/php.ini

If you are on cPanel hosting then you can find this file in your main cPanel section. Simply search php configuration and you will see it. If you did not found then contact your hosting provider they will help you with that.

OK! if you found this file then search the “memory_limit” and change the value of it.memory_limit 512M

After saving the file, restart your apache server and check your file and you will see the error not showing now.

So, That’s it!!!

Hopefully, your error “allowed memory Size exhausted” is fixed in wordpress.

If you have any doubt please ask me in the comment section, I’ll help you with that.

By admin

Leave a Reply

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