Monday, June 11, 2012

WordPress - Fatal error: Allowed memory size of bytes exhausted



If you get a WordPress Fatal Error message similar to: Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 19456 bytes) in wp-admin/includes/theme.php on line 81 then this tutorial is for you. We've helped several of our students with similar issues so we decided to write a tutorial to hopefully help someone else out as well.

Background Information About Memory Limit

Memory limit sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server.
In most cases if you get a memory limit error it's due to a faulty addon. If you're at 32 or 64 M, that should be more than enough. If you set it to 128 M, and it's still getting the error, then you for sure know it's a faulty addon. So the key question is what addon did you install prior to this?

Things to Try

Here are some things to try in this order:
1. Try adding this line to your wp-config.php file:
define('WP_MEMORY_LIMIT', '128M');
2. If you have access to your PHP.ini file, change the line in PHP.ini
If your line shows 32M try 128M:
memory_limit = 128M ; Maximum amount of memory a script may consume (128MB)
3. If you don't have access to PHP.ini try adding this to an .htaccess file:
php_value memory_limit 128M
4. Talk to your host.

Plugin for Keeping Track of Memory Usage

You can use TPC! Memory Usage to keep track of the memory usage in WordPress:
http://wordpress.org/extend/plugins/tpc-memory-usage/

0 comments:

Post a Comment