What this thread does
Do first: read the failure's stderr before changing COMPOSER_MEMORY_LIMIT, because PHP allocation failure and host exhaustion need different remedies.
Short answer
As of November 2026, Composer 2.11.2 is current (November 11 release). Use a per-command allowance; leave application runtime configuration alone. Prefer a bounded value supported by available memory, and use unlimited allocation only when host/container capacity is deliberately controlled (troubleshooting, container memory).
Choose / don't choose
- Update on a provisioned build machine: choose when intentionally resolving new dependency versions; don't repeat resolution on a constrained deployment host.
composer install: choose withcomposer.lockin the current directory to use its exact versions; don't expect it to decide a new dependency set. Withoutcomposer.lock, Composer creates one after dependency resolution (CLI).
Not for: PHP runtime security patches; see php-rce-october-security-patch-runtime-image-audit.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
COMPOSER_MEMORY_LIMIT | Prefix only this invocation, e.g. COMPOSER_MEMORY_LIMIT=2G composer update; 2G is an example allowance, not a recommendation for every host | Current Composer CLI | memory guidance |
PHP -d memory_limit | The command-line form is php -d memory_limit=-1 composer.phar <...> | Current PHP CLI / Composer | memory guidance |
COMPOSER_MEMORY_LIMIT | Overrides the limit through COMPOSER_MEMORY_LIMIT=-1; Composer otherwise internally raises the limit to 1.5G | Current Composer docs | troubleshooting |
max_memory_limit | Default -1; a startup-only setting controls the maximum memory_limit | PHP 8.5.0+, current manual | PHP |
--memory / --memory-swap | Non-swap memory and total memory-plus-swap limits; no PHP setting creates physical memory | Current Docker docs | resource constraints |
Order of operations
1. Identify the executable and its CLI PHP configuration. Composer's memory guidance first asks for Composer 2, preferably 2.2.0 or above; its historical memory improvements do not eliminate host limits (troubleshooting). 2. Read stderr and host/container OOM evidence. Allocate headroom for other processes. Run the update with the chosen per-process setting and commit the resulting lockfile after reviewing changes. 3. Deploy with the exact versions from composer.lock in the current directory; keep the same platform requirements in the deployment environment (CLI).
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
Allowed memory size | PHP allocation allowance exhausted | Raise only this Composer invocation's allowance if capacity exists; PHP subprocesses may need separate limits | Composer |
proc_open(): fork failed | Host may lack memory/swap to create a process | Inspect host capacity and provide a suitably sized build environment; raising the PHP allowance alone is insufficient | Composer |
Hard memory limit | An allocation would exceed the hard limit | Inspect stderr before calling status 137 a kernel OOM; reassess the process allowance and capacity | PHP |
The current PHP manual distinguishes a soft allocation limit from a hard limit and says both a PHP hard-limit termination and SIGKILL may yield 137; that status alone does not identify the cause. memory_limit=-1 also removes PHP's derived hard limit, subject to the maximum memory_limit controlled by max_memory_limit (PHP, Docker). Aldibe's report is a historical PHP allocation failure, not evidence that every modern failure has that cause.
Missing
- No universal memory allowance follows from dependency count; the dependency graph, CLI PHP settings and available host capacity determine the budget.
Checked
2026-11-12; Composer 2.11.2; current Composer troubleshooting/CLI, release changelog, PHP resource directives, Docker memory guidance and Aldibe's dated failure report read. No PHP or Composer commands executed.
Started from a post by @Composer, packaged by the editor. Original post