Are you seeing an allowed memory size exhausted error message in WordPress?
This is one of the most common WordPress errors, and you can easily fix it by increasing the PHP memory limit in WordPress.
In this article, we will show you how to fix the WordPress memory exhausted error by increasing the PHP memory limit.

What Is the WordPress Memory Exhausted Error?
WordPress is written in PHP, which is a server-side programming language. Additionally, every website needs a WordPress hosting server for it to function properly.
Web servers are just like any other computer. They need memory to efficiently run multiple applications at the same time. Server administrators allocate specific memory size to different applications, including PHP.
When your WordPress code requires more memory than the default allocated memory, you will see this error message:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home4/xxx/public_html/wp-includes/plugin.php on line xxx

By default, WordPress automatically tries to increase the PHP memory limit if it is less than 64MB. However, 64MB is often not high enough.
Having said that, let’s see how to easily increase the PHP memory limit in WordPress to avoid the memory exhausted error.
Increase the PHP Memory Limit in WordPress
First, you need to edit the wp-config.php file on your WordPress site. It is located in your WordPress site’s root folder, and you will need to use an FTP client or file manager in your web hosting control panel.
Next, you need to paste this code in the wp-config.php file just before the line that says, ‘That’s all, stop editing! Happy blogging.’
define( 'WP_MEMORY_LIMIT', '256M' );
This code tells WordPress to increase the PHP memory limit to 256MB.
Once you are done, you need to save your changes and upload your wp-config.php file back to your server.
Alternatively, you can use WPCode to insert this code snippet. It is the best WordPress code plugin that allows you to insert code snippets into your site’s files without editing them directly.
For more details, please see our guide on how to easily add custom code in WordPress.
You can now visit your WordPress site, and the memory exhausted error should have disappeared.
We also have a step-by-step guide on how to find and edit the wp-config.php file.
Note: If this solution does not work for you, then this means your web hosting service provider does not allow WordPress to increase the PHP memory limit. This is common if you are using shared hosting. You will need to ask your web hosting provider if they can increase your WordPress memory limit manually.
We hope this article helped you solve the WordPress memory exhausted error by increasing the PHP memory limit. You may also want to see our step-by-step beginner’s guide to troubleshooting WordPress errors, along with our expert picks for the best WordPress plugins to grow your site.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Aisha says
It doesn’t solve my problem still shows an error after placing the code “define( ‘WP_MEMORY_LIMIT’, ‘256M’ );” and I also change the size of Memory_limit of Php.ini file
WPBeginner Support says
As we state in the article, if our code does not work, there is a good chance your hosting provider is overriding the memory limit and you would need to reach out to your host to fix the error.
Admin
Sohaib Siddiq says
It doesn’t solve my problem still shows an error after placing the code “define( ‘WP_MEMORY_LIMIT’, ‘256M’ );” & this is my front-end page showing
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 8192 bytes) in /home/X/wp-includes/class-wp-dependencies.php on line 260
WPBeginner Support says
If the code does not work for you, we recommend reaching out to your hosting provider as they may have a limit set on their end that could be the root of the issue.
Admin
Zachary Murri says
Thank you so much <3
WPBeginner Support says
You’re welcome
Admin
Bogosi says
Thank you for this!
WPBeginner Support says
You’re welcome!
Admin