Is your WordPress memory limit exhausted?
If you’re getting a error which looks something like this ‘allowed memory size of 33554432 bytes exhausted‘, then you need to increase your PHP allowed memory limit.
By default most web hosts set the WordPress memory limit fairly low as a higher limit allows for use of more server resources ( CPU ).
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.
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.
In this post i’ll show you how to increase the limit via your php.ini file as well as 2 other very simple solutions.
Firstly, here’s the php.ini solution:
1. Login to your web hosts cPanel
2. Navigate to the Software/Services section and click on the PHP Config icon.
Install a php.ini file
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.
Increase via wp-config.php
Simply add the following line to your wp-config.php file using a code editor.
define('WP_MEMORY_LIMIT', '256M');
Increase via .htaccess
Simply add the following line to your .htaccess file using a code editor.
php_value memory_limit 256M
No cPanel
Some hosts use primitive control panels and may require you use SSH command line to create and edit a php.ini file.
Was This Tutorial Helpful?