WordPress Out-​​of-​​Memory Fix

wordpress logo

I’ve been making some changes to this site recently: upgrading to the newest version of WordPress, choosing a new theme and fiddling with the layout.

One thing I dis­covered is that, unless you’re running a very minimal install­a­tion, it’s quite easy to run out of memory, even with only a handful of plug-​​ins. Versions of the software have become slightly larger since WordPress 2.6 or so, plus plug-​​ins have become more ambi­tious, not to mention the increased usage of rich content like videos and AJAX transitions.

Every time I tweaked some­thing, I ended up with blank pages and an error message like this:

Fatal error: Allowed memory size of X bytes exhausted (tried to allocate X bytes) in /​home /​Your-​​Username/​public_​html/​ the par­tic­ular folder on line X

I searched around for quite some time for advice, and tried each of the fol­lowing, before ending up at a working solution. They didn’t work for me, but I’ll leave them here since they might prove useful for someone else. Please be very careful, though: some of these ‘handy tips’ will break your entire site.

1) De-​​activating all but the most essen­tial plug-​​ins. This is probably good house­keeping advice all-​​round, but didn’t actually make a lot of dif­fer­ence. The basic install was using 26MB of the 32MB alloc­ated; with a full suite of plug-​​ins it was just over 28MB. Add some users, and you’ll quickly run out of memory — the extra 2MB from dis­abling plug-​​ins didn’t make enough difference.

2) Alter the value of php_​value memory_​limit in your .htaccess file. Doing this broke the whole site: YMMV.

3) Optimise your database tables using phpMy­Admin. Saved about 200KB. Woop.

4) Adding the line “memory_​limit = 64M” in my php5.ini file. Made no dif­fer­ence one way or another.

What actually worked was this.

Open wp-config.php and find this bit:

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

Change it so that it reads like this:

/** Sets up WordPress vars and included files. */
define('WP_MEMORY_LIMIT', '64M');
require_once(ABSPATH . 'wp-settings.php');

Touch wood, that’s done the trick. The site’s still as slow as molasses, of course, but at least I’m not running out of memory.

Share this post:

Digg This
Reddit This
Stumble Now!
Buzz This
Share on Facebook
Bookmark this on Delicious
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Possibly related:

6 comments to WordPress Out-​​of-​​Memory Fix

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>