Sometimes, you get an allowed memory size exhausted error in WordPress. This is one of those common WordPress errors which can be fixed easily. It is also called as WordPress PHP memory limit error.
In this post, you’ll learn how to fix the WordPress PHP memory limit error.
What is WordPress PHP memory limit error?
As you already know, WordPress is written in PHP (a server-side programming language). For a WordPress website to function properly, every website needs a WordPress hosting server. These web hosting servers need memory for running multiple applications (at the same time) efficiently.
PHP has a specific memory size allocated by the server admins. When your WordPress code requires more memory than that is allocated, you get memory exhausted error.
The error will look something like this,
Fatal Error: Allowed Memory size of xxxx bytes exhausted….
Though WordPress automatically tries to increase the PHP memory limit if it is less than 64MB, it is often not enough.
What do you do in that case?
How to increase PHP memory limit in WordPress?
To increase the PHP memory limit, you’ll first need to edit the wp-config.php file located in your WordPress site’s root folder. Then, you’ll need to use a file manager in your web hosting control panel or an FTP client.
Next, paste the following code in wp-config.php.
define( 'WP_MEMORY_LIMIT', '256M' );
Paste the code just before the line that says ‘That’s all, stop editing! Happy blogging.’
This code is used to tell WordPress to increase the memory limit to 256MB. After you’re done, save your changes and upload your wp-config.php file back to your server.
Visit your WordPress site; the WordPress PHP memory limit error should’ve disappeared.
If the error persists, then it means your web hosting service provider does not allow WordPress to increase PHP memory limit. You’ll have to ask them to do so manually.
We hope that we’ve helped you solve the WorPress PHP memory limit error. If you know any other method to do so, please share with us in the comment section.