Are you getting an “Allowed Memory Size Exhausted”? error when you try to access your WordPress site?
This is actually one of the most common WordPress errors, and it’s easy to correct by increasing your WordPress PHP memory cap.
There are a couple of problems with that very simple statement, though. Many WordPress site owners don’t know what a PHP memory cap is or even that their site has one. And while a few Google searches – made through their panic because their site is down – may reveal what it is, finding out how to do it is a different story.
It’s not just a fatal error that will highlight the problem either. An increasing number of WordPress sites are making use of WordPress’ own free to use – and rather nifty – Site Health Status Plugin. That will post an ongoing warning if your PHP version is out of date. However, it does not offer much practical help either. But it will warn you that something critical may happen any minute (see that failed to update error? That’s a clue that things may go bad soon on this site.)
In this post, we’ll show you how to increase PHP memory to fix the WordPress memory exhausted error.
What is the WordPress Memory Exhausted Error?
Although it is an open-source project that has thousands of contributors, there are lots of set standards for the platform and everything that runs on it (sites included). One of them is that everything is written in PHP.
PHP is a server-side scripting language. A script – in web development terms – is a compilation of runtime-interpretable programming instructions. A scripting language is something that interprets scripts as they are running. Sorry for making your eyes hurt. In simpler terms, PHP makes stuff on WordPress work.
This makes PHP – which stands for Hypertext Pre-processor, but once stood for Personal Home Pages; thus, the order of the letters in the acronym – very important in the WordPress scheme of things. So, running out of PHP memory ‘breaks’ all kinds of things, and when the memory is completely exhausted, it usually crashes whole WordPress sites, sending their owners into a panic and a race to fix the WordPress memory exhausted error.
To be fair to WordPress, it does try to fix this by itself. When a site’s PHP memory is filling up, it will attempt to raise it to 64MB if it’s at less than that. However, that is as high as it can go by itself, and in these days of far more complex, code and content loaded WP sites, that is rarely good enough.
How To Increase PHP Memory Limit in WP
You can now take over and try to increase the PHP memory limit yourself. You’ll need access to your WordPress site’s root folder via the file manager in the web hosting control panel to do so.
To find this file, log in to your CP and find that WordPress site’s root folder. Open it up, as you are going to be pasting in some code. You’ll be pasting the code in the file marked wp-config.php. Usually, that’s right at the end of the files listing.
The code you’ll need to paste in is a single line, and it is the same for all WordPress sites. It’s very simply this:
define( ‘WP_MEMORY_LIMIT’, ‘256M’ );
However, don’t just grab it from here. You’ll need to put it into a text editor and copy it from there to ensure you are not adding any stray code that will break even more stuff.
When you have your (clean) code on your clipboard, paste it into the wp-config.php. file right before the line that reads ‘That’s all stop editing! Happy blogging.’
What this little code snippet does is tell your installation of WordPress to increase the PHP memory all the way up to 256MB, more than enough for even the most crowded with ‘stuff’ site. This done, save your changes. Exit out, head back to your WordPress site, and everything should be back to normal.
Why Does a WordPress Site-Run Out of PHP Memory?
As we mentioned, the plugins, themes, widgets and extensions that we all use to make our WordPress sites so cool and useful use up a lot of resources and memory. If the PHP memory limit is set low, there will come a point when yes, it runs out completely, and you’ll likely be faced with a situation in which you’ll be searching for a how-to-fix the WordPress memory exhausted error problem solver (like this one)
Dealing with a Web Host PHP Block
There is a wrinkle here in what should be a very simple process. That complication is that an increasing number of web hosting companies are not allowing their customers to increase their PHP limit by themselves. There is no workaround for this one, your only option will be to contact your web host and ask them to do it for you.
At the same time, you should also ensure that they upgrade your site to the latest PHP version. In an ideal world, they would do this automatically, as new versions are released. Unfortunately, it’s been our experience that they don’t, and, very often, if you don’t ask, it won’t get done.
Why are they doing this?
The problem occurs for WordPress sites on a shared hosting plan, which is a lot of them.
PHP applications are now often limited in memory capacity by your host directly. Due to the high CPU/memory requirements of some WordPress plugins, this is becoming extremely prevalent (WooCommerce being a prime example, so watch out e-commerce site owners).
If the plugins are allowed to consume more than 512MB, they can trigger slowdowns on other customers’ sites, so the ISP sets caps. It’s for this reason that they won’t let you make the simple fix we’ve described yourself.
The only workaround here is to upgrade your hosting plan. Once you are not sharing with others, naturally, the ISPs will allow you more memory and more freedom to do as you please with your site.
Dedicated hosting IS more expensive, the reason many avoid it. However, is your WordPress site frequently runs out of memory (because your ISP is limiting it), then making a change will be your only choice if you do not want to remove anything from your site.
Hopefully, this has helped you fix the WordPress Memory Exhausted Error, and your WordPress website is back to normal!
Need help with WordPress and WordPress SEO? Our team at Pearl Lemon have decades of combined experience, from site design to technical SEO for WordPress, so feel free to give us a call to discuss your needs.