WordPress Error – “Allowed memory size of 8388608 bytes”

You sometimes might get the following error if you are trying to import a previous blog into a newly installation of WordPress through an RSS feed or while installing a new plugin as:

Allowed memory size of 8388608 bytes exhausted (tried to allocate xxxxx bytes)

This means that the server is not allowing to process the size of the data than its maximum alloted size. Remember that there is nothing wrong with the WordPress installation. Its the matter of the amount of data that the server can process at one time.

Don’t be scared, you can get it resolved in a matter of seconds. There are two ways of resolving this error.

Method #1 : Without Restarting the Server

If the error mentioned appears during the importing, what you need to do is get access to the source code of the WordPress where you have done the installation.

Once you get the access you will need to modify two files . They are:

  1. <installation_directory>/wp-admin/import.php
  2. <installation_directory>/wp-admin/import/wordpress.php

Now copy this line of code:

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

This line increases the server processing capacity by the included size i.e 16M. Paste the above line in the import.php file just after the line of code:

require_once ('admin-header.php');

Now in the second file i.e. wordpress.php paste the code after the line of code:

<?php

Note: If the error mentioned appears during the installation of a plugin then make a note of the path and the .php page which is given out in the error and paste the same line in the mentioned .php page.Remember, the code must be pasted within the php code block i.e in between <?php and php?> in the page since it is to be executed by the server.

Now once again access your WordPress URL and go to the manage > import menu and try importing. If your problem still remains, just keep increasing the size mentioned in the pasted code in multiples of 4 i.e. in place of “16M”, try “20M”, “24M” etc.

Method #2 : Which Requires a Server Restart

If you want to eliminate this error once and for all then you need to target your server to make the changes. But you should have the permissions to restart the server.

If you have this permission then go to the server installed path and search for the file php.ini file. In this file there will numerous things mentioned. But all you have to do is search for the term “memory_limit“. Change the value of this variable from 8M to either 16M, 24M, etc as required.

Save the file and restart your server. The error will be resolved once and for all. Good luck!

48 thoughts on “WordPress Error – “Allowed memory size of 8388608 bytes”

  1. After searching for answers….you explanation was PERFECT!

    I got the wacky error and didn’t want to put in a trouble ticket with my hosting company.

    I followed your instructions for Method #1, ftp’d those files up to my server and went back into my blog and waa-la, it worked!

    Thanks so much for your excellent and easy to understand advice.

  2. Thanks…
    I pulled hair for hours trying to work out what i had done wrong and which plugin was at fault but ended up with the same error no matter which one was installed last.

    You saved my sanity (not that theres much left to save)
    So Thanks

  3. Hi,

    I’ve recently upgraded to WordPress 2.3.1 and started getting memory exhausted errors all over place.

    At this moment, I’m trying to import UTW tags, but to no avail the screen comes blank after step 1.

    I searched around and found your post, and followed method#1, edited import.php and wordpress.php, but still I’m not able to complete the and getting memory error in wp-db.php. I’ve entered same values at the top of wp-db.php also, but still same error persists.

    I’ve written to DreamHost also, but didn’t received reply from them as of now.

    May be only you can help, waiting for your reply.

    DG….

  4. i try your solution to the fatal error message when i’m importing my DB from my old blog…

    now i recive this message:
    Warning: ini_set() has been disabled for security reasons

    i think is a problem with my host… is tripod.lycos.es and it’s free… i don’t want to ask for help in lycos.es, there is another solution for that ?

  5. The only solution is to get to a good paid host. I would recommend Bluehost hosting to you since this site is being hosted by the same. The support team of Bluehost is really good and quick. The main advantage you get is to host unlimited domains on a single account!

  6. Do you really have to do anything or will the problem just go away by itself? Wondering if it has anything to do with server load at the time…

  7. Hi there-
    Can you please help me?
    I’m scouring the internet for help.
    I’ve just started to go self-hosted–> from WP.com to self hosted using WP software. I’m trying to import my blog XML file, BUT it’s too large. It’s 3+ MB and the WP software says it can only import 2MB file or smaller. What can i do? I’ve seen some posts talking about ’splitting up’ the XML file into smaller files…but i don’t understand how to do this and need step by step instructions. I’ve read your above post too but don’t know how to find the files you are talking about to make the changes. Would you be able to help me, please??
    THanks!!
    Lisa

    http://www.llworldtour.wordpress.com
    http://www.llworldtour.com

  8. Hello!
    Very Interesting post! Thank you for such interesting resource!
    PS: Sorry for my bad english, I’v just started to learn this language 😉
    See you!
    Your, Raiul Baztepo

  9. Hello there! This is kind of off topic but I need some help from
    an established blog. Is it very hard to set up your own blog?
    I’m not very techincal but I can figure things out pretty quick.
    I’m thinking about setting up my own but I’m not sure where to
    begin. Do you have any points or suggestions? With thanks

  10. Hello, I think your blog might be having browser compatibility
    issues. When I look at your blog siye iin Safari, it looks fine but when opening in Internet
    Explorer, it has some overlapping. I just wanted to give you a quick heads
    up! Other then that, awesome blog!

  11. For those of you looking for wordpress.php, it seems as if it is now in /wp-content/plugins/wordpress-importer/wordpress-importer.php. However, I’m not 100% positive, as I just went with editing php.ini option.

  12. I tried this and it didn’t work for me. I tried a thousand ways but to no avail.

    So I contacted my host provider’s customer support and they told me I could change it like this:

    – Go to your cPanel
    – Click on “Select PHP version”
    – Once inside, click on the link that reads “Switch to PHP settings”
    – It will show the entire list of settings and allow you to change them to whatever you need. So increase the max file size to the amount you need!

    After that, I didn’t get any error anymore! Hope it helps! My host is namecheap.com, I don’t know if it’ll work the same for other hosts, but if it can save you a headache, it’s worth trying the above steps!

Leave a Reply

Your email address will not be published. Required fields are marked *