It is about technology!
 Subscribe to Feed

WordPress Fatal error: Out of memory

This is a common error message thrown in when someone tries to view your WordPress-driven blog/site. This also happens while you are in the middle of doing some work on the admin interface or writing your entry and saving it.

The reason is that some activity in the back end is eating up the memory allotted by the server set up for PHP processes and/or MySQL database operation. It may be due to multiple processes trying to operate simultaneously.

Now to the remedy:

There are several fixes suggested in different blogs. Most of them talk about either modifying the php.ini file in the PHP installation on the server or tweaking the wp-settings.php in the WordPress core.

While 99% of the WordPress users are in a shared hosting environment, access to php.ini file of the host set up is out of question. so forget about it.

Let s now discuss various types of remedies obtained through a Google search.
Audio Visual Junkie focuses on the flooding of “wp_options” table in the database with entries like “rss_f07b6018d7bc77b2520b5ec4296f3e66_ts” which seemed to cause the memory problem. It also feels that certain plugins cause such bloating of the table.

The blog suggested complete flushing of such entries out of the options table, by running this SQL query:

DELETE FROM `wp_options` WHERE `option_name` LIKE “rss_%”

Though there is a word caution expressed since such indiscriminate removal of all options starting with RSS would cause your blog’s feeds being not valid. Mittineague had suggested use of “Clean Options Plugin” for judicious removal of such unwanted entries in options table.

Narfstuff suggests a few sane ways to get into the root of the problem. One of them is to divine what exactly the memory limit allotted by the web host for PHP based processes by creating a phpinfo.php file with the snippet as follows:

and placing it in the root directory. When called through the browser, it will display the entire PHP and MySQL environment. Search for the value against “memory_limit”. If it shows more than 64MB, you are good. Most good web hosts allot 128MB. But this will not help prevent throwing up of error when one of your WordPress processes consume even 2.5 MB because of various other parameters coming into play while executing WordPress commands which have not been explicitly stated anywhere! But it may be due to the server overload at the time of taking backups etc.

Narfsurf also analyses the generic issues thus:

Test to see whether there is any improvement after:

* Taking Plugins Offline.
* Switching large sections of the site onto ‘Draft’ mode (i.e pages with large quantities of sub-pages).

It is worth pointing out that whilst low PHP memory can be the root of rendering problems, it can also be the case that a badly written plugin or modification to WordPress’ core code may munch its way through vast swathes of system RAM. It’s important to make certain that any code is well formed and written, before placing blame on the package’s low memory.

When reducing WordPress’ memory footprint, there’s a few tricks that can help us to make progress. Converting tags such as bloginfo(’template_directory’) to their hard coded counterparts can help reduce system load, and Disabling plugins which aren’t core to the operation of the site.

Perishable Press has come up with a few solutions like assigning a higher value to the memory_limit parameter in .htaccess file and php.ini files in specific directories where the problem occurs.

My web host, the friendly did a Goggling on my behalf and came up with this web site containing a solution to the memory_limit problem.

The site suggests tinkering with wp-settings.php file which is part of the WP core which will get overwritten on every upgrade, which is of course, once in a couple of months. Hence it is not a desirable solution. But you can find a cue from that suggestion. To wit, the lines of code in wp-settings.php that is asked to be changed reads thus:

if ( !defined('WP_MEMORY_LIMIT') )
define('WP_MEMORY_LIMIT', '32M');

It reads that if the memory limit had NOT been defined (negativity indicated by the “!” sign), define it now. The default value is 32MB. It can be increased to 64 or even 128 MB depending on your choice and what your web host allows.

Hence the best option would be to define it in the first place as enumerated in the following FAQ offered by MichaelH:

Fatal error: Allowed memory size of xxxxxxxx bytes exhausted
If deactivating plugins doesn’t work try one of these methods for increasing the amount of memory a PHP script may consume

1. If you have access to your PHP.ini file, change the line in PHP.ini
If your line shows 32M try 64M:
memory_limit = 64M ; Maximum amount of memory a script may consume (64MB)

2. If you don’t have access to PHP.ini try adding this to an .htaccess file:
php_value memory_limit 64M

3. Try adding this line to your wp-config.php file:
Increasing memory allocated to PHP
define(‘WP_MEMORY_LIMIT’, ’64M’);

4. Talk to your host.

As for me I did item no. 2 and 3 and did talk to the host who was very helpful. So far so good!

(Picture courtesy: Austin Passy.)

Tags: , , , , , , , , ,

5 Responses to “WordPress Fatal error: Out of memory”

  1. The Frosty says:

    Thanks for the little write up.
    I’ve seemed to get passed the memory issue and have now come to an new “IO error” in every upload, including simple small photos. Oh well, guess it will never be perfect.

  2. Thank you for this. Few of my clients got this error.
    It seems that this often appear on the same web hosts.

  3. Sie finden unsere Station im Zentrum der Stadt, direkt neben der Sparda Bank am
    Zehmeplatz 11a und nur 800m vom Bahnhof entfernt.

Leave a Reply

Copyright © HyperCircle 2009 | Powered by Wordpress | Designed by Elegant Themes