[BUG] Claude is getting slower and slower the longer it works. (keystrokes take forever after 2 hours of work, unusable after 5 hours)

Resolved 💬 4 comments Opened Jul 26, 2025 by ChristophRauch Closed Aug 11, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.61 (Claude Code)
  • Operating System: Fedora 42
  • Terminal: gnome-terminal-server

TLDR

This particular claude session uses all of my mem as VIRT memory, but only around 1GB RES memory. Even after many hours the RES has not grown significantly, but the heap thrashing has, slowing it down.

Bug Description

After running for a few hours (yes, a few hours) under heavy load, claude apparently experiences memory thrashing through repeated heap-allocation and de-allocation cycles. My assumption is that you're using node.js to run claude, so I'm guessing this would be a problem with node, but could also be due to the work-load (many small objects allocated?).

I calculated that the whole 15 Tasks which it initially planned would take about 20k Tokens in the main agent and should take around 4-5 hours. Now, after 4 hours, it's not even half-way through and its getting slower. // Update: I killed the process and did a --continue, but the process STILL has 32GB of VIRT and 1GB of RES. Now I'm a bit lost. IT IS running fast again though.

Steps to Reproduce

Well, you'd have to give it at least 6-7 Tasks of which each should run to around 100k tokens. Then you can clearly see through strace that:

mmap(NULL, 67112960, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd9a3fff000
mmap(NULL, 134221824, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd99bffe000
munmap(0x7fd9a3fff000, 67112960)        = 0
mmap(NULL, 268439552, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd98bffd000
munmap(0x7fd99bffe000, 134221824)       = 0
mmap(NULL, 536875008, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd1bd07f000
munmap(0x7fd98bffd000, 268439552)       = 0
mmap(NULL, 1073745920, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd17d07e000
munmap(0x7fd1bd07f000, 536875008)       = 0
munmap(0x7fd17d07e000, 1073745920)      = 0
futex(0x5634bc3b35e8, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 67112960, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd9a3fff000
mmap(NULL, 134221824, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd99bffe000
munmap(0x7fd9a3fff000, 67112960)        = 0
mmap(NULL, 268439552, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd98bffd000
munmap(0x7fd99bffe000, 134221824)       = 0
mmap(NULL, 536875008, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd1bd07f000
munmap(0x7fd98bffd000, 268439552)       = 0
mmap(NULL, 1073745920, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd17d07e000
munmap(0x7fd1bd07f000, 536875008)       = 0
munmap(0x7fd17d07e000, 1073745920)      = 0
futex(0x5634bc3b35ec, FUTEX_WAKE_PRIVATE, 1) = 1
getpid()                                = 363256
futex(0x5634bc3b35ec, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5634bc3ccbe0, FUTEX_WAKE_PRIVATE, 1) = 0
mmap(NULL, 67112960, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd9a3fff000
mmap(NULL, 134221824, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd99bffe000
munmap(0x7fd9a3fff000, 67112960)        = 0
mmap(NULL, 268439552, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd98bffd000
munmap(0x7fd99bffe000, 134221824)       = 0
mmap(NULL, 536875008, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd1bd07f000
munmap(0x7fd98bffd000, 268439552)       = 0
mmap(NULL, 1073745920, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd17d07e000
munmap(0x7fd1bd07f000, 536875008)       = 0
munmap(0x7fd17d07e000, 1073745920)      = 0
mmap(NULL, 67112960, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd9a3fff000
mmap(NULL, 134221824, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd99bffe000
munmap(0x7fd9a3fff000, 67112960)        = 0
mmap(NULL, 268439552, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd98bffd000
munmap(0x7fd99bffe000, 134221824)       = 0
mmap(NULL, 536875008, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd1bd07f000
munmap(0x7fd98bffd000, 268439552)       = 0
mmap(NULL, 1073745920, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd17d07e000
munmap(0x7fd1bd07f000, 536875008)       = 0

This is the usual behaviour. Other syscalls are sparse and happen in bursts. Then it will go back to memory juggling.

Expected Behavior

Well, I expected it not to do that.

Actual Behavior

But it does!

Additional Context

View original on GitHub ↗

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