@shawn777/vscode-cpu-monitor
v1.2.0
Published
Monitor and kill VS Code zombie processes with high CPU usage
Downloads
34
Maintainers
Readme
VSCode CPU Monitor
A Node.js process monitor designed to solve the VS Code high CPU usage problem.
VS Code's Code Helper (Plugin) process often becomes a zombie process with extremely high CPU usage (90%+), causing system lag and battery drain. This tool automatically detects and terminates such runaway processes.
Installation
npm
npm i -g @shawn777/vscode-cpu-monitorHomebrew (macOS/Linux)
brew tap xylvxy/vscode-cpu-monitor https://github.com/xylvxy/vscode-cpu-monitor.git
brew install vscode-cpu-monitorFeatures
Core Features
- Process Monitoring - Periodically scan system processes and detect CPU usage
- Zombie Process Detection - Identify processes with abnormally high CPU usage
- Auto Termination - Kill processes that meet the termination criteria
- Watch List - Only monitor processes in the watch list to avoid killing critical system processes
Watch List
Initial watch list:
Code Helper (Plugin)Configuration
| Option | Description | Default |
|--------|-------------|---------|
| cpuThreshold | CPU usage threshold (%) | 80 |
| minRunTime | Minimum run time (s) | 600 |
| cpuHitCount | Consecutive CPU threshold hits | 3 |
| checkInterval | Check interval (ms) | 60000 |
| watchList | Process watch list | See above |
White List
Processes in the white list will never be terminated, even if they match the watch list and exceed resource thresholds. Configuration includes common processes and platform-specific system processes.
Default White List:
| Category | Processes | |----------|-----------| | Common | node, npm, git | | macOS | launchd, kernel_task, WindowServer, Finder, Dock, etc. | | Linux | systemd, init, kthreadd, sshd, cron, etc. | | Windows | System, csrss, svchost, explorer, dwm, etc. |
Termination Rules
A process will be terminated only when ALL of the following conditions are met:
- In watch list - Process name matches any item in watchList
- Not in white list - Process is not protected by the white list
- Run time threshold - Running time >=
minRunTime(avoids killing newly started processes) - Resource threshold exceeded:
- CPU exceeds
cpuThresholdforcpuHitCountconsecutive checks
- CPU exceeds
Notes:
- CPU uses consecutive hit counting to avoid false kills from temporary spikes
- CPU counter resets automatically when CPU returns to normal
Execution Flow
- Scan system processes at configured interval
- Filter processes matching the watch list
- Skip processes in the white list
- Check CPU usage
- Kill processes exceeding thresholds
- Log all actions
Usage
vscode-cpu-monitor [options]Options
| Option | Description |
|--------|-------------|
| -l, --log [date] | View logs (default: today, format: YYYY-MM-DD) |
| -s, --stop | Stop the background daemon |
| -h, --help | Show help message |
Examples
# Start monitor in background (default)
vscode-cpu-monitor
# View today's logs
vscode-cpu-monitor -l
# View logs for specific date
vscode-cpu-monitor -l 2024-01-15
# Stop background daemon
vscode-cpu-monitor -sLogging
- Log directory:
log/ - Daily log files:
YYYY-MM-DD.log - Output to both console and file
Log Levels:
| Level | Description |
|-------|-------------|
| INFO | General information (startup, process discovery) |
| WARN | Warnings (CPU threshold exceeded) |
| ERROR | Errors (operation failed) |
| KILL | Termination records |
Log Format:
[2026/2/12 14:05:15] [INFO] === Code Monitor Started ===
[2026/2/12 14:05:15] [WARN] PID: 8888, CPU: 98.8% exceeded threshold 80%
[2026/2/12 14:05:15] [KILL] PID: 8888, Command: Code Helper (Plugin)...Tech Stack
- Node.js
- Supported Platforms: macOS / Linux / Windows
Platform Support
| Platform | Get Processes | Kill Process |
|----------|---------------|--------------|
| macOS | ps -eo pid,%cpu,rss,etime,command | kill -9 |
| Linux | ps -eo pid,%cpu,rss,etime,command | kill -9 |
| Windows | PowerShell Get-Process | taskkill /F /PID |
