fix: resolve memory leaks causing VSCode crashes with hierarchical tasks #5769
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses issue #5768 where VSCode crashes when using Roo for extended periods, particularly with hierarchical child tasks.
Problem
Users reported VSCode freezing and requiring restarts when using Roo extensively, especially when creating deeper hierarchies of child tasks. The crashes were becoming more frequent and causing black screens and multiple VSCode resets.
Root Cause Analysis
Investigation revealed several critical memory leak sources:
Solution
Implemented comprehensive memory management improvements:
ClineProvider Enhancements (
src/core/webview/ClineProvider.ts)removeClineFromStack(): Added comprehensive cleanup verification with timeout protectionensureTaskDisposal(): New method for timeout-protected disposal verificationclearTaskReferences(): Method to break circular references and clean up task hierarchydispose(): Enhanced error handling and complete stack cleanupTask Disposal Improvements (
src/core/task/Task.ts)dispose(): Comprehensive error handling with timeout protectionclearTaskHierarchyReferences(): Defensive cleanup for task hierarchy referencesisDisposedflag: Prevents multiple disposal attempts and resource leaksKey Features
Testing
Impact
This fix should resolve the VSCode crashes and freezing issues by:
Fixes #5768
Important
Fixes memory leaks in VSCode by improving task disposal and preventing circular references in
Task.tsandClineProvider.ts.Task.tsandClineProvider.ts.clearTaskHierarchyReferences()inTask.tsandclearTaskReferences()inClineProvider.tsto prevent circular references.dispose()inTask.tsnow includes comprehensive error handling and timeout protection.ensureTaskDisposal()inClineProvider.tsensures tasks are disposed of with timeout protection.Task.ts.This description was created by
for 83aae4d. You can customize this summary. It will automatically update as commits are pushed.