Codex memory grows to 75GB+ during basic session

Open 💬 5 comments Opened May 2, 2026 by evilfps
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

Summary

Urgent: Codex can grow to extreme memory usage during an apparently basic/single-task session, eventually triggering macOS "Your system has run out of application memory."

Observed in the macOS Force Quit Applications dialog:

Codex: 75.50 GB
cmux (paused): 10.76 GB
Activity Monitor: 60.4 MB
Finder: 125.9 MB

The memory usage reportedly kept increasing and reached roughly 85 GB before Codex was stopped to avoid taking down the system.

Environment

  • Codex CLI: codex-cli 0.128.0
  • OS: macOS 26.4.1, Darwin 25.4.0, arm64
  • Model: gpt-5.5
  • Reasoning effort: medium
  • Config has multi_agent = true, but the observed problem happened during a basic/single-task session, not an intentionally large multi-agent run.

Impact

This is system-threatening on macOS:

  • macOS showed the global "system has run out of application memory" dialog.
  • Codex reached at least 75.50 GB in the Force Quit dialog.
  • The user had to stop Codex manually when it approached roughly 85 GB and was still increasing.
  • This can interrupt work and risks destabilizing the whole machine.

What happened

During a normal Codex session, memory usage climbed continuously even though the user was not running a large task. The behavior looked like runaway accumulation/leak rather than a bounded memory spike.

Relevant local log clue from the same timeframe:

turn{... model=gpt-5.5 codex.turn.token_usage.input_tokens=1905121 ... codex.turn.token_usage.cached_input_tokens=1818240 ... codex.turn.token_usage.non_cached_input_tokens=86881 ... codex.turn.token_usage.output_tokens=3950 ... codex.turn.token_usage.reasoning_output_tokens=1091 ... codex.turn.token_usage.total_tokens=1909071}: codex_core::tasks: close time.busy=1.18s time.idle=361s

That is about 1.9M total tokens for a session that did not feel like a large task from the user's perspective. This may indicate that Codex is retaining/re-sending/accumulating too much session context or cached input state across turns, which may correlate with the memory growth.

Expected behavior

For a basic single-task session, Codex memory should remain bounded and should not grow into tens of GB. If a session/context grows unexpectedly large, Codex should either compact, evict, fail fast with a clear diagnostic, or provide an explicit warning before the desktop app threatens system memory.

Actual behavior

Codex memory kept increasing until macOS forced the user into the application memory pressure dialog. Codex was shown at 75.50 GB and was reportedly near 85 GB before the user stopped it.

Notes

This may be related to a separate WebSocket/Responses streaming instability issue already filed here:

However, this issue is distinct: the urgent failure here is unbounded memory growth / excessive retained context during ordinary usage.

View original on GitHub ↗

5 Comments

github-actions[bot] contributor · 3 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #20573
  • #19333
  • #19540
  • #19381

Powered by Codex Action

dpandey82 · 3 months ago

I faced same issue on my macbook m3pro

mistersilver-uk · 3 months ago

I've experienced the same issue on Ubuntu.

IgorGanapolsky · 3 months ago

I hit a very similar macOS failure mode while cleaning up a local multi-project agent workstation. The useful distinction was separating Codex memory growth from session-restore amplification.

A few diagnostics that made the issue easier to reason about:

ps -axo pid,rss,command | sort -nrk2 | head -20
launchctl list | rg -i 'codex|agent|tmux|restore|openclaw'
tmux ls 2>/dev/null
find "$HOME/Library/Mail" -path '*Outbox.mbox*Messages*.emlx' -type f 2>/dev/null | wc -l

The mitigation that stopped the machine-wide collapse was:

  • disable automatic tmux/terminal/app restore for agent sessions
  • cap concurrent/background agents to 1 until memory is stable
  • move long-lived work into named workspaces with explicit owners/stop conditions
  • kill stale helper processes after GUI/Computer Use transport failures
  • keep Mail/Gmail/browser outbound automation off until the queue is proven empty

This does not prove the root cause inside Codex, but it prevents a single leak/regression from being multiplied by restored sessions and background launch jobs.

I wrote up the operational checklist here in case it helps other macOS users debug safely without wiping their workspace: https://igorganapolsky.github.io/AI_OpenClaw_Setup_Kits/guides/codex-openclaw-runaway-agent-safety.md

omry · 3 months ago

For WSL / Ubuntu users hitting this class of memory growth, I posted a containment workaround here: https://github.com/openai/codex/issues/18041#issuecomment-4457925732

Short version: use the VS Code extension setting chatgpt.cliExecutable to point at a wrapper that launches the bundled native Codex binary through systemd-run --user --scope with MemoryMax / MemorySwapMax.

This does not fix the leak, but it prevents Codex from taking down the whole WSL VM or Linux desktop.