Allowed memory size of 792723456 bytes exhausted at Magento 2 extension installation

When you install a fresh Magento 2 system, you might encounter a nasty error when you would like to install additional extensions for your magento 2 setup. The error shows on the Magento console first:

Check Component Dependency. We found conflicting component dependencies.

In my case this error was related to the fact that the system has run out of memory while it was checking the component dependencies. The Apache error log contained the following:

[Thu Aug 15 17:21:35.703406 2019] [php7:error] [pid 5918] [client 192.168.0.101:63386] PHP Fatal error:  Allowed memory size of 792723456 bytes exhausted (tried to allocate 4096 bytes) in /var/www/html/vendor/composer/composer/src/Composer/DependencyResolver/RuleSetGenerator.php on line 129, referer: http://192.168.0.85/setup/

[Thu Aug 15 17:21:35.712310 2019] [php7:error] [pid 5918] [client 192.168.0.101:63386] PHP Fatal error:  Allowed memory size of 792723456 bytes exhausted (tried to allocate 45056 bytes) in /var/www/html/vendor/magento/framework/Session/SessionManager.php on line 150, referer: http://192.168.0.85/setup/

[Thu Aug 15 17:21:35.723690 2019] [php7:error] [pid 5924] [client 192.168.0.101:63388] PHP Fatal error:  Uncaught Exception: Warning: session_start(): Failed to decode session object. Session has been destroyed in /var/www/html/vendor/magento/framework/Session/SessionManager.php on line 206 in /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61\nStack trace:\n#0 [internal function]: Magento\\Framework\\App\\ErrorHandler->handler(2, 'session_start()...', '/var/www/html/v...', 206, Array)\n#1 /var/www/html/vendor/magento/framework/Session/SessionManager.php(206): session_start()\n#2 /var/www/html/generated/code/Magento/Backend/Model/Auth/Session/Interceptor.php(167): Magento\\Framework\\Session\\SessionManager->start()\n#3 /var/www/html/vendor/magento/framework/Session/SessionManager.php(140): Magento\\Backend\\Model\\Auth\\Session\\Interceptor->start()\n#4 /var/www/html/vendor/magento/module-backend/Model/Auth/Session.php(101): Magento\\Framework\\Session\\SessionManager->__construct(Object(Magento\\Framework\\App\\Request\\Http), Object(Magento\\Framework\\Session\\SidResolver\\Proxy), Object(Magento\\Backend\\Model\\Session\\AdminC in /var/www/html/vendor/magento/framework/App/ErrorHandler.php on line 61, referer: http://192.168.0.85/setup/

[Thu Aug 15 17:21:35.726328 2019] [php7:error] [pid 6010] [client 192.168.0.101:63389] PHP Fatal error:  Uncaught Exception: Warning: session_start(): Failed to decode session object. Session has been destroyed in /var/www/html/vendor/magento/framework/Session/SessionManager.php on line 206 in /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61\nStack trace:\n#0 [internal function]: Magento\\Framework\\App\\ErrorHandler->handler(2, 'session_start()...', '/var/www/html/v...', 206, Array)\n#1 /var/www/html/vendor/magento/framework/Session/SessionManager.php(206): session_start()\n#2 /var/www/html/generated/code/Magento/Backend/Model/Auth/Session/Interceptor.php(167): Magento\\Framework\\Session\\SessionManager->start()\n#3 /var/www/html/vendor/magento/framework/Session/SessionManager.php(140): Magento\\Backend\\Model\\Auth\\Session\\Interceptor->start()\n#4 /var/www/html/vendor/magento/module-backend/Model/Auth/Session.php(101): Magento\\Framework\\Session\\SessionManager->__construct(Object(Magento\\Framework\\App\\Request\\Http), Object(Magento\\Framework\\Session\\SidResolver\\Proxy), Object(Magento\\Backend\\Model\\Session\\AdminC in /var/www/html/vendor/magento/framework/App/ErrorHandler.php on line 61, referer: http://192.168.0.85/setup/

The solution to this issue is to raise the memory limits which would be an easy one if it wasn’t defined at least at 2 location.

First edit the relevant section of the php.ini make sure you are editing the one that is used by the apache2 server. If you are using ubuntu it is usually in the following location:

/etc/php/[version]/apache2/php.ini

Change the memory_limit variable to 2048M from 756M

memory_limit = 2048M

Then open the .htaccess file from your magento root directory and change the memory_limit variable to 2048M from 756M. Be aware that this parameter is defined TWICE in the .htaccess file so change the value in BOTH locations then restart the apache2 server

service apache2 restart

Create the phpinfo.php file in your magento root directory if you don’t already have it. Just create the file and paste the one line shown below in it, then save it.

Now go to your base server url plus the phpini.php file like:

http://192.168.0.85/phpinfo.php

Once the page is open navigate to the memory limit section and check if the settings have changed

The local and master value should both show 2048M.

This solution has solved my issue if you have less memory at your server you might want to experiment with gradually increasing the memory from 756M to 1024M, etc and see if it works with the new amount.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.