How to Fix Memory Exhausted Error in WordPress Website

How to Fix Memory Exhausted Error in WordPress Website

If you are looking at something like given below, you are facing the Memory exhausted error

Fatal error: Allowed memory size of 12345678 bytes exhausted (tried to allocate 2345678 bytes) in /home/your-username/public_html/wp-includes/plugin.php on line 1000

Lets first discuss what this Memory Exhausted Error is about.

  1. Every website is allocated a specific amount of memory to run the scripts.
  2. Usually this memory can be in range of 64MB to 512 MB depending  upon the hosting type.
  3. Every php script runs on your website consumes some part of this memory.
  4. If we talk about WordPress, every plugin takes up a particular amount of memory . Here is one plugin which can help you estimate the amount of memory used by a plugin.
  5. Sometimes when you install too many plugins, the memory usage goes out of limit and your website start showing  Memory Exhausted Error.
  6. This error can also cause if some spammer or bot is using one of your script much.

How to fix Memory Exhausted Error –

This error can be resolved in 2 ways depending upon the level of access you have on your WordPress website’s server.

Method 1 (to resolve Memory Exhausted Error via php.ini file)–

If you have the root access to your hosting which will be the case if you have a VPS ( Virtual Private Server) or Dedicated Hosting. Follow the following steps :

  1. Go to the root directory of your server.
  2. Search for php.ini file.
  3. Open this php.ini file in edit mode.
  4. Search for  : memory_limit = 64MB
  5. This value 64MB is a imaginary value we used here. It can be anything on your real file.
  6. Change this value according to your requirement.
  7. Now recheck, the problem would be solved now.

Method 2 (to resolve Memory Exhausted Error via wp-config.php file) –

If you are using a shared hosting, you will not have access to the php.ini file.  In such situation, we have to go for an alternate route. Follow the following steps :

  1. Go to cpanel and open file manager.
  2. Open the public_html folder or the directory where you installed WordPress.
  3. Find and open the file wp-config.php.
  4. Paste the following code just before the line -That’s all, stop editing! Happy blogging.
    define( ‘WP_MEMORY_LIMIT’, ‘512M’ );
    It tells the WordPress to increase the php memory limit to 512 MB.
  5.  Save this file and try your website again.

If you like above article, please subscribe. We will keep you updated with our new Articles.

Leave your Feedback / Questions in Comments.

Leave a Reply

one × four =

Close Menu