Claude Code Fixes Major Memory Leaks and Shrinks Session Transcripts Up to 79x

Claude Code

Claude Code 2.1.208 closes out a cluster of long-standing memory leaks that had let some sessions balloon to tens of gigabytes of RAM and trigger out-of-memory kills. Anthropic fixed leaking MCP stdio server stderr buffers, unbounded LSP document handles, retained async hook output, and unchecked growth in headless and SDK session payloads. Alongside the leak fixes, Claude Code now prunes superseded file-history backups to cut on-disk session transcript size by up to 79x in edit-heavy sessions, and caches tool-pool assembly to deliver up to 7x faster tool rounds in print and SDK sessions with many MCP tools configured.


Runaway Memory Had Become a Real Problem

Over the preceding months, developers had filed a string of GitHub issues describing Claude Code processes consuming an alarming amount of memory during long-running sessions. Reports ranged from private memory reaching 18 GB in extended sessions to heap allocations climbing as high as 93 GB, with some users describing idle sessions where resident memory grew by 400-500 MB per minute until the process was killed by the operating system. For developers running long coding sessions, background agents, or SDK-hosted integrations, this made Claude Code unreliable for anything beyond short bursts of work.

What Anthropic Fixed

Version 2.1.208 addresses several distinct leak sources identified across these reports:

  • MCP server stderr accumulation: stdio-based MCP servers could accumulate up to 64 MB of stderr output per server with no cap, which added up quickly in sessions with several MCP servers configured.
  • LSP document handles: Language Server Protocol documents were staying open indefinitely; Claude Code now enforces an LRU cache capped at 50 documents.
  • Async hook output retention: output from asynchronous hooks was being retained even after a task moved to the background, rather than being released.
  • Headless and SDK payload growth: sessions driven through the SDK or headless mode could grow without bound when tool results returned large payloads.
  • Agent view image retention: a separate leak kept pasted images alive for the full lifetime of the agent view screen after sending peek replies.
  • Long-line file reads: reading files containing extremely long single lines with an offset or limit could previously trigger a memory blowup; Claude Code now returns a clean error instead of loading the entire line.

Smaller Transcripts, Faster Tool Rounds

Beyond the leak fixes, Anthropic reduced how much disk space session transcripts consume. By pruning superseded file-history backups, transcript size in edit-heavy sessions is now up to 79x smaller, and checkpoint disk usage is bounded rather than growing unchecked. The file edit read cache was also tightened, now bounded to 16 MB instead of pinning up to 1,000 full files in memory.

On the performance side, Claude Code now caches tool-pool assembly in print and SDK sessions, cutting per-tool-call CPU overhead and delivering up to 7x faster tool rounds in sessions configured with many MCP tools. Resuming sessions that include background agents or forks spawned from large conversations also now uses less memory.

Why It Matters

Together, these fixes target the exact failure mode developers had been reporting for months: healthy short sessions that degraded badly the longer they ran, eventually forcing a restart or crashing outright under memory pressure. Combined with the transcript size and tool-round performance improvements, the release should make long-running Claude Code sessions, particularly those using multiple MCP servers or background agents, meaningfully more stable and lighter on system resources.