Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

fix(code-index): prevent indexing memory leaks - #10390

Open
hannesrudolph wants to merge 2 commits into
mainfrom
fix/code-index-memory-leaks
Open

fix(code-index): prevent indexing memory leaks#10390
hannesrudolph wants to merge 2 commits into
mainfrom
fix/code-index-memory-leaks

Conversation

@hannesrudolph

@hannesrudolphhannesrudolph commented Dec 30, 2025

Copy link
Copy Markdown
Contributor

Related to Roo-Code PR #7666 (terminal output memory retention), this audits the codebase indexing feature for similar long-lived retention and fixes two leak patterns:

  1. .rooignore watcher lifecycle
  • Avoid creating file watchers during one-shot directory scans.
  • Ensure ignore controller watchers are disposed when recreating/disposing the code index services.
  1. web-tree-sitter parse tree disposal
  • Ensure parse trees are deleted after use to prevent WASM heap growth.

Key changes:

  • src/core/ignore/RooIgnoreController.ts: add watch option to skip watcher creation.
  • src/services/code-index/processors/scanner.ts: use watch:false and dispose in finally.
  • src/services/code-index/processors/file-watcher.ts + src/services/code-index/manager.ts: explicit ownership + disposal of shared RooIgnoreController.
  • src/services/code-index/processors/parser.ts + src/services/tree-sitter/index.ts: delete parse trees.

Tests:

  • Updated scanner/file-watcher/parser tests and added tree-sitter tree-disposal test.

Important

Fix memory leaks in code indexing by controlling file watcher creation and ensuring parse tree disposal.

  • Behavior:
    • Avoid creating file watchers during one-shot directory scans in RooIgnoreController.
    • Ensure RooIgnoreController watchers are disposed in manager.ts and file-watcher.ts.
    • Ensure parse trees are deleted after use in parser.ts and index.ts.
  • Options:
    • Add watch option to RooIgnoreController to control watcher creation.
  • Tests:
    • Update tests in file-watcher.spec.ts, parser.spec.ts, and scanner.spec.ts.
    • Add tree-disposal.spec.ts to test parse tree disposal.

This description was created by Ellipsis for 90f010f. You can customize this summary. It will automatically update as commits are pushed.

@dosubotdosubotBot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Dec 30, 2025
@ghost

ghost commented Dec 30, 2025

Copy link
Copy Markdown

OroocleClockSee task on Roo Cloud

Re-review complete (90f010f). No issues flagged in the latest changes.

  • No issues to resolve
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolphhannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 30, 2025
@hannesrudolphhannesrudolph moved this from Triage to PR [Draft / In Progress] in Roo Code RoadmapJan 8, 2026
@hannesrudolphhannesrudolph added PR - Draft / In Progress and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jan 8, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bugSomething isn't workingPR - Draft / In Progresssize:LThis PR changes 100-499 lines, ignoring generated files.

Projects

No open projects
Status: PR [Draft / In Progress]

Development

Successfully merging this pull request may close these issues.

1 participant

@hannesrudolph