Bajorat Media
WordPress Memory Limit: “Fatal error: Allowed memory size of X bytes exhausted…”
WordPress Memory Limit: Fix WordPress error “Fatal error: Allowed memory size exhausted” with this tutorial.
In this article we would like to explain the origin and solution to a common error message related to WordPress Memory Limit. This error message often appears in the backend of WordPress (but can also affect the frontend) and can make the system partially or even completely unusable. The WordPress Memory Limit error message in question could e.g. E.g. as follows:
Fatal error: Allowed memory size of 654321 bytes exhausted (tried to allocate 12345 bytes) in /var/www/domain.de/wordpress/file.php on line 123
While the bytes value, file path, and line where the error occurs may vary, the underlying cause remains the same. Below we will tell you why this error occurs and how to fix it.
What does the WordPress Memory Limit error message mean?
WordPress is based on the scripting language PHP (PHP: Hypertext Preprocessor, originally Personal Home Page Tools). In the PHP configuration file there is a value called “memory_limit” which sets the memory limit that a PHP script is allowed to use during its execution. This setting is intended to protect the server from memory overflow and thus ensure the stability of the web server. Strictly speaking, we are not talking about the WordPress memory limit, but the PHP memory limit, which is exceeded by WordPress. The error message that appears in your WordPress frontend or backend would like to show you the following problem: The currently running script (WordPress including the active theme and all plugins) is trying to reserve more RAM than is allowed in the settings. In most cases, these settings are determined by your web host.
Causes of WordPress Memory Limit Error
The error occurs when your WordPress system wants or needs to use too much memory. The memory requirement increases with every plugin you install and use in your WordPress system. Depending on the chosen theme, different memory usage can occur. In addition, memory-intensive processes can occur directly in WordPress, e.g. B. when mass editing content or editing and creating images.
The long-term solution to the WordPress / PHP memory limit problem
memory_limit = 128M;
Or add the following in your wp-config.php directly after the beginning <?php tag:
@ini_set(‘memory_limit’, ‘128M’);
Alternatively, the following entry for the WordPress memory limit can be set in wp-config.php:
define(‘WP_MEMORY_LIMIT’, ‘128M’);
Or in the .htaccess:
php_value memory_limit 128M
In some cases, the memory adjustments mentioned above can help and make the system operational again. Especially with extensive shop systems with WooCommerce, a WordPress system can require between 512 MB and 1024 MB of PHP memory limit. If your system still fails even with a 1024 MB memory limit, we strongly recommend checking the components and plugins, as the memory consumption will then be disproportionately high. While this can be normal for individual actions or bulk editing in the backend, it should never be necessary as a default value for the frontend. In this case, the high memory limit value would be an indicator of a poorly optimized system. For comparison: The WordPress core system usually gets by with a PHP memory limit of just 32 MB without any problems. Anything beyond that is usually taken up by the theme and plugins.
Short-term solutions
If the long-term solutions don’t help, you can try reducing storage requirements in the short term. Here are some suggestions:
- Deactivating plugins: As a first step, switch off plugins that are not needed or can be dispensed with.
- Switching off the translations: Another option is to switch off the translations, as some of them require a lot of memory. To do this, open your wp-config.php and set the value of WPLANG to en_US. Alternatively, you can remove the constant completely or comment it out.
define(‘WPLANG’, ‘en_US’);
Since most WordPress plugins and the WordPress system itself are originally in English, the translation files no longer need to be loaded with this change. The memory that has now become free is often enough to get the system running to its full potential again. As soon as the system is running again, you can take your time to check whether the memory can be increased, as described above.
Summary
The “Fatal error: Allowed memory size exhausted” in WordPress occurs when the system tries to reserve more memory than is allowed (PHP or WordPress Memory Limit). This article has provided you with both long-term and short-term solutions to resolve this issue. A long-term solution is to increase the memory_limit or change web host or hosting package. Short-term solutions can include deactivating plugins or turning off translations. Try the solutions presented and get your WordPress system up and running again. If you continue to have problems with your WordPress website, we are at your service developer happy to help and advise. Simply contact us.