◉CLAUDE LABJP
●2.1.296 — Subagents can set their own autoCompactWindow, and an env var pins the model used by workflow agents●HAIKU 5.5 — Since 2.1.293 (Oct 7), claude-haiku-5-5 is the default Haiku model on the Anthropic API●SONNET 4.5 — Retires on the Claude API on 11/30, 47 days left. Migrate to Sonnet 5.5●Q&A — A write-up shows three places to look when a Mod draws nothing and reports no error●AGENTS.MD — One write-up explains how to split the entry points when Codex and Claude Code share a folder: AGENTS.md and CLAUDE.md●NEW — Approval prompts for "cd, git add, commit" every time: not a missing setting, but how it works●2.1.296 — Subagents can set their own autoCompactWindow, and an env var pins the model used by workflow agents●HAIKU 5.5 — Since 2.1.293 (Oct 7), claude-haiku-5-5 is the default Haiku model on the Anthropic API●SONNET 4.5 — Retires on the Claude API on 11/30, 47 days left. Migrate to Sonnet 5.5●Q&A — A write-up shows three places to look when a Mod draws nothing and reports no error●AGENTS.MD — One write-up explains how to split the entry points when Codex and Claude Code share a folder: AGENTS.md and CLAUDE.md●NEW — Approval prompts for "cd, git add, commit" every time: not a missing setting, but how it works
Articles/Claude Code
⟐ Claude Code/2026-06-27Advanced

Will It Stay Light When You Run It Unattended? Observing and Capping Claude Code's Long-Session Memory

How to keep long, unattended Claude Code sessions from slowly getting heavier — with a tiny ps-based RSS sampler, a rolling-baseline watchdog, and session segmentation, shown with working scripts and a before/after comparison.

Claude Code261Automation45Memory6HeadlessOperations21

✦ Premium Article

There was a quiet line in the 2026-06-27 Claude Code update that I did not want to skim past: CPU and memory usage during streaming and long-running sessions were reduced. It is not a flashy feature, but for anyone who keeps Claude Code running unattended for hours, this kind of baseline improvement is the most welcome kind.

As an indie developer, I run headless Claude Code to auto-publish articles across several sites, and the failure I fear most is not a crash — it is the quiet one where the process slowly gets heavier and only the last few jobs of the batch get dropped. A crash is loud; a gradual slowdown that misses the final couple of jobs is easy to miss. This update softens that worry a notch, but if I lean on the app-side improvement alone and stop measuring, I will eventually fall back into the same hole.

This article builds the three operational layers I rely on: observe Claude Code's resident memory in a few dozen lines, detect the onset of bloat, and split long runs into segments so RSS levels off instead of climbing.

What Actually Becomes "Heavy" in a Long Unattended Session

The first thing to separate is that "memory" here means two different things. One is the context Claude carries (the context window), which drives token cost and latency. The other is the resident memory of the local Claude Code process itself (RSS: resident set size), which is how heavy the process looks to the OS. The 6/27 improvement mainly lowered the latter. Context-grooming techniques are a separate topic, so this article stays consistently on RSS.

In unattended runs, RSS tends to become a problem in a few recognizable shapes:

  • Stacking dozens of tool calls into a single session lets streaming buffers and intermediate state accumulate, and RSS creeps upward
  • If a VM or container has a low memory ceiling, the grown RSS hits it and the OS OOM killer takes the whole process down
  • Even without a kill, once swapping starts everything slows down and the later jobs miss their window

A crash is loud, so you notice it. The nasty case is the third one: it just "gets slow" without raising an error. That is exactly why we start from observation.

What the 6/27 Update Lowers — and What It Doesn't

The published improvement is a reduction in CPU and memory usage during streaming and long-running sessions. In other words, the same work now ramps RSS up more gently than before. That is genuinely helpful.

But what the app lowers is the basal metabolism. If your job crams hundreds of operations' worth of work into one session, even a gentler slope will reach the ceiling given enough time. The update delays arrival; it does not promise you can run forever. Observation and segmentation stack on top of the app's improvement without conflicting with it.

A useful framing: the app's memory reduction makes the hill less steep, while the operational practice in this article adds a flat landing partway up that brings you back down.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦How to keep a fixed eye on Claude Code's resident memory with a ps-based RSS sampler in a few dozen lines
✦Building a drift-tolerant watchdog using a rolling baseline and median absolute deviation to catch the start of bloat
✦Splitting long runs into bounded segments and using --resume to cap RSS while preserving context
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $15 for lifetime access
View Membership →

Related Articles

⟐ Claude Code2026-08-22
Handing a long job to another session — and the completion marker for when the notification never arrives
How to use notify_when_idle to hear when another Claude Code session finishes, and a small completion marker that keeps you from waiting forever when the notification is dropped.
⟐ Claude Code2026-08-03
Existence Checks Pass, Writes Fail — Probing Capabilities Before an Unattended Run
A directory existing and a directory being writable are two different facts. Measured results from five broken-environment cases, why static clues cannot predict the worst of them, and a capability-probe preflight for unattended Claude Code runs.
⟐ Claude Code2026-08-02
Resuming After a Budget Stop: What 36 Enumerated Stop Points Taught Me
A budget cap that halts a headless run is neither success nor failure. I enumerated every stop point, measured resume integrity and total spend, and ended up changing what the cap applies to.