The out of memory error is a common problem encountered by WordPress users. It appears when your WordPress script tries to use more memory than allowed by your server settings. Here are some solutions to help increase your PHP memory limit to avoid this error.
1. Increase PHP memory limit via wp-config.php file
The simplest solution is to increase the PHP memory limit directly in the WordPress configuration file – wp-config.php. This file is located in the root directory of your WordPress installation. Open this file with any text editor and add the following line of code:
define('WP_MEMORY_LIMIT', '256M');
This line of code increases the memory limit to 256 MB, which is usually enough for most websites. You can set a higher value if your site is more demanding.
2. Change PHP memory limit using .htaccess file
If changing wp-config.php did not bring the desired effect, you can try increasing the PHP memory limit using the .htaccess file. It is also located in the main WordPress directory. Open this file in a text editor and add the following lines of code:
php_value memory_limit 256M
As before, you can adjust the 256M value to suit your site's needs.
3. Increase the memory limit using the php.ini file
If the above methods do not work, the problem may lie in the PHP settings on the server. In this case, you need to increase the memory limit using the php.ini file. Open this file in a text editor and find the line containing “memory_limit”. Change the value to 256M or higher.
4. Use a WordPress plugin to increase your memory limit
If you are not confident in your ability to edit configuration files, you can use a plugin to increase your memory limit. The “WP Memory Limit” plugin is one such tool that makes this process easier.
5. Contact your hosting provider
If none of the above methods work, most likely your hosting cannot be configured to increase the PHP memory limit. In this case, contact your hosting provider and ask them to increase the PHP memory limit.
Remember that increasing the PHP memory limit is only a temporary solution. If your website is constantly sucking up a lot of memory, you should identify and fix the problem. This may require optimizing your website, updating your plugins, or changing your theme.