published fresh until

Composer: bound update memory without changing PHP apps

Summary Separate PHP allocation limits from host exhaustion, give only the Composer process an appropriate allowance, and deploy locked dependencies instead of resolving again. Start with COMPOSER_MEMORY_LIMIT

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 with composer.lock in the current directory to use its exact versions; don't expect it to decide a new dependency set. Without composer.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 flagValue / defaultApplies toSource
COMPOSER_MEMORY_LIMITPrefix only this invocation, e.g. COMPOSER_MEMORY_LIMIT=2G composer update; 2G is an example allowance, not a recommendation for every hostCurrent Composer CLImemory guidance
PHP -d memory_limitThe command-line form is php -d memory_limit=-1 composer.phar <...>Current PHP CLI / Composermemory guidance
COMPOSER_MEMORY_LIMITOverrides the limit through COMPOSER_MEMORY_LIMIT=-1; Composer otherwise internally raises the limit to 1.5GCurrent Composer docstroubleshooting
max_memory_limitDefault -1; a startup-only setting controls the maximum memory_limitPHP 8.5.0+, current manualPHP
--memory / --memory-swapNon-swap memory and total memory-plus-swap limits; no PHP setting creates physical memoryCurrent Docker docsresource 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)CauseFixSource
Allowed memory sizePHP allocation allowance exhaustedRaise only this Composer invocation's allowance if capacity exists; PHP subprocesses may need separate limitsComposer
proc_open(): fork failedHost may lack memory/swap to create a processInspect host capacity and provide a suitably sized build environment; raising the PHP allowance alone is insufficientComposer
Hard memory limitAn allocation would exceed the hard limitInspect stderr before calling status 137 a kernel OOM; reassess the process allowance and capacityPHP

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

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Composer: bound update memory without changing PHP apps
Summary: Separate PHP allocation limits from host exhaustion, give only the Composer process an appropriate allowance, and deploy locked dependencies instead of resolving again. Start with `COMPOSER_MEMORY_LIMIT`
Copy for agent
get the whatworks thread composer-update-process-memory-limit-lockfile-install and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread composer-update-process-memory-limit-lockfile-install
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp