Are you seeing an allowed memory size exhausted error 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 WordPress memory exhausted error by increasing PHP memory.
What is WordPress Memory Exhausted Error?
WordPress is written in PHP, which is a server-side programming language. 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 get to see this error.
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 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 PHP memory limit in WordPress to avoid memory exhausted error.
Increase 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 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.
You can now visit your WordPress site and memory exhausted error should disappear now.
If you are new to WordPress, then take a look at our beginners guide on how to copy and paste code from the web.
We also have a step by step guide on how to find and edit 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 PHP memory limit. You will need to ask your web hosting provider to increase your PHP memory limit manually.
That’s all we hope this article helped you solve WordPress memory exhausted error by increasing PHP memory limit. You may also want to see our step-by-step beginner’s guide to troubleshooting WordPress errors.
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.
It’s 1:53AM and because of you, I can sleep in peace now. THANK YOU!
Chintan Dave says
define( ‘WP_MEMORY_LIMIT’, ‘256M’ ); worked all time. Thank a lot for the solution.
you guys are amazing you solved most of the issues i encounter since started working with WordPress.
Siddhartha Gautam says
It worked for me. Thanks!
Haley McCalister says
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 22 bytes) in /home/nels1max/public_html/ngifts/wp-includes/class-wp-hook.php on line 286
I’ve tried to expand my limit but it didn’t work. When I refresh the page, it changes what’s after “/wp-includes/” and the line number, but none of those files have a place to expand the size. Any tips?
Jordan Casey says
Try increasing it to 512M. There still isn’t enough memory for whatever theme you’re running. Good luck! P.S. make sure that you have more than 512M of memory. Ask your hosting provider.
Marcel Dusek says
Great! It worked. Thank you so much !!!
Vikas Yadav says
Thank you so much for sharing this. Helped me a lot!
It works! Thanks for the suggestion. But I have a question. I find another article said that changes WP_MEMORY_LIMIT in default-constants.php. Is there any different between this two methods?
Jeff C says
I have the same question. Can you explain the difference? Why use one over the other?
WPBeginner Support says
The constants file is for settings that don’t change, editing the config file is where you would make changes that can be reverted later when you are no longer receiving the error.
Joseph Sintum says
Thank you very much for this fix.
I was already freaking out…
Ahad Arzi says
Thanks man. iT’S REALLY HELPS
Wow, this worked like a charm and it was easy peasy! Thanks so much!
Thank you very much! It works
I looked everywhere for a solution and even called the host searching for an answer. Fixed it PERFECTLY! Thanks so very much!
Thanks a lot! My problem was solved in 5 minutes!!
we are getting this error
let me know the solution on it?
Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 8192 bytes) in /home/f036v20tz3th/public_html/wp-includes/functions.php on line 5276
Desmond Lai says
Great! It works well. Thank you so much.
Thanks for the tips, fixed with the memory line in wp-config
Shehan Disanayake says
This was very helpful. Thanks a lot.
Thanks so much guys for this article! What is the diference from changing wp_memory_limit (wp-config.php) and memory_limit (php.ini)??? Are the same??
This memory limit is for individual sessions or entire wordpress site?? I ask because if i had 200 visitors in minutes.. i have to go damn higher with this number?? Or try to keep it low??? Hope you can help me with this!
Thank you so much!!!
Thank you guys so much for this! I spent the last couple hours trying to figure this out.
Rick Hunter says
Excellent. Thanks so much. Changed to 1024 and it worked like a charm.
When I changed with 512 M it was failed then I put it define( ‘WP_MEMORY_LIMIT’, ‘2000M’ );
And it works well.
/* That’s all, stop editing! Happy blogging. */
if that code doesn’t work, rephrase it to
//increase WP Memory Limit
Could this be set to 512MB by any chance?
I am hosted by OVH
WPBeginner Support says
Yes it can be.
worked like a charm and loads faster .. but sure would like to knw the root cause and fix the issue there
you can change but it maxed out the memory and gave frequent errors of the same, editing posts on wordpress.com also had errors and tags and categories did not populate there.
in WP it seems to work but it lagged considerably.
If you have more memory allocated then you can do it. I am gonna do half of memory allocated by hosting. check cpanel for that.
Thank you so much! I’ve been waiting for my developer to respond in order to fix it when I could have just done it myself! So much time wasted, thank you for publishing this!!
Thanks, you da MAN! Fixed my problem
Yakin Shah says
This is awesome. just 2minutes, and I got my website back to working. Thanks!
You ROCK! Easy to follow and it worked! I am web-illiterate and was able to fix it in one go. THANK YOU!
Awesome, thank you, you saved my site
You guys are great. Thank you so much for the help!
Sue Hanson says
Thanks a lot for this article. It really helped me out. I was able to fix this problem and get onto building my site.
Beautiful, simple fix, thanks so much!!
Morgan Leahy says
Before doing any of this…be sure to check your root install directory. I had a blank ‘index.htm’ file that was left by my hosting service, and I completely overlooked it.
Thank you so much for posting this tutorial! It fixed my website so I could start breathing again!
Worked like a charm… Love the internet!
Dana Jewel says
Thank you so very, very much for sharing this tip.
Bharat M says
You are rocking men…
Every time I got an problem, I got it solution from here…
Thanks for the awesome article.
Karen Gusler says
Thank you!!!! This was a Godsend!!! While trying to troubleshoot why some emails are not being sent via our online form, I installed a plugin and it caused this error. My web site is back up and running!!!! Thank you again!
By following these steps I have fixed the problem. Thank you SOOOOO much!
Excuse me. What could be the cause of this?
Jason Didner says
That fixed a number of problems! Being able to change themes; being able to save my widgets – great tip! Spent a lot of time looking for this solution.
Thanks a lot!
It works really nice for me.
Thank you so much.
Amir Khan says
Thanks a lot fixed my issue Successfully
this doesn’t resolve my issue plz now tell me what I can do ?
still error is there
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 4114136611 bytes) in C:\xampp\…\wp-includes\functions.php on line 5163
I get this error quite often. And I am not sure why.
It comes from the function wp_is_stream(). I’m not sure where this is being used that is causing the error.
A bit of investigation showed that if you comment out wp_head() in your header.php file that solves the issue. More specifically, it is something hooked onto the ‘wp_head’ action, and I think one of the filters with priority of 10. Unfortunately, after getting this far, the error magically fixed itself and went away, so I wasn’t able to track down the exact function. Also, wp_is_stream() was only used in 3 or 4 places, so maybe you could find the culprit easier just by checking the usages of that function.
Brandon J says
This was amazing. I was skeptical at first since this was my first time ever doing something like this. I finally just went for it and it worked. Thank you so much.
Sahil gour says
Thank you so much for explaining everything. it works thanks
This fixed my issue. Thank you for the well-explained article.
Thanks a lot, you saved me. You are my go-to site for most of my wordpress related problems!