Fixing “Allowed memory size exhausted” Error in WordPress

Posted on Sunday 16 December 2007

After my web host tried to upgrade Apache, but ran into a cPanel/WHM bug and had to go back to the old Apache version, I suddenly had a WordPress install that wasn’t working right. I would get the following error whenever I tried to get to any page in the administration end of things:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 55431 bytes) in /home/sitedir/public_html/wp-includes/plugin.php on line 158

My theory is that some default PHP memory limit was changed, but they didn’t respond to my support forum post asking about that. So I had to troubleshoot it myself. Luckily, it wasn’t hard to fix, and here’s what I did.



First, I had to figure out which plug-in was causing the problem. Since I couldn’t try disabling plugins from within Wordpress, since I couldn’t load that screen, I used the FileZilla FTP client (a great little free FTP client for Windows, by the way) and moved plugins out of the wp-content/plugins directory one by one to see if the site started working. You could also just use cPanel’s built-in file manager, or an SSH session, or something like that. The cPanel file manager is kind of a pain to move things around in, though, so I wouldn’t recommend it.

Eventually I found that it was the aLinks plugin that was causing the problem. I decided to tell it to use a higher PHP memory limit than the 8MB default that it seemed to be hitting, so I added this line to the beginning of the main plugin file:

ini_set(”memory_limit”,”12M”);

And that fixed it. aLinks now has 12MB to work with, which is enough. If it still hit the memory limit, you can try increasing the limit to higher and higher levels and see if that fixes it, although at some point you need to figure out if you need a more efficiently written plugin, rather than just wildly increasing the memory limit. (Although in today’s Vista world, that doesn’t seem to be a popular approach. Even my beloved Adobe CS3 suite has gotten crazy with memory usage. 12 MB sounds tiny by comparison… But now I’m close to ranting about ridiculous memory requirements, so I’ll just shut up.)

No comments have been added to this post yet.

Leave a comment

(required)

(required)


Information for comment users
Line and paragraph breaks are implemented automatically. Your e-mail address is never displayed.


RSS feed for comments on this post | TrackBack URI