0

I'm trying to upgrade my Magento installation but experiencing problems with the process:

I was trying to update my site to the latest release as advised and I did so via the command line but I ran out of memory trying to do so.

Commands I ran were:

composer require magento/product-community-edition 2.2.3 --no-update
composer update

It was running fine but then a fatal error occurred:

Updating magento/magento2-base (2.2.2 => 2.2.3): Downloading (90%)
mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory

Fatal error: Out of memory (allocated 848302080) (tried to allocate 14680096 bytes) in phar:///usr/local/bin/composer.phar/src/Comp

Any ideas as my RAM allocation is fixed to 768? (I tried boosting it already). I'm trying to upgrade to 2.2.3 from 2.2.2.

Thank you so much for any advice you may have.

0

Try:

php -d memory_limit=2048M composer require magento/product-community-edition 2.2.3 --no-update

php -d memory_limit=2048M composer update

If this fails go for memory_limit=-1.

If you haven't linked composer to your users bash, then replace composer with $(which composer). It will return the path to the composer executable in your server. For example: /usr/local/bin/composer and the command will look like:

php -d memory_limit=2048M /usr/local/bin/composer require magento/product-community-edition 2.2.3 --no-update composer update

Same goes for php. If you got multiple php versions you should use the php7 version. Run $which php and it will return the paths that php in installed in. The parenthesis just execute the return as well so you can use them in commands like the one i gave you. Please do this with care. Open a second terminal and monitor your processes, try htop, for possible memory leaks(so you can kill the processes with kill $pid of the memory eating one).

As for the hard limit you face. What kind of webserver are you using and what php version/package for php code? What kind of values exist on your php.ini and if you are using php-fpm on your fpm-pool for this user?

Magento 2 example configurations for both apache and nginx set the value for memory limit via .htaccess, .user.ini or FastCGI memory_limit to 768 and might be overriding your values.

If you are on a shared hosting with many restriction then try this: find - /name php.ini Find the one that fits your php-version. Edit this file and set memory_limit=2048M or memory_limit=-1. DO NOT FORGET TO REVERT THE CHANGE AFTER YOU ARE DONE.

If you are using Apache then:

  • create a php.ini file in your Magento installation root folder(copy php's default we found above. cp /path/to/php7/etc/php.ini /path/to/magento/root/php.ini).

  • edit memory_limit value as said above.

  • create .htaccess file on your Magento installation root folder and add this line SetEnv PHPRC /path/to/magento/root/php.ini.

  • Hi Thanks for replying! So I'm using cpanel if that helps? Any command I run using PHP I have to do as /usr/local/php70/bin/php-cli While I'm technically able linux / magento are still fairly new to me and I'm not sure how to find any memory leaks using cpanel etc. – Rushed89 Mar 2 '18 at 11:13
  • We don't really care for cPanel at this point. Simply login to your server via ssh and navigate to your Magentos root path.This should be the directory that contains the var/ pub/ etc/ update/ lib/ generated/ directories and more. From there run: /usr/local/php70/bin/php-cli -d memory_limit=2048M $(which composer) require magento/product-community-edition 2.2.3 --no-update composer update – 1337_sanc Mar 2 '18 at 11:23
  • Let me know how it went or if you are still facing problems. – 1337_sanc Mar 2 '18 at 12:13
  • I think because I'm using a shared server setup I can't set PHP limits higher than 756 and I don't have the ability to install htop. All a bit of a mess really. I'm thinking maybe restating my php service might help and kill any mem leaks long enough for me to upgrade? – Rushed89 Mar 2 '18 at 12:28
  • Don't take the leaks statement for granted. I just mentioned it because in rare cases you might face one. This is a standard procedure you are about to do, i just had to let you know. Since this is a shared setup my scenario should never happen so just go for the command i gave you. Also restarting php would also kill the process as well and since it was a process you spawned manually without schedule it should not come up again. I think there was a certain tab on cpanel that you can monitor your processes aswell. – 1337_sanc Mar 2 '18 at 12:32
0

Your help was close thanks. Not sure why I needed to state composer.phar but there we go. I can follow copy and paste for next time! Commands I ran were:

/usr/local/php70/bin/php-cli composer.phar require magento/product-community-edition 2.2.3 --no-update

./composer.json has been updated

/usr/local/php70/bin/php-cli composer.phar update

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.