WordPress memory limit exhausted? If you have received a WordPress error message that looks something like this ‘allowed memory size of 33554432 bytes exhausted‘, then you need to increase your Php allowed memory limit.
There’s different reasons you may have exhausted the allowed php memory limit which may be caused by running to many php scripts, too many search engine bots scanning your site or a poorly optimized site.
A common reason is too many plugins which use too many php resources and CPU.
Caution: If you make a mistake in your code while modifying a PHP file, saving the php file may result in your site becoming temporarily unusable. Prior to editing php files, be sure to have access to the file via FTP or File Manager so that you can correct the error and always take full backup of your WordPress files and databases before editing.
Increasing WordPress memory limits
There’s different ways to increase your php memory limit however best practice dictates you edit your existing php.ini file or create a new master file and edit that. Follow these instructions to create a new php.ini file and increase the memory limits.
1. Login to your web hosts cPanel
2. Navigate to the Software/Services section and click on the PHP Config icon.
5. Rename the “php.ini.default” file to ”php.ini” which will activate it.
To do this navigate to your File Manager under Files in cPanel. You’ll normally find that when you click on the File Manager link you get a pop up which offers options on which directory you want to access.
In the popup screen, click the “Web Root (public_html/www)” & also ”Show Hidden Files (dotfiles)“. Click GO.
6. Navigate to the php.ini.default file which you have just installed and right click on it. You’ll be presented with a range of options so just click the Rename link.
7. Delete the default text from the end of the file by using the backspace button on your computer so your left with php.ini and save the changes.
You have now successfully installed a php.ini file to WordPress and can now edit this file to increase your PHP memory limit.
Increasing PHP memory Limit
Open the php.ini file again and navigate to the ‘Resource Limits’ section where you’ll find the memory limit on line 302. Its here you’ll see: memory_limit = 10M
This limit may be different or even on another line depending on the way your web host has setup the file.
Simply change the 10M to 24M, 32M, 64M or any limit you like up to a maximum which is normally 100M depending on your web hosts allowed limits.
Caution:If you are not familiar with these options, do NOT change them. This can cause all PHP scripts on your site to stop functioning if misconfigured.
You may also choose to activate Fast CGI by checking the Fast CGI checkbox and then clicking Save. This will help reduce the amount of resources your site uses and optimize it for better performance.
This results in all your .php files loading faster as Fast CGI eliminates the overhead of loading the PHP interpretor on every hit. Since it is always in memory ready for the next hit, the responses will be generated faster.
NO MODIFICATIONS to your existing PHP apps will be performed so you can easily enable and disable when you want.
If you have any unresolved problems when you try to increase your memory limit or edit php files, you are welcome to contact me using the contact form.