Get rid of fatal errors while activating plugins

by Keith Dsouza | Translate | Print
Tuesday, 28th Aug 2007 | Share




I have recently received a few complaints about users receiving fatal errors while activating plugins. Though this can basically be caused by two things one of them being a faulty plugin itself in which case you will get some error description along with line number etc in the plugin file.

The other reason could be no fault of either WordPress or the plugin itself but the amount of memory available to PHP for executing scripts. In such cases while activating a plugin you may come across fatal errors relating to high memory usage, a error similar to the one below.

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 46080 bytes) in /var/www/html/wordpress/wp-admin/admin- functions.php on line 864

In such cases it simply means that the memory size to execute this script has been exhausted and the engine cannot allocate more memory for the script to run.

How can you determine the amount of memory allocated?

There are several ways in which you can do that. I will list out the three basic ways in which you can do it. The first and most simple one is creating a simple PHP file and adding the code as shown below to it.

php-info-image

Once you have added the code save the file as test.php or whatever name you would like to give it and upload it to your web server using FTP. Once you have done that you can load the file in your browser. Once you have loaded the file you will see information about PHP that is running on your server. To find the exact amount of memory allocated to run PHP scripts you will need to find the text “memory_limit” without the quotes.

php-memory-limit

Many a sites do not allow you to run the the above code on the server so as a workaround you may try with the following code

php-echo-ini

Running the following code would return you with a out put of “The memory limit is 16M”.

The last and most advanced way to know this is information is looking into the php.ini file and finding the setting “memory_limit” without the quotes. If nothing works then you will have to contact the server administrator to know how much memory is allocated for running and executing PHP scripts.

How to fix this errors?

Many web sites are run on shared servers so in that case the best thing is to contact the system administrator asking them to increase the memory limit.

One of my readers Britt Malka has also suggested an alternate way to get rid of this problem but I am not sure if it works and have not tested it yet.

You can view the solution Britt used in the comments here.

If you know of any other solution please post it in the comments and let the readers know about it.

Liked this post? Have a Question? Comment and share your opinions and views with us

Get Regular Updates. Subscribe to Free RSS Feeds or Email Updates. Click to expand subscription options

3 Responses so far | Leave Your Comments

Comments are moderated. Please try and stay on topic. Please do not use abusive language, if you think there is a problem, please email the post author or use the contact us form to tell us about it.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  1. Dave Zan
    August 28th, 2007 at 9:54 pm #

    Just tried that solution Britt commented. Plugin activated, script worked, blog updated. :)

    One plugin didn’t reactivate, though. But no big.

    Reply to this comment

  2. Robert Bartlett
    August 29th, 2007 at 5:04 am #

    Hey Keith,

    I recently went through a three week hunt trying to fix that exact error.

    Thing is, I run my on linux server, so I could manually set the limit myself. Once I got to 96M though… I figured, it wasn’t really a memory error, so I began looking at other things.

    After considerable research, pain, and agony on my part (one of the blogs affected was my wife’s, hence “pain, and agony”), I started suspecting that it wasn’t PHP, or permissions, or files or anything so easy to fix, or easy to find.

    I had recently moved my blogs from another host, and used the Wordpress export tool to move them to my new host. As it turns out, for some reason, the new database tables created with the export (upon importing) didn’t have “autoincrement” enabled on the primary index keys of the tables in the database… Once I added it, “voila!” Everything worked as expected again.

    So, to make this long comment even longer, it seems that whilst the memory error was probably an accurate error message (I’m sure WP just churned and churned trying to pull some record from some table), it seems that the REAL reason this was happening, was an improperly configured database.

    Anyways, just wanted to pass that on to someone… somewhere. Maybe it’ll help somebody.

    Thanks for your blog!

    Robert

    Reply to this comment

  3. Nimwit
    April 16th, 2009 at 2:29 am #

    Thanks for the post. I use Dreamhost and they have a 90MB limit but when I activate all the plugins I get the 500 & 503 errors too.

    There is another blog that talks about this issue at http://php-memory-and-wordpress.iamuk.co.uk should anyone want to read more (this is not my blog!)

    N.

    Reply to this comment