How to Fix VS Code High CPU Usage

Visual Studio Code is a highly popular and lightweight text editor, but users occasionally encounter performance issues where the application consumes an unusually high percentage of CPU resources. This guide provides a direct, step-by-step troubleshooting workflow to help you identify the root cause of the slowdown and implement effective solutions. You will learn how to use built-in diagnostics, isolate problematic extensions, and adjust specific settings to restore VS Code to its optimal, lightweight state.

Step 1: Identify the Culprit with Process Explorer

VS Code has a built-in task manager called the Process Explorer. This tool shows exactly which process (such as a utility process, the main window, or a specific extension) is consuming your CPU.

  1. Open VS Code.
  2. Click on Help in the top menu bar, then select Open Process Explorer (or press Ctrl+Alt+P / Cmd+Option+P on some systems).
  3. Look at the CPU % column to find the process with the high percentage.
  4. If the high CPU usage is tied to an extension host or a specific extension process, you have found the source. If it is tied to a file-watching or search process, your project configuration may need adjustment.

Step 2: Test Without Extensions

Extensions are the most common cause of high CPU usage in VS Code. To verify if an extension is causing the issue, you should run VS Code with all extensions temporarily disabled.

  1. Close all running instances of VS Code.

  2. Open your terminal or command prompt.

  3. Launch VS Code from the command line using the following command:

    code --disable-extensions
  4. Work in this clean environment for a few minutes. If the CPU usage returns to normal, an extension is definitely causing the issue.

To find the specific problematic extension, re-enable your extensions one by one (or in halves) until the high CPU usage returns, then uninstall or replace that extension.

Step 3: Optimize File Watcher and Search Settings

VS Code constantly monitors files in your workspace for changes. If you are working on a large project with thousands of files (like a massive node_modules folder or build directories), the file watcher can overload your CPU.

You can exclude heavy folders from being indexed by updating your settings:

  1. Open Settings (Ctrl+, or Cmd+,).
  2. Search for watcher exclude.
  3. Under Files: Watcher Exclude, add patterns for directories you do not need to track. For example:
    • **/node_modules/*
    • **/dist/*
    • **/.git/*
  4. Search for search exclude and ensure similar heavy folders are added to Search: Exclude to prevent the search indexer from constantly scanning them.

Step 4: Disable GPU Acceleration

In some systems, hardware compatibility issues with the Chromium engine underneath VS Code can cause severe CPU spikes. Disabling GPU acceleration can resolve this.

  1. Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P).

  2. Type and select Preferences: Configure Runtime Arguments. This opens the argv.json file.

  3. Add the following line to the JSON configuration:

    "disable-hardware-acceleration": true
  4. Save the file, close VS Code, and restart your computer.

Step 5: Clear VS Code Cache

Corrupted cache files can cause the editor to get stuck in infinite loops, leading to high CPU usage.

  1. Close VS Code.
  2. Navigate to the cache directory on your operating system:
    • Windows: %APPDATA%\Code\Cache and %APPDATA%\Code\CachedData
    • macOS: ~/Library/Application Support/Code/Cache and ~/Library/Application Support/Code/CachedData
    • Linux: ~/.config/Code/Cache and ~/.config/Code/CachedData
  3. Delete the contents of these folders and restart VS Code.