Fixing “Fatal Error: Allowed memory size of 33554432 bytes exhausted”

After updating to WordPress 2.8.6, I received an error telling me that my “Allowed memory size of 33554432 bytes was exhausted (tried to allocate 30720 bytes)” when I tried to access my site’s admin page. Thankfully, this only appeared on my site’s backend, but there are a lot of WordPress users who have had similar (if not identical) issues. So, I’ve put together a little how-to walking you through all the things that could be causing the restriction in memory.

What is this error, exactly?

Everything on your website takes up a little bit of memory. The biggest culprit of this are plugins, which often times are the easiest answer to the problem; if you have a lot of active plugins, just deactivate a few! Regardless, plugins aren’t the only thing that can cause memory overflows; things like excessive animations, or inefficient scripts. Your page might even have too many images, but it would take quite a lot of content like this to demonstrate this issue.

Interestingly enough, there is a surprisingly simple way to fix this issue. You just need to enter a line of code in a few places so that your wordpress install knows to allocate more memory. Here’s a solution, in a few simple steps:

1. Open your FTP browser and navigate to the folder/directory that you installed WordPress in. From there,  locate “wp-config.php”. You’ll need to open it in whatever editor you like. Once you’ve done this, enter the following code somewhere close to the top:

@ini_set('memory_limit','64M');

Check to see if the error is resolved. If not, go on to step 2.

2. In your FTP browser, navigate to your root folder (it’s usually /public_html/ or /www/) and look for a “PHP.ini” file. You’ll need to find a line like this:

memory_limit = 12M

Change “12M” to “32M” to allow the PHP scripts WordPress runs to access more memory. If this doesn’t work, try changing it to “64M”. If you still have issues, and you have access to your webserver, it might be necessary to restart your webserver. If this doesn’t work, or you don’t have access to your webserver, then you’ll need to go ahead to step 3.

3. We’re going to edit your /install.php file. You can find this file in the root directory of your site, or in whichever directory/folder you installed WordPress in. You’ll need to add the following line to the beginning of the file:

ini_set('memory_limit','32M');

When you are finished, the beginning of the file should look like this:

ini_set('memory_limit','32M');
/**
* WordPress Installer
* @since unknown
* @var bool
*/
define('WP_INSTALLING', true);

If this still doesn’t work, try changing “32M” to “64M”.  If you’re totally at a loss for ideas, I’d recommend contacting your site’s host and asking them if there’s any issues with your server. If you have access to your administrative control panel, you might want to try disabling any extraneous plugins, as well.

Final thoughts

It’s always a good idea to be tidy and prudent. Delete anything you don’t need or that doesn’t need to be archived. Get rid of plugins that you don’t use, and update any old plugins (often times, plugins are optimized between versions, to run smoothest with the latest versions of WordPress). This saves you from issues when you upgrade your site. If this article helped, or if you need some extra assistance, post a comment! I’d appreciate it.

  • themecreator

    weird… I didn't get any error. I think there was an option when you wrote the config.php file, which allows you to give wordpress unlimited space… can't remember exactly.

    • http://technoheads.org Salem

      It doesn't happen with everyone; Like I said, it depends on how much stuff
      you're running on your site.

      • themecreator

        ah, I see… well it's not that much stuff yet, but it will be :D

  • http://www.naturalk9supplies.com/Dog-Food/merrick-before-grain-chicken-can.aspx MerrickBeforeGrain ChickenCan

    I think there was an option when you wrote the config.php file, which allows you to give wordpress unlimited space… can't remember exactly.

    • http://technoheads.org Salem

      There is, I'm sure, but the limit is there for a reason; a plugin
      could be poorly scripted and could contain a memory leak. It also
      ensures that your site loads quickly.

  • http://technoheads.org Salem

    There is, I'm sure, but the limit is there for a reason; a plugin
    could be poorly scripted and could contain a memory leak. It also
    ensures that your site loads quickly.

  • Miroslav Bekyarov

    Can u help me? I have this problem but there is no php.ini file in my public_html folder :(

    • http://technoheads.org Salem

      Does your server support php?

  • Ludovic Helleboid

    thanks a lot, it helped me to fix my issue !

    • http://technoheads.org Salem

      haha, no problem.

  • caribbeanPresser

    wow.. thanks. I was worried there for a minute, now I have regained full access to my admin panel. Thanks again!

    • http://technoheads.org Salem

      haha yeah, i remember the whole process being a bit frightening. Just remember, as long as you can still access your database, you’ll always be set.

  • Wholdipp

    Thanks i have been pulling my hair out until I saw this solution to my problem

  • Jay

    YOU ARE MY FKING HERO!!!!!!!!!!!!!! I just upgraded to 3.2.1 and was getting this error. Was driving me NUTS last night!!! I know this post is old, but it came in at #2 on Google for the problem ;)

    • http://technoheads.org Salem

      Haha glad it worked :D i figure if I have an issue, someone else must be experiencing something similar.

  • Wayne

    Way to go Salem.  My wife upgraded her site to 3.1.2 and was getting this error and hassling me to fix it.. Once again I am her hero.. hope you don’t mind if I let her think I solved it on my own! :-)

    • http://technoheads.org Salem

      No problem! You may go right ahead and keep this a secret. I got your back ;)

  • Alamin Major

    thanks, it’s working. thank u very much. my site is http://celebritydisk.com

    • http://technoheads.org Salem

      Glad it worked! Might want to check your site though, looks like you have a few other issues still.

  • http://technoheads.org Salem

    Absolutely. I’d hate for other people to have to freak out like I did when this happened to me.

  • http://www.hanso.me/ ?sir

    thanks for your help. i had just been resolved in the 1st step .
    thank u very much!!

  • Pingback: ?sir » ??“Allowed memory size of 33554432 bytes exhausted”

  • Clayton

    Thanks! option 1 worked for me

    • http://technoheads.org Salem

      Awesome! Good to know it’s working.

  • http://www.facebook.com/bonnkosi Goodwill Bonginkosi Hlathe

    great. you saved my life.

  • http://twitter.com/keith_dotson Keith Dotson

    Thanks for this post. Easiest fix ever thanks to you!

  • shahnawaz kaka

    i have tried first and third step respectively and it works properly.thanks..