WordPress allows you to run as many plugins as you like. Therefore, it’s not really surprising to get this dreadful error:
Fatal error: Allowed memory size of 805306368 bytes exhausted (tried to allocate 130023440 bytes) in /wp-content/plugins/somewhere.php on line X
Why this error?
PHP runs WordPress, your theme and your plugins. Basically, everything that makes your website. To avoid issues, the server only allows a certain amount of memory to be used by PHP for each task. If you encounter this error, it means that a task (such as a visitor going on your website) required too much memory, and the server halted it.
This allowed memory size is in bytes, so for clarity, this might be helpful.
- Allowed Memory Size of 8388608 Bytes Exhausted = 8 MB
- Allowed Memory Size of 16777216 Bytes Exhausted = 16 MB
- Allowed Memory Size of 33554432 Bytes Exhausted = 32 MB
- Allowed Memory Size of 67108864 Bytes Exhausted = 64 MB
- Allowed Memory Size of 134217728 Bytes Exhausted = 128 MB
- Allowed Memory Size of 268435456 Bytes Exhausted = 256 MB
- Allowed Memory Size of 536870912 Bytes Exhausted = 512 MB
- Allowed Memory Size of 1073741824 Bytes Exhausted = 1 GB
How to fix it?
There are many ways, but you should consider them in order.
Disable or Remove Plugins
This is probably the first thing you should try; have a look at your Plugins list, and try to disable the ones you don’t really need. Not only you will get rid of this error, but you will make your WordPress faster.
Optimize WordPress (Options & PHP)
If you really need all your plugins, take some time to check the options for each of them; maybe you could avoid some heavy processing? Also, make sure you are using a recent version of PHP (nowadays, PHP 7 is a must).
Increase the PHP Memory Limit
That’s the easiest (and laziest) solution. You should only do this after you really tried to optimize your WordPress install. You can increase the memory limit in your WordPress by adding this line in the wp-config.php.
define( 'WP_MEMORY_LIMIT', '256M' );
You can also try 512M but you shouldn’t go above that.
Contact your Hosting Service
If you can’t change your PHP version or your PHP Memory Limit by yourself (or maybe it doesn’t seem to be possible), you should contact your hosting service.