Out of memory errors in WordPress are one of the most common errors that can occur with sites running on WordPress. WordPress themes and plugins are notorious for hogging up site resources and bogging down your site, especially if you have a lot of them. Un-optimized code can also be too demanding and easily start to eat up what memory you have available.
How Do I Fix Out of Memory Errors on WordPress?
You may be able to increase the memory available for your site by simply adding a single line of code to your wp-config.php file. To do this, follow these steps:
Step One: Go to the File Manager in your cPanel Interface
Step Two: Find the wp-config.php file located with your WordPress installation and choose edit
Step Three: Add the following line at the end just before the “Happy Blogging” line:
If this line already exists, increase the number to a higher value than what it was previously.
This may or may not help, depending on what memory is available according to your php.ini file and the memory allowed per the hosting plan that you have. It has the final say and can overwrite the above change. However, if your wp-config.php file didn’t have that line or it had a lower amount than what the php.ini has then this will have a good probability of fixing the problem.
If it doesn’t fix it, then you can change the amount of memory allocated to the site in the php.ini file if you’re on a Cloud or dedicated server (below). If you’re on one of our shared hosting plans, you don’t have access to the php.ini file. Try the other fixes below and if nothing works then it may be time to upgrade your hosting plan.
How Do I Increase Memory Using the php.ini File?
Step One: Download or create the php.ini file in Notepad or your preferred text editor
Step Two: Add this line:
Step Three: Upload it to the root directory of your site.
Step Four: Check to see if the problem is fixed
Cleaning up your WordPress installation
This is something that should be done every now and then regardless whether you’re getting errors or not. Doing these can improve overall performance of your WordPress installation and reduce resource consumption.
- Get rid of any plugins that you don’t need. Delete them – don’t just deactivate them and let them pile up in your plugin directory
- Empty the trash section and get rid of the revision versions of posts
- Delete all those spam comments that have been piling up since you first started your site
- A useful plugin that can be used to profile the Resource Consumption of other plugins is P3 Profiler which can be installed on your WordPress.
- How To Lower WordPress Resource Usage – A neat guide that suggests possible ways that the resource usage of your WordPress installation can be reduced.
- Installing WordPress Using Softaculous – A guide on how you can easily install WordPress using the Softaculous Scripts installer.