Are you trying to deal with WordPress memory exhausted error? While dealing with your WordPress website you really don’t know that there is a hardware which is actually running your WordPress CMS on PHP. The hardware is actually the server you are using no matter how great and expensive web hosting you are using these type of errors Memory exhausted WordPress can occur. This can happen cause of several reasons for example if you start a specific instance like thumbnails regeneration and your server does not get time to breath again. Then you can fall into such issues like memory exhausted or server response time error.
However WordPress gives you option to increase the allocated memory size. But before changing the allocation of memory ask yourself a question. The task you are trying to perform is very important for your website? If not then don’t do anything just ignore the error and wait until your website start running again.
Do you want to know how to increase maximum upload size in WordPress.
What is memory exhausted error and how you get it?
When you are running your website on shared hosting then the resources you can use are limited. Please note the issues can even happen with high performance dedicated servers also. For example if you are using a specific plugin of script which leaks the memory or consume un required memory then such problems can also occur. See below the memory exhausted fatal error you receive.
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
By default your WordPress use the memory which your hosting allows to PHP. If you want to know the memory size your php offers just run PHP function phpinfo(); which can give you details. However WordPress try to increase the memory size to avoid the FATAL error but WordPress also have limit 64MB to go beyond just to avoid server crash WordPress have this limit.
Increase PHP Memory Limit in WordPress
There are several ways to increase your PHP memory limit. You can adopt any which is most convenient for you. And if one method does not work you can try the other method. Please note these methods depends on the permissions of your server to work.
- Connect your FTP client so you can download wp-config.php or .htaccess or php.ini
- How to increase memory by wp-config.php
- Increase PHP memory by .htaccess
- To increase memory via php.ini
1) Connect your FTP client so you can download wp-config.php or .htaccess or php.ini
Now you can open the best FTP client you are comfortable with in our case we use Filezilla. To connect your FTP you need FTP username, FTP password, FTP host and FTP port. If you don’t have this information please contact your hosting provider they can provide you. Once you are connected and you can see server directory now you are ready to follow next step. Make sure you can edit wp-config.php and .htaccess when required in next steps and upload updated versions.
2) Increase PHP memory via wp-config.php
Please download wp-config.php and add the following line just between <?php /** and then upload to your server. I hope this solve the issue for you. This method works only for WordPress as define(‘WP_MEMORY_LIMIT’ constant is related to WordPress only.
//Code to Insert
define( 'WP_MEMORY_LIMIT', '256M' );
//Insert view.
<?php
define( 'WP_MEMORY_LIMIT', '256M' );
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
* * MySQL settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://codex.wordpress.org/Editing_wp-config.php
*
* @package WordPress
*/
2) Increase PHP memory by .htaccess
The other method is if in any case you could not access your wp-config.php or that did not work for you. Edit your .htaccess file and insert the following code.
php_value memory_limit 128M
3) To increase memory via php.ini
If luckily you have access to your php.ini then you can edit the settings for php which resources can be used. Insert the following line of code in your php.ini which will solve maximum memory exhausted issue. Again if there is some memory leak in your plugins, themes or WordPress get that fixed rather than running your server on its maximum.
memory_limit = 128M ; Maximum amount of memory a script may consume (128MB)
Nothing worked?
If nothing worked and you continue receiving memory exhausted error then please contact your host. Because your host does not allow WordPress, php.ini and .htaccess to modify the settings they want you to use on their server.
Any further questions can be posted below in comments. This post is extension of our The site is experiencing technical difficulties.