How to increase the WordPress memory limit, and why you should
Some of the most common WordPress errors are related to a lack of available memory. Sometimes this results in the ‘Allowed memory size exhausted’ error, or the ‘fatal error: allowed memory size of … bytes exhausted’ error, or even the dreaded White Screen of Death.
All of these errors are specifically related to how much PHP memory WordPress needs compared how much it is able to use (although the White Screen of Death could also be the result of a PHP error).
Fun fact: by default WordPress only has a 40MB memory limit. This means that all your theme functions and plugins have a maximum of 40MB to play with. For small, low traffic websites with a handful of good plugins, this may not be an issue. Going beyond that, it is recommended that you increase the amount of memory that WordPress can use.
But before you can increase the WordPress memory limit, you will need to know how much PHP memory your hosting account has afforded you. Depending on your website host, this could be as low as 64MB, but most good web hosting providers should at least be offering a minimum of 128MB.
Once we know how much PHP memory the hosting has, we can increase the WordPress memory limit to match. There are two ways you can find out:
WordPress 5.2 or higher
Go to Tools -> Site Health and hit the Info tab. Scroll down and expand Server and note the PHP memory limit value. This is what you’ll have at your disposal.
WordPress 5.1.1 and lower
Install the WP System plugin, activate it, go to Tools -> WP System and scroll down to PHP memory.
You can deactivate and delete this plugin once you’ve noted the memory limit (in this example, 256M can be used).
Now that you know the memory limit of the hosting account, you can force WordPress to take advantage of it.
To do that you’ll need to edit wp-config.php in your website root and add this line anywhere after where it says “That’s all, stop editing! Happy blogging.”…
define( 'WP_MEMORY_LIMIT', '256M' );
…and save the file.
In this particular case the memory limit is 256M, but you’ll need to change that value to match the actual PHP memory limit of your own hosting account.
Once you’ve done that there is nothing else to configure. Your WordPress installation should now have more memory for running PHP scripts, resulting in less likelihood of your website falling over due to memory limitations.
September 2021 in review
A lot has happened this month. Here’s a summary of updates, features and tweaks across several products.Keep reading
What to expect in wProject 1.4.0
wProject 1.4.0 is not far away and should be safe to push out next week.Keep reading
wProject has launched and you can get it right now
As of today wProject is available for purchase, and there are implications for Task Rocket.Keep reading
wProject feature demonstration
Subtasks are arguably the biggest deal. As is often with any task, there can be a number of smaller tasks that need to be accomplished within it.Keep reading
Introducing wProject and what it means for Task Rocket
It’s been is a long time coming. Specifically, wProject is intended to be the successor to Task Rocket.Keep reading
Why I eat my own dog food
For the uninitiated, I, nor any other developer, actually eats dog food (not that I know of anyway).Keep reading