Skip to content

fix: resolve memory leaks in long-running VSCode sessions #2639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ndcunningham
Copy link
Contributor

Summary

Fixes several memory leak issues that accumulate during long-running VSCode sessions, addressing the high memory usage seen in Activity Monitor when VSCode runs for days without restart.

Changes Made

  • Language Model Cache: Fixed interval management to prevent accumulation of cleanup intervals
  • MCP Server: Added proper tracking and cleanup of keep-alive intervals
  • Workspace Refresh: Prevented timeout accumulation with proper cleanup and 10s limits
  • Project Cache: Added 5-minute expiration to prevent unbounded cache growth

This commit addresses several memory leak issues that accumulate during
long-running VSCode sessions:

1. **Language Model Cache Interval Management**: Fixed potential interval
   accumulation by properly clearing existing intervals before creating new ones

2. **MCP Server Keep-Alive Intervals**: Added tracking of all active intervals
   and comprehensive cleanup in stopMcpServer() to prevent orphaned intervals

3. **Workspace Refresh Timeout Accumulation**: Prevented setTimeout accumulation
   in refreshWorkspaceWithBackoff by tracking and clearing existing timeouts,
   plus added 10-second timeout limits to prevent infinite waits

4. **Project Path Cache Unbounded Growth**: Added 5-minute cache expiration
   to prevent indefinite growth of _rootProjectMap cache

These fixes should significantly reduce memory usage in Activity Monitor
when running VSCode for extended periods (days) without restart.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@ndcunningham ndcunningham requested a review from MaxKless as a code owner July 25, 2025 17:23
Copy link

nx-cloud bot commented Jul 25, 2025

View your CI Pipeline Execution ↗ for commit 63a1acf

Command Status Duration Result
nx affected --targets=build,test,e2e-ci --confi... ❌ Failed 1h 24s View ↗
nx-cloud record -- ./gradlew :intellij:ktfmtChe... ✅ Succeeded 3s View ↗
nx-cloud record -- ./gradlew projectReportAll ✅ Succeeded 27s View ↗

☁️ Nx Cloud last updated this comment at 2025-07-25 18:29:11 UTC

@ndcunningham ndcunningham marked this pull request as draft July 25, 2025 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant