[FEATURE] Auto-exit idle sessions to free memory

Resolved 💬 3 comments Opened Apr 6, 2026 by ahbarnum Closed May 17, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

When working on multiple tickets/tasks simultaneously, I keep many Claude Code sessions open across virtual desktops, each one focused on a different ticket. I bounce between them giving direction, then move on.

At any given moment, only some sessions are active; the rest are idle but still consuming 500MB-1GB+ each. Over time they grow further due to memory leaks (see #18859). With 6 idle sessions, that's 3-6GB of RAM doing nothing. On a 32GB machine running browser, editor, and other tools alongside Claude, this forces constant manual session management, remembering to quit sessions I'm not using and resume them later.

Proposed Solution

A configurable idle timeout setting that gracefully exits the session after N minutes of no user interaction and prints the resume command to the terminal:
claude --idle-timeout 15

Or as a persistent setting:

// ~/.claude/settings.json
{ "idleTimeoutMinutes": 15 }

When the timeout fires:

  1. The session saves its state (as it already does on normal exit)
  2. Prints: Session saved. Resume with: claude --resume "session-name"
  3. Exits cleanly, freeing all memory

The terminal stays open showing the resume command, so the user can pick right back up when they return to that desktop.

Alternative Solutions

  • Manually quitting and resuming sessions, works but adds friction and I forget, leading to 6+ idle sessions eating RAM
  • A custom monitoring script that alerts when sessions are idle, I built this but it can only notify, not actually free the memory
  • Killing processes externally, loses session state and isn't graceful

Priority

High - Significant impact on productivity

Feature Category

Performance and speed

Use Case Example

  1. I'm working many tickets simultaneously, each on its own virtual desktop with a Claude Code session
  2. I give the "claim routing" session a task, switch to the "filtering bug" desktop to check progress, give it a nudge, switch to "new hire setup" to review what Claude found
  3. Each interaction is 30-60 seconds. The other sessions sit idle
  4. With --idle-timeout 15, after 15 minutes of no interaction, idle sessions exit gracefully and print their resume command
  5. When I switch back to a desktop, I see "Session saved. Resume with: claude --resume claim-routing" in the terminal, hit up-enter, and I'm back in seconds
  6. Instead of 6 sessions × 800MB = 4.8GB wasted, I'm using memory only for the few sessions I'm actively directing

Additional Context

  • Claude Desktop already has a 5-minute idle timeout (#23092) but it's hardcoded and users report it as a bug because it's not configurable and doesn't (always?) communicate the resume path
  • The memory leak in idle sessions (#18859) makes this worse over time, sessions that started at 300MB can grow to 1GB+ while sitting idle
  • This would pair well with --resume which already exists, the infrastructure is there, just needs the automatic trigger
  • DDR5 RAM prices have tripled due to the AI memory shortage, making RAM conservation more important than ever for users who can't easily upgrade

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗