Get rid of fatal errors while activating plugins
Written on Tuesday, 28th August 2007 . Permalink Jump to Comments
Tags: WordPress Plugins, WordPress Tips and Tricks
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.
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.
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
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.
Popularity: 2% [?]
Get the latest updates from Techie Buzz directly in your inbox. Subscribe now.















Just tried that solution Britt commented. Plugin activated, script worked, blog updated.
One plugin didn’t reactivate, though. But no big.
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