Out of memory on a WordPress server, or what to do about php memory_limit
Today, logging into the blog admin, I got this error:
Allowed memory size 67108864 bytes exhausted (tried to allocate 139650 bytes) ../class.wp-scripts.php on line 154
The blog itself works, but I can’t get into the admin. Since it’s hosted on shared hosting, on a free account no less, I got a bit worried — I suspected I wouldn’t be able to raise the php memory limit.
There are a few options for situations like this:
- Raise
php_memory_limitin.htaccess:php_value memory_limit 128M
Unfortunately this might not work if your host’s apache config has AllowOwerride none
- Raise
php_memory_limitfrom php itself. Add this line toindex.php:ini_set('memory_limit', '128M');
The annoying part: if your host has safe_mode enabled in php, this option won’t help either.
- Add the following to
wp-config.php:define( 'WP_MEMORY_LIMIT', '128M' );
Log into the admin and enjoy life. Maybe disable a couple of plugins while you’re there.