GitHub Copilot in VS Code Crashes With Large Workspaces: Fix
🔍 WiseChecker

GitHub Copilot in VS Code Crashes With Large Workspaces: Fix

GitHub Copilot in VS Code can crash or become unresponsive when you open a workspace containing hundreds or thousands of files. This happens because Copilot scans the entire open folder to build its context for code suggestions, and large workspaces consume excessive memory and CPU. This article explains why Copilot fails in large projects and provides three targeted fixes to restore stability.

Key Takeaways: Fixing GitHub Copilot Crashes in Large VS Code Workspaces

  • VS Code settings.json > git.ignoredRepos: Exclude large Git repositories from Copilot scanning to reduce memory load.
  • VS Code settings.json > github.copilot.enable: Disable Copilot for specific file types or languages that you do not need suggestions for.
  • VS Code > File > Add Folder to Workspace: Instead of opening the entire root folder, add only the subfolders you actively work on.

Why Copilot Crashes in Large Workspaces

GitHub Copilot uses a language model that analyzes the current file and nearby files to generate suggestions. When you open a large workspace, Copilot indexes every file in the folder tree. For projects with more than 500 files, this indexing can consume over 1 GB of RAM and cause the VS Code extension host process to exceed its memory limit. The result is a frozen editor, a crash, or an error message that reads “Extension host terminated unexpectedly.”

The root cause is not a bug in Copilot itself. It is a resource constraint. The extension host in VS Code has a default memory limit of 512 MB on 32-bit systems and 1 GB on 64-bit systems. A large workspace with many dependencies, generated files, or node_modules folders easily pushes past that limit. Once the extension host crashes, Copilot stops working until you reload the window.

How Workspace Size Affects Copilot Performance

Copilot does not need to scan every file to provide useful suggestions. It only needs the current file plus a few related files. However, the current version of Copilot in VS Code does not limit its scan scope by default. It reads the entire workspace root, including hidden folders like .git, node_modules, and build output. Each file increases memory usage linearly. A workspace with 10,000 files can cause Copilot to use 2 GB or more of RAM, leading to a crash within seconds of opening the project.

Steps to Stop Copilot From Crashing in Large Workspaces

Apply these fixes in the order shown. Each fix reduces the amount of data Copilot must process. Start with the most effective fix: exclude large folders from Git indexing.

Method 1: Exclude Large Repositories With git.ignoredRepos

  1. Open VS Code settings.json
    Press Ctrl+Shift+P to open the Command Palette. Type Preferences: Open Settings (JSON) and press Enter.
  2. Add the git.ignoredRepos setting
    Insert this line inside the JSON object:
    "git.ignoredRepos": ["C:/path/to/large-repo", "D:/other-repo"]
    Replace the paths with the absolute paths of the large Git repositories in your workspace. Use forward slashes on Windows.
  3. Save and reload the window
    Press Ctrl+S to save settings.json. Then press Ctrl+Shift+P, type Developer: Reload Window, and press Enter.

This setting tells Copilot to skip indexing those Git repos entirely. It is the fastest way to reduce memory usage because Copilot stops scanning the largest folders in your workspace.

Method 2: Disable Copilot for Specific File Types

  1. Open VS Code settings.json
    Press Ctrl+Shift+P and run Preferences: Open Settings (JSON).
  2. Add the github.copilot.enable setting
    Insert this block inside the JSON object:
    "github.copilot.enable": {
    "": true,
    "plaintext": false,
    "yaml": false,
    "markdown": false
    }

    Set the value to false for any language where you do not need Copilot suggestions. The asterisk keeps Copilot enabled for all other languages.
  3. Save and reload the window
    Press Ctrl+S, then Ctrl+Shift+P and run Developer: Reload Window.

Disabling Copilot for documentation, config, or generated files prevents the extension from loading those files into memory. This reduces the total file count that Copilot processes.

Method 3: Open Only Subfolders Instead of the Root

  1. Close the current workspace
    Press Ctrl+Shift+W to close the workspace. Do not save the workspace file if prompted.
  2. Add individual subfolders to a new workspace
    Go to File > Add Folder to Workspace. Select only the subfolders you need for your current task. For example, instead of opening the entire src folder, open only src/components and src/utils.
  3. Save the workspace file
    Go to File > Save Workspace As. Give the file a name like frontend.code-workspace. This lets you reopen the same subset of folders later without repeating the selection.

This method is the most manual but gives you complete control over which files Copilot can see. It is the best option when you work on only a portion of a monorepo.

If Copilot Still Has Issues After the Main Fix

The three methods above resolve crashes in most large workspaces. However, some edge cases require additional steps.

Copilot Generates No Suggestions After Excluding Folders

If you exclude too many folders, Copilot may have no context to work with. Open the Copilot status icon in the VS Code status bar. It shows whether Copilot is active. If it is dimmed, you have disabled Copilot for the current file type or excluded the folder that contains your active file. Re-enable Copilot for that language in settings.json by setting its value to true.

Extension Host Still Crashes After Applying All Fixes

If the extension host continues to crash, the workspace might contain a single file that is extremely large, such as a database dump or a minified JavaScript bundle. Open the workspace and look for files over 10 MB. Delete or move those files outside the workspace folder. Then reload the window.

Copilot Crashes Only When Opening Certain File Types

Some file types, such as JSON with many nested objects or YAML with thousands of lines, cause Copilot to consume extra memory. Open settings.json and add those specific file extensions to the disabled list in github.copilot.enable. For example, add "json": false if you work with large JSON config files.

Copilot Crash Behavior: Large Workspace vs Small Workspace

Item Large Workspace (500+ files) Small Workspace (under 100 files)
Memory usage by Copilot 800 MB to 2 GB 100 MB to 300 MB
Extension host crash frequency Often within 2 minutes of opening Rare
Effect of git.ignoredRepos Reduces memory by 40-60% Minimal effect
Effect of disabling file types Reduces file count by 30-50% Minimal effect
Recommended fix order git.ignoredRepos, then disable file types, then subfolders None needed

GitHub Copilot in VS Code is stable for small to medium projects but requires explicit configuration for large workspaces. Use git.ignoredRepos to exclude entire repositories, disable Copilot for file types you do not need, and open only the subfolders you actively edit. After applying these changes, Copilot will generate suggestions without crashing, even in monorepos with thousands of files. For ongoing maintenance, periodically review your settings.json to ensure excluded paths still match your current project structure.