Skip to content

Cap V8 heap to prevent guest OOM kills#61

Merged
jhrozek merged 1 commit intomainfrom
fix/node-heap-limit
Mar 17, 2026
Merged

Cap V8 heap to prevent guest OOM kills#61
jhrozek merged 1 commit intomainfrom
fix/node-heap-limit

Conversation

@jhrozek
Copy link
Copy Markdown
Contributor

@jhrozek jhrozek commented Mar 17, 2026

Add NodeHeapPercent to the Agent domain type: when set, the sandbox
computes NODE_OPTIONS=--max-old-space-size based on the effective VM
memory. For claude-code this is 75%, giving a 3072 MiB heap cap in a
4 GiB VM that scales automatically if the user increases --memory.

Also add DefaultEnv to Agent for static per-agent env vars, and
NODE_OPTIONS to claude-code's EnvForward so users can override the
default by exporting NODE_OPTIONS on the host.

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

Claude Code has a known memory leak where the mutableMessages array
grows monotonically (~600+ MB/min). In a 4 GiB VM without swap, this
exhausts guest RAM in ~60 seconds and the Linux OOM killer SIGKILLs
the process — appearing as a mysterious sudden exit.

Add NodeHeapPercent to the Agent domain type: when set, the sandbox
computes NODE_OPTIONS=--max-old-space-size based on the effective VM
memory. For claude-code this is 75%, giving a 3072 MiB heap cap in a
4 GiB VM that scales automatically if the user increases --memory.

Also add DefaultEnv to Agent for static per-agent env vars, and
NODE_OPTIONS to claude-code's EnvForward so users can override the
default by exporting NODE_OPTIONS on the host.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jhrozek jhrozek merged commit 7a1e9c2 into main Mar 17, 2026
7 checks passed
@jhrozek jhrozek deleted the fix/node-heap-limit branch March 17, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants