One of the more common errors that seems to crop up with WordPress installation is a Fatal Memory error something along the lines of the following :
Fatal error: Allowed memory size of XX bytes exhausted (tried to allocate XX bytes) in /directory/filename.php on line XX
This error may occur for various elements on the dashboard, or when trying to upgrade WordPress.
The error indicates that there is a restriction on the amount of memory the system can allocate to perform a particular task, and there is not currently enough memory available. The problem sometimes starts to show up after a new plugin has been installed.
To resolve this issue you need to try and either reduce the memory requirements of your WP implementation, or increase the available memory.
Decrease WordPress memory requirements
If the error only shows up when trying to upgrade WP, you may be able to temporarily deactivate all plugins, undertake the upgrade, and then reactivate them. However, if the error is impacting on the functionality of your installation, then try and deactivate any unnecessary plugins.
If this works, and the error is resolved, be aware, that the problems may very well recur if you install more plugins.
Increase System Memory
Depending on your hosting environment, you may be able to allocate additional memory via the following steps. However, there will be a limit on how much memory is available to you, so there is a chance that these “fixes” will have no impact. If this is the case, you should contact your host provider and see if they are able to allocate more memory for you (this may involve upgrading your hosting, and / or paying extra)
To try and increase memory allocation, use the following following processes :
(note their are various methods to do this – depending on what version of WordPress you are running, so some of these suggested methods may not apply to you)
1. php.ini
Create or edit a local php.ini file in the wp-admin directory (and also, possibly the directory where the error is occuring and insert the following:
[PHP]
max_execution_time = 30 ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
memory_limit = 84M ; Maximum amount of memory a script may consume (64MB)
upload_max_filesize = 20M ; Sets a file Upload limit to 8Mb
; safe mode
;
safe_mode = Off
2. Cache.php
open the file wp-includes/cache.php and place the following code immediately after the opening <?php tag:
ini_set(‘memory_limit’,’64M’); // set memory to prevent fatal errors
3. .htaccess
Create a .htaccess file in the wp-includes directory and insert the following directive:
# set memory limit for cache.php
php_value memory_limit 64M
4. wp-settings.php
open the file wp-settings.php (in the root directory) and increase the :
define(‘WP_MEMORY_LIMIT’, ’64M’);
entry. Save the file and refresh.
5. default-constants.php
open the file wp-includes/default-constants.php and increase the :
define(‘WP_MEMORY_LIMIT’, ’64M’);
entry (note there may be different setting for Multisite configurations)
Save the file and refresh.
6. wp-config.php
In your WP installation root folder, find the file named: wp-config.php
Open the file to be edited in your favorite editor
after the lines :
/** Database Charset to use in creating database tables. */
define(‘DB_CHARSET’, ‘utf8’);/** The Database Collate type. Don’t change this if in doubt. */
define(‘DB_COLLATE’, ”);
Add this code to your wp-config.php file
define(‘WP_MEMORY_LIMIT’, ’64M’);
Save the file and refresh your wordpress page and it should not give the error again.
And that’s it. Save, upload, test and check for additional errors. If necessary, you may wish to try alternate values for the memory limit (e.g. 32, 64, 128, 256) – although be aware that there will be a physical limit imposed by your hosting environment, so any values greater than that will have no benefit.
What if Nothing works !!!
Your host may not allow the Memory Limit increase, or they may have a setting which overwrites (or limits) the changes you made. If nothing seems to work, contact your host provider and find out if they allow you to increase that limit and which method ought to be used.