Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

Fix: WordPress Memory Exhausted Error – Increase PHP Memory

Last updated on by
Elegant Themes
Fix: WordPress Memory Exhausted Error – Increase PHP Memory

We have transferred numerous client websites, and sometimes a WordPress Memory Exhausted error shows up when activating a new plugin or doing some other task. Usually the error looks like this:

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

We got an email from a user who was facing the same problem, so we decided to do a writeup on it because this is a common problem. The reason why this error shows up is because you exceed your default Memory Limit. There are numerous solutions for it, but in this article we will share the simplest one out of all.

First open your wp-config.php which is located in the root WordPress directory. Then add the following line inside the main php tag:

define('WP_MEMORY_LIMIT', '64M');

We just increased the memory limit to 64M. If you still get the error after this fix, then please contact your host. Most likely, they would have to go in their php.ini file to increase the memory limit for you. If you have other ways of increasing the memory limit, then let us know in the comments below.


Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »

Comments

  1. Daniel says:

    Didn’t work for me, but I’m not sure what it means to be “inside the main php tag”. I opened the file in Dreamweaver and did a search. The word “main” doesn’t appear anywhere on the page. So I put the code in line 2, just after the “<php". Tried it at 64 and 128. Thanks.

    • Editorial Staff says:

      The main php tag means just insert it like you did. Sometimes this doesn’t work in which case you have to ask your host.

  2. Deepanshu says:

    Thanks for the help.
    But 64M was already default for me and of course it wasn’t sufficient so I changed it to 96M and I think u should mention this as well.

  3. Jan says:

    Nice but nothing works – use rackspace cloud – tried 32 – 64 – 128 – 256- 512 – 1024Mb MU site i can’t go more up and only in admin i can’t get access after a plugin from wpmudev so guess i have to delete that and try something pro.

  4. Julie Geiger says:

    worked perfect.. thank you for sharing, tried a few other fixes but all errored out.

  5. Nick says:

    Thank you for the article. It was a great help

  6. pathik says:

    its really work,, i had problem of internam server,,, when add new plugine,,, i just increse memomry limit
    define(‘WP_MEMORY_LIMIT’, ’64M’);
    in wp-admin and problem solved..

    tthnaks a lot

  7. Joke van de Fliert says:

    thanks! for me the provider had to change a setting to increase the memory limit, but that did fix it!

  8. Jennifer Ortiz says:

    Thanks a million for this! I got the error message right after the WordPress install–I never even had a chance to add a plug-in.:

    Fatal error: Allowed memory size of 33554432 bytes exhausted…

    All seems to be working fine now.

  9. Timothy Jacobs says:

    I have tried to do this, but it has not solved the problem.  I am on 1&1 hosting and I have tried all the changes, but I still get this error whenever uploading a semi-large picture:
     
    Fatal error: Out of memory (allocated 29884416) (tried to allocate 4096 bytes) in /homepages/21/d258522816/htdocs/TBJFilms/WP/wp-includes/media.php on line 1010
     
    What is your suggestion?

  10. aidilgoh says:

    Tried placing this at the end of the wp-config.php and didnt work.

    However, placing it on top right after the <?php tag worked. Hooray!

  11. PatrickTyrus says:

    this was a great help, but as you noted it could easily be a plugin, or as someone mentioned it could be a memory leak.

    And as others have pointed out, there are memory settings for a reason, some hosts will cut your services if you try to circumvent them.

    Is there a way to check on what’s eating memory?

    I’ll be searching, but this is something that should be listed under related posts, or as a note and link at the end regarding one of the “numerous solutions for it”. Going for the “simplest one” might get you through the day, but is may not be a good long term solution as it may cover up the real problem and delay the inevitable.

  12. wpbeginner says:

    @shally1584 There is no = << in our code. So are you sure that you are pasting our code as an independent function and not as part of something else.

  13. shally1584 says:

    hi.i tried to adjust memory limit and got this error

    ‘Parse error: syntax error, unexpected ‘=’ in /home/amanerdm/public_html/beaverealty.com/wp-config.php on line 62′

    pls help fix this.thanx.

  14. Luna says:

    Thank you for this post… I had a couple of category / archive query pages that were throwing this error after I upgraded to WordPress 3.1. I was just about to re-write the queries until I found your post in a Google search.

    You saved me a lot of work and headaches :)

  15. Kdb says:

    I ended up having to switch hosting companies because I couldn’t get my current one to increase the memory from 32MB to, well, anything more. Pretty sad. Took a bit of hassle to transfer three WordPress sites (and multiple other sites), but it was worth it. My current host offers 128MB and my sites are working SO much better. I can actually add plug-ins.

  16. Richard says:

    Hello
    I tried the fix by adding the line immediately after the opening >php tag (line 1)
    define(‘WP_MEMORY_LIMIT’, ’64M’);

    It did not work for me BUT
    I placed the line with comments for my own use on (as it happens) line 22 and it worked.

    I am testing this procedure on a test WP site using Twentyten 1.2 Theme

    /home/par*****/public_html/wp-config.php

    Line 22 /** WP memory limit Note it does not work when placed immediately after line 1 */
    define(‘WP_MEMORY_LIMIT’, ’64M’);

  17. Chris says:

    This trick doesn’t work for me ever since WP 3.

    what I found worked was to create a PHP.INI file in the wp-admin folder with the line:

    memory_limit = 128M

    (or whatever you want to make it)

    • Editorial Staff says:

      Sounds like a host issue rather than WP 3.0 issue. We still have this trick working on our clients.

      • Trunks says:

        This worked for me! Thanks!!!

        Create PHP.INI in the wp-admin folder, with the line “memory_limit = 128M;”

        I changed all the other methods, and this was the only one that seemed to work.

    • dan says:

      Brilliant! Thanks!

  18. kdb says:

    I tried this, but my host limits it to 32 megs. Can anyone recommend a good host for WP, because I’m going to have to change. Thanks!

  19. phil says:

    I put that line at the very top of the file (wp-config.php) and it worked!

  20. ayahshiva says:

    i also got the same warning when i activated too many plugin

  21. Eyl says:

    I have done the trick but seems like nothing happened. The error keep showing so can you suggest other solutions?

    • Editorial Staff says:

      On some hosts, this trick won’t work. So you have to ask (beg) them to increase the PHP Memory Limit. OR get rid of the plugin which is causing it.

  22. Seth Merrick says:

    Great article. A brand new plugin that may soon find its way on to this list is Cobalt WP Boost.

    Check it out here:
    http://frugaltheme.com/about/cobalt-wp-boost-plugin/

    It allows blog owners to raise their WordPress Memory Limits with a couple of mouse clicks, as well as showing at-a-glance memory usage information. WordPress keeps its internal memory limit at 32MB, which is fine for a small-time blog; but if you’re trying to add any robust plugins for social networking or ecommerce applications, 32M will not suffice. This problem can only be expected to worsen with the release of 3.0 which, judging from the beta release, will consume a lot more memory itself without upping the 32MB limit.

  23. W^L+ says:

    Just remember that if the problem is a memory leak (either in PHP itself or in some library that is used by a plugin), this will merely delay the occurence.

    Before you change the memory limits, you should ensure that you’re using the most up-to-date versions of any plugins. Be sure you are running the newest version of WP. If your host offers multiple versions of PHP, be sure you’re using version 5.

    Your hosting service may have preset limits on memory usage. If your editing causes you to exceed those limits, your service may be suspended or canceled without warning.

    • Dunn says:

      I tried to deactivate the plugins one by one and found out that the Google XML Sitemaps plugin cause problem.

  24. Muhammad Asad says:

    I would like to try it! Thanks for the trick.

  25. wparena says:

    I think the better way is to put this limit in wp-setting.php file where this memory limit already described as 32M, just changed that value to 64M.

    • Chad McCullough says:

      Thank you, wparena. I’ll try this.

    • Chad McCullough says:

      Changing the settings in the wp-settings.php file fixed my 2 week, driving me crazy, issue! Thank you very much!!

      -Chad

    • Editorial Staff says:

      Yes, but editing the core files is not the best way. You would have to change that every time you update WordPress. The way we share in this article, will save you time.

      • Chad McCullough says:

        I would much rather not modify core files, if possible. Where would I place the line in the wp-config.php file? I’m not sure where the main php table is.

        Thanks for the article and the help!

  26. Kate Mag says:

    Awesome trick. Is that same with PHP memory limit?

  27. Chad McCullough says:

    I think that this might fix an issue I’ve been having with my site. I just can’t figure out where the main php table is in the wp-confip.php to place the line.

    Thanks!

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.