Skip to content

[Bug] ccusage statusline causes infinite process spawning loop leading to 100% CPU usage #459

Closed

Description

@aranej

Bug Description

The ccusage statusline command causes an infinite process spawning loop when used with Claude Code's statusline hooks, leading to complete system overload.

Environment

  • ccusage version: 15.9.1
  • Runtime: Bun v1.2.19
  • OS: Ubuntu 24.04.2 LTS
  • Claude Code: v1.0.72
  • Server: Hetzner CX22 (2 vCPU, 4GB RAM)

Configuration

{
  "statusLine": {
    "type": "command",
    "command": "bun x ccusage statusline",
    "padding": 0
  }
}

Issue Details

What happens:

1. Claude Code statusline hook executes bun x ccusage statusline
2. ccusage processes hang/don't terminate properly
3. Claude Code detects timeout and spawns new process
4. Process accumulation continues indefinitely
5. System becomes unresponsive due to resource exhaustion

Resource Impact:

- CPU Usage: 300%+ (30+ parallel processes each consuming 8-15% CPU)
- Memory: 3+ GB consumption
- Load Average: 21.73 (normal <2.0)
- Active Processes: 34+ simultaneous node ccusage statusline instances

Reproduction:

1. Add statusline config to ~/.claude/settings.json
2. Use Claude Code for 2-3 minutes
3. Check ps aux | grep ccusage - multiple hanging processes
4. Monitor with htop - CPU usage climbs to 100%

Expected Behavior

- Single ccusage process per statusline call
- Process terminates after returning output
- Normal CPU/memory usage

Actual Behavior

- Multiple processes spawn continuously
- Processes don't terminate properly
- System overload requiring manual intervention

Workaround

Temporarily disable statusline:
{
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
  "model": "sonnet"
}

Additional Context

- Feature works correctly when called manually: bun x ccusage statusline --help
- Issue appears to be specific to statusline hook integration
- Same problem reported by other users in Reddit thread
- Beta feature - possibly related to stdin handling or process lifecycle management

Logs

$ ps aux | grep ccusage
claude-+ 3152617  8.8  4.5 11525868 178220 pts/2 Rl+ ccusage statusline
claude-+ 3152645  8.5  3.9 11508688 154340 pts/2 Rl+ ccusage statusline
claude-+ 3152678  8.6  3.9 11489148 153540 pts/2 Rl+ ccusage statusline
[... 30+ more processes]

Thanks for the amazing tool! This is the only issue preventing production usage of the statusline feature.

Activity

  1. spotshare-nick commented on Aug 11, 2025

    @spotshare-nick

    I'm using the npx -y version and not seeing this. I just somewhat wonder what's causing this. Hopefully the project owner knows, but maybe try some different ideas to help better understand the issue. I can't think that NPX vs BUN would make a difference, but it's possible. You could also try running the BUN command independently just to make sure there's no obvious issue.

  2. thushan commented on Aug 12, 2025

    @thushan

    can repro with bun also - things went a bit bunanas:

      "statusLine": {
        "type": "command",
        "command": "bun x ccusage statusline"
      }
    

    macOS & PopOS with latest CCode. As mentioned in the bug report, can only repro this issue with statusline, on its own it's okay.

  3. tommyruin commented on Aug 12, 2025

    @tommyruin

    Issue: Memory leak causing 20+ Node.js processes when used as Claude
    Code status line

    Environment:

    • Windows 11
    • Claude Code with global ccusage installation
    • Status line config: "command": "bun x ccusage statusline"

    Problem:

    1. ccusage installed globally via npm install -g [email protected]
    2. Claude Code shell snapshot corruption - creates infinite recursive
      shell execution loops
    3. Multiple Node.js processes spawn (up to 20+ simultaneously,
      150MB-600MB each)
    4. Memory consumption escalates to several GB
    5. ccusage persists even after uninstall - keeps respawning via cached
      global Claude Code settings

    Root Cause:

    • ccusage status line command triggers Claude Code's shell snapshot
      system
    • Shell snapshots become corrupted, creating recursive execution paths
      like:
      /c/Users/tommy/.claude/shell-snapshots/snapshot-bash-[id].sh
    • Each snapshot tries to execute ccusage, spawning new Node processes
    • Process cleanup fails, leading to accumulation

    Impact:

    • System becomes unresponsive due to memory exhaustion
    • Multiple node.exe processes consume 2-4GB RAM total
    • Affects both development machines (laptop and PC)

    Workaround:

    • Manually delete shell snapshots: rmdir /S /Q
      "%USERPROFILE%.claude\shell-snapshots"
    • Remove ccusage from global Claude Code settings
    • Kill Node processes: taskkill /F /IM node.exe

    Recommendation:
    ccusage may need better process cleanup or compatibility testing with
    Claude Code's shell management system.

  4. ursisterbtw commented on Aug 12, 2025

    @ursisterbtw

    can repro with bun also - things went a bit bunanas:

      "statusLine": {
        "type": "command",
        "command": "bun x ccusage statusline"
      }
    

    macOS & PopOS with latest CCode. As mentioned in the bug report, can only repro this issue with statusline, on its own it's okay.

    I've had the exact same issue on Ubuntu

  5. 9wick commented on Aug 16, 2025

    @9wick

    I can reproduce this issue as well.
    The ccusage processes are indeed accumulating as shown in the top screenshot.

    Image

    My hypothesis and investigation:
    I suspected this might be a timing mismatch between ccusage execution speed and statusline request frequency, so I decided to measure both sides:

    My measurements:

    • ccusage statusline execution takes ~10 seconds in my environment
      Image

    • Statusline requests occur much more frequently - about half of the requests come within 1-second intervals when measured over ~100 turn converstation
      Image

    • This timing gap causes new processes to spawn faster than existing ones can complete

    Analysis:
    Based on my measurements, I think the root cause might be that Claude Code's statusline hook spawns new ccusage processes before previous ones finish executing. Since ccusage takes significantly longer to execute than the statusline refresh rate, processes could accumulate and consume CPU resources.
    This could explain the behavior described in the issue - the processes might not be terminating properly because new ones keep getting spawned before the previous ones complete their work.

  6. alexstewartja commented on Aug 16, 2025

    @alexstewartja

    @9wick Well-written report. Eyballing the CLI's behavior while this issue is active, I can visibly see the refresh rate (rapid blinking), which subsequently spawn new node processes

  7. ryoppippi commented on Aug 17, 2025

    @ryoppippi
    Member

    published https://github.com/ryoppippi/ccusage/releases/tag/v15.9.8
    added semaphore for exploding process in statusline
    please try it out

  8. alexstewartja commented on Aug 17, 2025

    @alexstewartja

    @ryoppippi Eager to try this, as statusline had become unusable. Will report back!

  9. ryoppippi commented on Aug 17, 2025

    @ryoppippi
    Member

    really so it is become worth...?
    thank you for try it out as always!!

  10. ryoppippi commented on Aug 18, 2025

    @ryoppippi
    Member

    oh use v15.9.9 instead!!

  11. ryoppippi commented on Aug 18, 2025

    @ryoppippi
    Member

    so it depends on users' machine power, os, network or so it is hard to reproduce it.
    in my env it works so well.
    so i need your feedback!!

  12. ursisterbtw commented on Aug 19, 2025

    @ursisterbtw

    so it depends on users' machine power, os, network or so it is hard to reproduce it. in my env it works so well. so i need your feedback!!

    the update fixed the process spawning issue for me on ubuntu 25.04 👍

  13. DevVig commented on Aug 20, 2025

    @DevVig

    I'm still having this issue, and its making CC Usage and status line edits unusable at this point - as it locks up the system still. @ursisterbtw - Mac OS Dev Beta here.

  14. b3nw commented on Aug 21, 2025

    @b3nw

    Same issue here

    24.04.2 LTS (GNU/Linux 6.8.12-9-pve x86_64)
    b3nw@vscode-dev:~$ ccusage --version
    15.9.3
    b3nw@vscode-dev:~$ claude --version
    1.0.86 (Claude Code)
    
  15. AhmadShbeeb commented on Aug 22, 2025

    @AhmadShbeeb

    same here using hyprland on arch Kernel: 6.12.43-1-lts , zsh 5.9
    ❯ ccusage --version 16.1.1 ❯ claude --version 1.0.88 (Claude Code)

  16. ryoppippi commented on Aug 22, 2025

    @ryoppippi
    Member

    So configure refreshinterval

  17. ryoppippi commented on Aug 22, 2025

    @ryoppippi
    Member

    I mean it depends on your machine. If your machine is faster enough this issue doesn't happen. But you can add refreshinterval option to manage it

  18. ryoppippi commented on May 17, 2026

    @ryoppippi
    Member

    The statusline process-spawning issue has been addressed in the current implementation with per-session semaphore/cache handling, active updater process detection, and refresh interval support. Remaining concerns around semaphore placement and multi-user tmpdir behavior are better tracked in #755 against the current code, so I am closing this as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions