Composer "Allowed memory size exhausted" - Fix OOM in CI
The PHP process running Composer hit PHP’s memory_limit and was killed mid-resolution. Dependency solving on a large composer.json can be memory-hungry, and CLI PHP often has a low limit.
What this error means
composer update (resolution is the heaviest step) dies with "Allowed memory size of N bytes exhausted". The same command may pass locally where PHP’s CLI memory_limit is higher or unlimited.
PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to
allocate 20480 bytes) in phar:///usr/bin/composer/src/Composer/DependencyResolver/...
on line 215Common causes
PHP memory_limit too low for resolution
The dependency solver builds a large in-memory graph. A CLI memory_limit of 128M–1.5G can be exceeded on big projects.
Running update instead of install in CI
composer update re-resolves everything (memory-heavy); composer install replays the lockfile and uses far less.
How to fix it
Remove the limit for Composer
Composer respects COMPOSER_MEMORY_LIMIT; setting it to -1 disables PHP’s limit for that process only.
COMPOSER_MEMORY_LIMIT=-1 composer update --no-interactionRaise PHP’s CLI memory_limit
Alternatively pass a higher limit to the PHP that runs Composer.
php -d memory_limit=-1 /usr/bin/composer update --no-interactionInstall from the lockfile instead of updating
CI should replay the lock, which needs much less memory than re-resolving.
composer install --no-interaction --prefer-distHow to prevent it
- Set
COMPOSER_MEMORY_LIMIT=-1in CI for anycomposer updatestep. - Run
composer install(lockfile replay) in CI rather thanupdate. - Give CI runners enough RAM for large dependency graphs.