mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
This commit addresses the grey screen issue that occurs every 15-20 minutes by implementing comprehensive memory leak fixes and proactive memory management: **Root Cause Analysis:** - LRU cache with excessive size (250 items) and long TTL (15 minutes) causing memory buildup - Timer leaks in WorkspaceTracker where timers weren't properly nullified after clearing - Insufficient resource cleanup in Task and ClineProvider disposal methods - Lack of proactive memory management and pressure detection **Memory Management Improvements:** 1. **LRU Cache Optimization** (ChatView.tsx): - Reduced cache size from 250 to 100 items - Shortened TTL from 15 minutes to 5 minutes - Added periodic cleanup every 2 minutes to prevent accumulation 2. **Timer Leak Fixes** (WorkspaceTracker.ts): - Fixed timer management by properly nullifying resetTimer and updateTimer after clearing - Prevents memory leaks from dangling timer references 3. **Enhanced Resource Disposal**: - Task.ts: Improved dispose() with comprehensive memory clearing and error handling - ClineProvider.ts: Enhanced disposal methods with better error handling and resource cleanup 4. **Proactive Memory Management System**: - Created MemoryManager utility (src/utils/memoryManager.ts) for centralized cleanup - Singleton pattern with periodic garbage collection and resource cleanup - Integrated into extension lifecycle for automatic management 5. **Memory Pressure Detection** (App.tsx): - Added webview-side memory monitoring using browser performance APIs - Checks memory usage every 2 minutes and triggers cleanup at 75% threshold - Communicates memory pressure to extension for reactive cleanup 6. **Message Handling Enhancement**: - Added memoryPressure message type to WebviewMessage.ts - Implemented memory pressure handler in webviewMessageHandler.ts - Triggers aggressive cleanup for critical memory usage (>90%) **Technical Implementation:** - Uses browser performance.memory API for accurate memory tracking - Implements both reactive (pressure-based) and proactive (periodic) cleanup strategies - Maintains backward compatibility with existing functionality - Includes comprehensive test coverage for MemoryManager **Testing:** - Added unit tests for MemoryManager functionality - Verified timer cleanup and resource disposal patterns - Tested memory pressure detection and cleanup triggers This solution prevents the grey screen crashes by addressing memory accumulation before it reaches critical levels, ensuring stable long-term operation of the Roo Code extension. |
||
|---|---|---|
| .. | ||
| audio | ||
| public | ||
| src | ||
| .gitignore | ||
| components.json | ||
| eslint.config.mjs | ||
| index.html | ||
| jest.config.cjs | ||
| package.json | ||
| tsconfig.json | ||
| turbo.json | ||
| vite.config.ts | ||