Allowed memory size of 805306368 bytes exhausted (tried to allocate 20480 bytes) in GenericHeader.php line 54. Magento2.3

Allowed memory size of 805306368 bytes exhausted (tried to allocate 20480 bytes) in GenericHeader.php line 54. Magento2.3

September 16, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Allowed memory size of 805306368 bytes exhausted (tried to allocate 20480 bytes) in GenericHeader.php line 54. Magento2.3

Solving Allowed memory size exhausted Error in Magento 2.3

Are you facing an annoying “Allowed memory size of X bytes exhausted” error while working on your Magento 2.3 installation? I know how frustrating this can be, especially when it seems like increasing the memory limit isn’t helping.

Let’s dive into understanding and resolving this issue step-by-step:

Understanding the Error

The error message “Allowed memory size of 805306368 bytes exhausted (tried to allocate 20480 bytes)” essentially means that Magento is running out of memory allocated for PHP execution. This usually happens due to complex data operations or extensions that require more resources.

Why Increasing Memory Limit Doesn’t Work

When you increase the memory limit in your php.ini file, you’re setting a global limit for all PHP processes running on your server. However, Magento uses different PHP processes for its backend and frontend operations.

In your case, increasing the limit to 5000M might not be enough because:

  • The error occurs during specific operations like checkout or logout.
  • The memory limit in php.ini is only applied to the main PHP process.

Step-by-Step Solution

1. Check Your Magento Configuration

First, ensure that your Magento configuration file (app/etc/env.php) has the correct memory setting for the frontend and backend:

'MAGE_MODE' => 'default',
'MAGE_DEPLOYMENT_CONFIG' => 'default',
'MAGE_IS_DEVELOPER_MODE' => '0',
'MAGE_PROFILER' => 1,
'IS_MAGENTO_ENGINE_ACTIVE' => true,
'MAGE_RELEASE_VERSION' => '2.3.7-p1',
'MAGE édition' => 'CE',
'MAGE_BUILD_DATE' => 'Fri Mar 8 05:46:09 UTC 2019',
'PHP_SELF' => '/vendor/magento/framework/Interception.php',
'SERVER' =>
array (
  'HTTP_HOST' => 'laravelcompany.com',
  'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4386.62 Safari/537.36 OPR/75.0.3969.93',
  'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.5',
  'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
),
'SERVER_NAME' => 'laravelcompany.com',
'SERVER_PORT' => 443,
'SERVER_ADDR' => '127.0.0.1:8000',
'SERVER_SOFTWARE' => 'nginx/1.15.9',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'SERVER_SIGNATURE' => '',
'SERVER_SIGNATURE_LARGE' => '',
'SERVER_ENVIRONMENT_NAME' => 'dev',
'server_api' => 'Drupal'
),

Ensure that the memory settings are set accordingly:

'memory_limit' => '2G',
'memory_limit_frontend' => '1G',
'memory_limit_backend' => '1G',
'memory_limit_amqp' => '1024M',
'memory_limit_amqp_quickly' => '512M',
'memory_limit_aop' => '196M',
'memory_limit_batch' => '256M',
'memory_limit_gurobi' => '1G',
'memory_limit_mysql' => '1024M',
'memory_limit_phpserver' => '1024M',
'memory_limit_sales' => '256M',
'memory_limit_search' => '256M',
'memory_limit_setup' => '1G',
'memory_limit_soap' => '256M',
'memory_limit_testing' => '1024M',
'memory_limit_xmlconnect' => '256M',
'memory_limit_api' => '256M',
'memory_limit_integration_api' => '256M',

2. Optimize Your System

Before diving into code changes, let’s ensure your system is optimized:

  • Upgrade PHP to the latest version (7.3 or higher).
  • Enable OPcache and increase its memory allocation.
  • Use a good quality hosting provider with sufficient resources.

3. Identify the Culprit Extension

The error message points to GenericHeader.php in the Zend Framework library. This is likely being triggered by an extension or customization that’s causing excessive memory usage during specific operations.

To verify this, try disabling all third-party extensions temporarily and see if the issue persists:

  • Navigate to Stores > Configuration > Advanced.
  • Click on Disable Modules By Code.
  • Enter all and click Save Config.

If the error stops appearing after disabling all extensions, you can re-enable them one by one until you find the problematic extension.

4. Optimize PHP Configuration

Update your php.ini file with these settings:

memory_limit = 2G
max_execution_time = 18000
max_input_vars = 50000

Remember to replace 2G with a value that’s suitable for your server’s available memory.

5. Use Object Manager and Indexes

Ensure that the Object Manager is enabled and properly configured. Also, check if you have missing or outdated indexes in your database. Outdated indexes can significantly slow down Magento operations.

Conclusion

Resolving “Allowed memory size exhausted” errors in Magento requires a systematic approach. Start by optimizing your system configuration, identifying problematic extensions, and fine-tuning the PHP settings.

Remember to test each change thoroughly before deploying to a production environment. If the issue persists after following these steps, consider reaching out to Magento support or engaging professional help for further investigation.

Happy coding!

Magento 2 Checkout Extensions Admin

Our network