WordPress Out of Memory Errors

What Causes WordPress Out of Memory Errors?

 

Out of memory errors are common 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. Unoptimized 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 file. To do this, follow these steps:

 

  1. Go to File Manager in your cPanel
  2. Go to your site’s root folder
  3. Find the wp-config.php file and choose edit
  4. Add the following line at the end just before the “Happy Blogging” line: define(‘WP_MEMORY_LIMIT’, ‘256M’);
  5. If this line already exists, increase the number to 128 or 256

 

This may or may not help, depending on what memory is available according to your php.ini file. It has the final say and can overwrite the above change. However, if your wp-config file didn’t have that line or it had a lower amount than what the php.ini has then this will probably fix 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?

Cloud and dedicated hosting plan users can edit the php.ini file for the site. It’s typically found in the root of the directory if there is one. If not, you can create one.

 

  1. Download or create the php.ini file in Notepead
  2. Add this line: memory_limit=128M
  3. Upload it to the root directory
  4. Check to see if the problem is fixed

 

Note: If this doesn’t correct the problem, you can increase the memory limit that is referenced above by replacing 128 in the above example with a value of your choosing.

 

Cleaning up your WordPress installation

This is something that should be done every now and then regardless whether you’re getting errors or not.

 

  • 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
  • Consider a helpful plugin like WP-Sweep to help you do most of the above and more

Share:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.