Should you get a composer memory error or status message “killed” when using
sudo composer upgrade on aMiSTACX, it is because of an incorrect setting w/ PHP 7.x, or the memory value is set too low.
This also happens with performance stacks that do not have a swap file, thus memory becomes exhausted.
Although most of our stacks G5s through G3s have PHP preconfigured for the stack with multiple PHP versions, and 2G, you may occasionally find a value less than 2G. Even with 2GB set, sometimes you just need more memory, because on some stacks we have removed the swap file.
As a quick work-around, increase instance size or increase php CLI memory from 2G to 3G+, reload PHP or reboot the server. [In some cases you may also need to also temporarily increase your instance size so you have more than 2GB of free memory available.]
A helpful command to determine what memory value PHP-CLI is set at, run the following:
sudo php -r "echo ini_get('memory_limit').PHP_EOL;"
To change the value edit the PHP CLI file:
sudo nano /etc/php/7.x/cli/php.ini
Where x = your current php version. # php -v
You can also do the following:
delete or rename the /magento/composer.lock file
sudo composer dumpautoload
sudo composer clearcache
sudo php -d memory_limit=4G /usr/local/bin/composer update
*Where memory_limit= available memory between 2GB and 4GB