How to check and increase your WordPress site's memory limit
Updated 1 week ago
by
Ben Oates
WordPress can sometimes run out of memory. This isn't very common, and usually only happens on either extremely busy or fully featured sites (lots of plug-ins and/or functionality) or if there's a code issue with a theme or plug-in being used.
You'll often see an error something like -
Allowed memory size of xxxxxx bytes exhausted.
or
Fatal error:Out of memory
followed by some detail about what was allocated/attempted to be allocated and what file was making the request - this can often be a clue as to where to look for any code issues.
Sometimes, however, it may just be a case that the site needs more memory available in order to run.
We always recommend that you run your site using the latest supported version of PHP, along with the latest version of WordPress and any theme and plug-ins.
WordPress has a built-in Site Health tool so you can see what memory limits are set.
You can find the Site Health under the Tools menu in the WordPress dashboard. Click the Info tab at the top.
First of all, check the Server section. This will show the PHP memory limit set on the server.The WordPress PHP limit can never be higher than this. So, if this is low you'll first need to increase the server PHP limit. We have a separate guide that covers changing PHP settings. Once you've increased the server's PHP memory limit, come back and refresh/reload the Site Health page and you should see the new limit. You could re-test your site at this point and all may be well - but the next step will allow you to check and confirm if WordPress is using this new limit automatically, or whether you need to make some further adjustments to tell WordPress to use a higher limit.
If you've checked your server limit and that's set as required the next step is to check your WordPress limit which can be set independently - but would usually set itself to the server limit. Expand the WordPress constants section on the Site Health page.You'll see here the WordPress memory limits.
If the figure shown is lower than the server limit you checked in the previous step, that is usually fine and not something you have broken. WordPress only ever raises the memory limit, never lowers it - so where the server already allows more, the server figure is the one that actually applies. With nothing set explicitly, WordPress reports its own defaults: 40M for the front-end and 256M for the admin area.
WordPress has two memory limits you can set. WP_MEMORY_LIMIT - this sets the PHP limit for the front-end of the site - this would usually be what you'd need to set if your site was experiencing fatal errors. WP_MAX_MEMORY_LIMIT - this sets the PHP limit for the admin area of the site - this can be set higher, or lower than WP_MEMORY_LIMIT as sometimes admin functions - like using third-party page builders can require more memory than is required to serve the site to visitors.
To confirm, or set these limits if they are lower than your server PHP limit you'll need to edit the WordPress wp-config.php file. You'll find this file in the root directory of your site. You can access it via cPanel File Manager or FTP. Check your wp-config.php for either of the following lines: define( 'WP_MEMORY_LIMIT', 'xxxM' ); define( 'WP_MAX_MEMORY_LIMIT', 'xxxM' ); If you find either line you can normally safely delete it to allow WordPress to use the limit you set within the cPanel PHP settings (see step 2). However, should you require a different limit you can add either line, with your required memory limit. Please ensure you add any additional entries above the "stop editing" line - /* That's all, stop editing! Happy publishing. */ Remember the limits you set can't exceed the server limit. Save your wp-config.php file and refresh the Site Health page to confirm the new limits are in place.