Sometimes when you try to finish a normal action in WordPress like activating a plugin, you get a message similar to this:
Fatal error: Allowed memory size of 157286400 bytes exhausted (tried to allocate 5775295 bytes)
If you are using a plugin that consumes a lot of resources like WooCommerce, or if your host is a bit stingy with resources, you are likely to find that error.
This means that PHP, the language used by WordPress, needs to use more memory to complete the task you just tried.
The solution is to increase the amount of memory allocated to PHP.
There are some ways to do this, and you may or may not be limited by your host: in this case, if the following solutions do not work, you need to talk to them. If you put your memory to the maximum and you still have problems, the reason could be a problematic plugin or a code badly done in your theme.
Make sure you are using an updated version of PHP because the older ones are less efficient.
WooCommerce recommends at least 64M. You can increase this amount until you complete the task that caused the error message.
To increase the memory limit for the admin area:
define( 'WP_MAX_MEMORY_LIMIT', '256M' );
If you see that defining the limit in your wp-config file does not help, you may have to go to a higher level – that is, your PHP configuration file, known as php.ini.
Depending on your host, you may not have access to this file, and you may not be able to create your own file. Search the documentation of your hosting provider for the file php.ini and you should understand where to find the file.
Then add or adjust the following line:
memory_limit = 128M ; Maximum amount of memory a script may consume (128MB)
If you do not have access to the php.ini file, sometimes you can directly use the .htaccess file to configure the memory limit:
php_value memory_limit 128M