Running the “composer update” command results in a fatal error:
Fatal error: Allowed memory size of 536870912 bytes exhausted

Magento 2 CLi command memory size exhausted issue can interrupt the process for different Magento 2 commands i.e. composer update, compiler update, indexer reindex etc.

How to resolve memory exhausted issue:

To resolve this issue, add memory_limit manually in the Magento CLI command “-d memory_limit=2048M”.

Example 01 – Composer update in the hosted solution:

php -d memory_limit=2048M /usr/local/bin/composer update

Example 02 – Composer update for local environment:

php -d memory_limit=2048M C:\composer\composer update

Example 03 – Index command execution:

php -d memory_limit=2048M bin/magento indexer:reindex

Example 04 – Data compiler command:

php -d memory_limit=2048M bin/magento setup:di:compile