[BUG] Large session JSONL files cause Claude Code to hang and consume all available RAM

Resolved 💬 7 comments Opened Feb 1, 2026 by gulf-token Closed Mar 11, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Environment

  • Claude Code v2.1.29
  • Ubuntu 22.04, 30 GB RAM
  • Project directory: large enterprise codebase (~2,500 files)

Symptoms

  • Claude Code responds to first prompt, then hangs indefinitely on second prompt
  • Process consumes 12-13 GB RAM (observed via top)
  • Non-interactive mode (echo "test" | claude --print) also hangs
  • Occurs with or without CLAUDE.md present
  • Occurs even after clearing history.jsonl

Root Cause

A single session JSONL file in ~/.claude/projects/<project>/ had grown to 3.8 GB.
Three other session files were 13-28 MB. Claude Code appears to load or
index these files on every prompt, causing the memory explosion and hang.

File: ~/.claude/projects/-opt-gulftoken/66cf6960-28df-4625-8f8f-4589dd1e69f9.jsonl (3.8 GB)
Corresponding debug file was 207 MB.

Resolution

Removing the oversized session files immediately resolved the issue.

Suggestions

  1. Add a size guard -- skip or warn on session files exceeding a threshold (e.g. 50 MB)
  2. Add diagnostic output when startup takes >10 seconds, indicating which file is being processed
  3. Consider a claude --doctor or claude --cleanup command to detect and fix corrupted state
  4. The debug log gave no indication of the issue -- it stopped at the API auth step with no error

What Should Happen?

  • Claude Code should either gracefully handle oversized session files or prevent them from growing to unreasonable sizes in the first place. Specifically:
  • Session JSONL files should not be allowed to grow unbounded (the offending file reached 3.8 GB)
  • If a session file exceeds a reasonable threshold (e.g. 50 MB), Claude Code should skip loading it, log a warning, and continue operating normally
  • Startup should not silently hang with no diagnostic output when encountering corrupted or oversized state files
  • A built-in diagnostic or cleanup command (e.g. claude --doctor or claude --cleanup) should exist to detect and resolve corrupted local state

Error Messages/Logs

Here is the text for each section:

What Should Happen?
Claude Code should either gracefully handle oversized session files or prevent them from growing to unreasonable sizes in the first place. Specifically:

Session JSONL files should not be allowed to grow unbounded (the offending file reached 3.8 GB)
If a session file exceeds a reasonable threshold (e.g. 50 MB), Claude Code should skip loading it, log a warning, and continue operating normally
Startup should not silently hang with no diagnostic output when encountering corrupted or oversized state files
A built-in diagnostic or cleanup command (e.g. claude --doctor or claude --cleanup) should exist to detect and resolve corrupted local state


Error Messages/Logs
No error messages were produced. The debug log (~/.claude/debug/<session-id>.txt) showed normal startup through API auth, then simply stopped with no further output:
2026-02-01T12:03:27.334Z [DEBUG] [API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: false, has Authorization header: false
2026-02-01T12:03:27.334Z [DEBUG] [API:auth] OAuth token check starting
2026-02-01T12:03:27.335Z [DEBUG] [API:auth] OAuth token check complete
No indication of which file was being processed, no timeout warning, no memory pressure alert. The corresponding debug file for the problematic session had grown to 207 MB (~/.claude/debug/66cf6960-28df-4625-8f8f-4589dd1e69f9.txt).
top showed the Claude process consuming 12.8 GB of RAM (84.1g virtual) on a 30 GB server:
237769 gulftok+  20   0   84.1g  12.8g  53780 R  90.9  41.2   1:24.45 claude

Steps to Reproduce

  1. Use Claude Code on a large enterprise project over an extended period (weeks of daily use, long sessions with large file operations)
  2. Over time, a session JSONL file in ~/.claude/projects/<project-hash>/ grows to multiple gigabytes (in our case, 3.8 GB)
  3. Launch Claude Code with claude in the project directory
  4. Send any prompt (e.g. hello) -- first response may succeed
  5. Attempt a second prompt -- Claude Code hangs indefinitely, consuming all available RAM
  6. Non-interactive mode (echo "test" | claude --print) also hangs

WORKAROUND
find ~/.claude/projects/ -name "*.jsonl" -size +50M -exec ls -lh {} \;

Remove or move the offending file(s)

mv ~/.claude/projects/<project>/<session-id>.jsonl /tmp/

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.29

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Terminal.app (macOS)

Additional Information

  • The issue is not related to CLAUDE.md content or size -- it reproduces with no CLAUDE.md present, with a 6-line CLAUDE.md, and with the full 205k char file
  • Clearing ~/.claude/history.jsonl (713 KB) did not resolve the issue
  • The .claude/ directory had grown to 4.1 GB total, with 3.8 GB attributable to the single corrupted session file
  • Four session JSONL files were oversized: 3.8 GB, 28 MB, 20 MB, and 13 MB. Quarantining all four resolved the issue immediately
  • After removing the files, Claude Code responded instantly with full multi-turn conversation capability restored
  • Server: Ubuntu 22.04, 30 GB RAM, Claude Code v2.1.29, Opus 4.5 via Claude Max subscription

View original on GitHub ↗

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