Does your WordPress site show a message similar to this?
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 19456 bytes) in wp-admin/includes/theme.php on line 81
If your answer is "yes", 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.
Before starting to read this guide, it's worth understanding what PHP errors are in WordPress.
Background Information About PHP Memory Limit
PHP Memory limit sets the maximum amount of memory in bytes that PHP allows to allocate to a script. This prevents 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 plugin. If you're at 32 or 64 M limit, that should be more than enough.
If you set it to 128 M and still getting the error, then you for sure know it's due to a faulty plugin. So the key question is what plugin did you install prior to this?
Things to Try
- Try adding this line to your wp-config.php file:
- 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)
- If you don't have access to PHP.ini try adding this to an .htaccess file:
php_value memory_limit 128M
- Talk to your host.
Plugin for Keeping Track of Memory Usage
Use the TPC! Memory Usage plugin to track the memory usage in your WordPress.
TPC! Memory Usage allows WordPress administrators to view the current and peak memory usage of the application. This is extremely helpful when testing new plugins, or if there are a lot of modifications, plugins, or large language files. As of version 0.4, administrators now have the ability to view detailed system information about their web server, MySQL, PHP, and WordPress software. Chris Strosser"