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.
- Every website is allocated a specific amount of memory to run the scripts.
- Usually this memory can be in range of 64MB to 512 MB depending upon the hosting type.
- Every php script runs on your website consumes some part of this memory.
- 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.
- Sometimes when you install too many plugins, the memory usage goes out of limit and your website start showing Memory Exhausted Error.
- 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 :
- Go to the root directory of your server.
- Search for php.ini file.
- Open this php.ini file in edit mode.
- Search for : memory_limit = 64MB
- This value 64MB is a imaginary value we used here. It can be anything on your real file.
- Change this value according to your requirement.
- 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 :
- Go to cpanel and open file manager.
- Open the public_html folder or the directory where you installed WordPress.
- Find and open the file wp-config.php.
- 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.
- Save this file and try your website again.