Fatal error: Allowed memory size of 33554432 bytes exhausted

How to fix the dreaded PHP memory limit on WordPress

A problem you will no doubt come across when using WordPress is the annoying PHP memory limit error.

It is not serious but is very common and there is no way of knowing when it will happen.

WordPress by default is allocated 40MB (64MB for multisite installs) and depending on your server settings you may see the following message if you attempt to install plugins or themes that require more than 40MB memory to run.

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

If you have a very active website the quickest way to fix this is to quickly remove the plugin(s) or theme that has caused the problem via FTP, CPanel or whatever file management tool you use.

You can then proceed to increase the memory limit on your installation by opening your WordPress configuration file wp-config.php and insert the following line:

 define('WP_MEMORY_LIMIT', '64M');

If you require more than 64M you can try using 96M or 120M.

Other ways of increasing the WordPress memory limit include:

htaccess

You can also change the memory limit of PHP from your sites htaccess file. Go to the root folder of your website (usually public_html) and create a new .htaccess file if it doesn’t already exist and add the following line:

php_value memory_limit 64M

PHP.ini

Some web hosts may not give you access to modify the PHP.ini file for your website. But if you do have access, open the file and search for the property memory_limit and change the value to something greater like 64M.

memory_limit = 64M

If you still get the error after this fix, then it will be a good idea for you to contact your web host as they could have restrictions in place which do not allow you to modify memory limits.