Claude Code Fixes a Memory Leak in Long Sessions With Subagents

Claude CodeView original changelog

Claude Code 2.1.238 fixes a memory leak in long interactive sessions where subagent tool results accumulated in memory indefinitely instead of being released once they scrolled out of view. Developers have filed a string of GitHub issues describing memory climbing into double-digit gigabytes during multi-hour sessions, particularly ones with heavy subagent use. The fix is notable because subagent forking became Claude Code's default behavior in version 2.1.232, which likely made this kind of memory growth more common for ordinary interactive sessions.

Key Takeaways

  • Subagent tool results are now released from memory once they leave the recent display window, instead of accumulating for the life of a session.
  • The fix targets long interactive sessions, where developers have reported memory climbing into double-digit gigabytes over multi-hour use.
  • It follows Claude Code's default switch to subagent forking in version 2.1.232, a change that likely made memory growth from subagents more common.
  • Multiple GitHub issues filed over the past year describe the underlying symptom, from idle-session leaks to crashes during heavy subagent orchestration.
  • The fix is scoped narrowly: it addresses subagent tool result retention specifically, not every reported cause of memory growth in long sessions.
  • Ships in version 2.1.238, released August 20, 2026.

The Problem

Developers running long Claude Code sessions, especially ones that lean on subagents, have filed a string of GitHub issues over the past year describing memory climbing steadily until a session slows to a crawl or a machine runs out of RAM, with some reports describing processes reaching double-digit gigabytes of private memory after hours of use.

The Fix

Version 2.1.238 addresses a specific driver of that growth: subagent tool results were being kept in memory indefinitely rather than being released once they scrolled out of the recently displayed window. Claude Code now frees that memory once a subagent's tool results leave the recent display window, capping how much a long session accumulates just from subagent activity.

Why It Matters

The timing is notable. Subagent forking became Claude Code's default behavior in version 2.1.232, meaning ordinary interactive sessions now spawn and fork subagents more often than before, which makes any per-subagent memory growth compound faster than it used to. A fix landing six releases later closes off one of the more direct ways that default change could have made long sessions heavier to run.

What to Expect

Developers who run multi-hour sessions with heavy subagent use, background code review, multi-file refactors, or agent-team workflows should see memory stay flatter over the course of a session. Anthropic did not describe this as a complete fix for every reported memory growth pattern in long sessions, only the one tied to subagent tool results piling up.


Mentioned onGitHubGitHub