Site icon Bajorat Media

WordPress Memory Limit: "Fatal error: Allowed memory size of X bytes exhausted..."

WordPress Memory Limit: Fatal error: Allowed memory size

In this article we would like to explain the origin and the solution of a frequently occurring error message related to the WordPress Memory Limit explain. 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 said WordPress Memory Limit error message could be for example as follows:

Fatal error: Allowed memory size of 654321 bytes exhausted (tried to allocate 12345 bytes) in /var/www/domain.com/wordpress/file.php on line 123

While the bytes value, the file path and the line where the error occurs may vary, the underlying cause remains the same. Below we will explain 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" that specifies 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, thus ensuring 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 frontend or backend of WordPress wants to show you the following problem:

The currently running script (WordPress incl. the active theme and all plugins) tries to allocate more memory than allowed in the settings. In most cases, these settings are set by your web host.

Causes of the WordPress Memory Limit Error

The error occurs when your WordPress system wants or needs to use too much RAM. The memory requirement increases with each plugin you install and use in your WordPress system. Also depending on the theme you choose, different memory usage can occur.

In addition, you may experience memory-intensive operations directly in WordPress, such as bulk content editing or image editing and creation.

The long term solution for the WordPress / PHP memory limit problem

The typical solution for too little memory is to upgrade the system. In many cases, with a shared web hosting package, you actually have no choice but to upgrade the package or change the web host completely.

However, before you do that, you should try the following ways to increase PHP / WordPress memory limit:

Change the PHP memory_limit Setting: If you have your own root server, VPS or shared hosting with appropriate rights, you can set the PHP memory limit using the php.iniYou can increase the amount of memory directly via PHP (e.g. in wp-config.php) or via an .htaccess file on Apache web servers. Convert the byte value from the error message into MB to find out how much memory you are missing and to which value you have to increase. The following 128 MB is just an example.
In the PHP configuration file "php.ini" look for the corresponding line and adjust it (if necessary it is commented out at the beginning by a ; (semicolon)):

memory_limit = 128M;

Or add in your wp-config.php directly after the beginning <?php tag the following:

@ini_set('memory_limit', '128M');

Alternatively, in the wp-config.php also the following entry for the WordPress memory limit can be set:

define('WP_MEMORY_LIMIT', '128M');

Or in the .htaccess:

php_value memory_limit 128M

In some cases, the above memory adjustments can help and make the system run again.

Especially for extensive store systems with WooCommerce, a WordPress system can need between 512 MB to 1024 MB of PHP memory limit.
If your system is still on strike even with 1024 MB memory limit, it is urgently recommended to check the components and plugins, because the memory consumption is then in a disproportionately high range.

This can be normal for single actions or mass processing in the backend, but should never be necessary as a default value for the frontend. In that case, the high memory limit value would be an indicator of a poorly optimized system.
For comparison, the WordPress core system usually comes with a PHP memory limit of just 32 MB without any problems. Everything beyond that is usually occupied by theme and plugins.

Short-term solution options

If the long-term solution approaches don't help, you can try to reduce storage requirements in the short term.

Here are some suggestions:

define('WPLANG', 'en_US');

Since most of the WordPress plugins as well as the WordPress system itself are originally in English, this conversion does not require loading the translation files.

The memory that has now been freed up is often sufficient to get the system running again at full capacity.

As soon as the system is running again, you can check at your leisure whether the memory can possibly be increased, as described previously.

Summary

The "Fatal error: Allowed memory size exhausted" in WordPress occurs when the system tries to allocate more memory than allowed (PHP or WordPress Memory Limit). This article has presented you both long term and short term solution options to fix this problem. A long-term solution is to increase the memory_limit or change the web host or hosting package. Short-term solutions can be disabling plugins or turning off translations. Try the presented solutions and get your WordPress system working again.

If you continue to have problems with your WordPress website, our Developer gladly with advice and support. Simply contact us.

Exit mobile version