Skip to content
Latchkey

Composer "Allowed memory size exhausted" during install in CI

Composer’s solver can use a lot of memory on large or deeply constrained dependency graphs. When PHP’s memory_limit is too low for the resolve, the process hits a fatal "Allowed memory size exhausted" and the install dies.

What this error means

composer install or composer update aborts with "PHP Fatal error: Allowed memory size of N bytes exhausted" inside Composer’s solver. It is most common on composer update with a complex dependency tree.

composer
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted
(tried to allocate 20480 bytes) in
phar:///usr/bin/composer/src/Composer/DependencyResolver/...

Common causes

PHP memory_limit too low for the resolve

The CLI memory_limit caps Composer below what a large dependency graph needs to resolve, so PHP aborts.

A heavy composer update on a big tree

Full updates explore far more of the version space than installs, spiking memory on complex projects.

How to fix it

Raise memory for the Composer process

Composer documents running it with an unlimited memory_limit for the command.

Terminal
COMPOSER_MEMORY_LIMIT=-1 composer update --no-interaction
# or
php -d memory_limit=-1 /usr/bin/composer install --no-interaction

Prefer install over update in CI

Resolve once locally and use the committed lock in CI so the heavy solve does not run on every build.

Terminal
composer install --no-interaction --prefer-dist

How to prevent it

  • Set COMPOSER_MEMORY_LIMIT=-1 for update steps in CI.
  • Run composer install (using the committed lock) in CI, not composer update.
  • Use a runner with enough memory for your dependency graph.

Frequently asked questions

What causes ""memory exhausted (install)""?
The CLI memory_limit caps Composer below what a large dependency graph needs to resolve, so PHP aborts.
How do I fix "memory exhausted (install)"?
Composer documents running it with an unlimited memory_limit for the command.
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.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card