Composer "Allowed memory size exhausted" - Fix OOM in CI
By Daniel Zoghalchali·Latchkey
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.
composer output
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 215
Common 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.
CI should replay the lock, which needs much less memory than re-resolving.
Terminal
composer install --no-interaction --prefer-dist
How to prevent it
Set COMPOSER_MEMORY_LIMIT=-1 in CI for any composer update step.
Run composer install (lockfile replay) in CI rather than update.
Give CI runners enough RAM for large dependency graphs.
Frequently asked questions
What causes ""Allowed memory size exhausted""?
The dependency solver builds a large in-memory graph. A CLI memory_limit of 128M–1.5G can be exceeded on big projects.
How do I fix "Allowed memory size exhausted"?
Composer respects COMPOSER_MEMORY_LIMIT; setting it to -1 disables PHP’s limit for that process only.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.