Fix memory leaks in dashboard components#225
Open
GazzyLee wants to merge 1 commit into
Open
Conversation
- Add timeout tracking and cleanup in useLiveFeed hook to prevent memory leaks from event highlight timeouts - Add timeout tracking and cleanup in CopyButton component (RawDataDialog) - Add timeout tracking and cleanup in ExportDataDialog - Add clarifying comment for existing interval cleanup in SecurityMetricsDashboard - All setTimeout calls now properly tracked and cleared on component unmount - WebSocket connections properly closed on unmount via existing disconnect cleanup Resolves: Navigating away from main dashboard stream view while active event listener timers or intervals are spinning leaks client heap memory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Navigating away from the main dashboard stream view while active event listener timers or intervals are spinning leaks client heap memory, steadily slowing down the app context over time.
Root Cause
Several dashboard components were creating
setTimeoutcalls without tracking or cleaning them up on component unmount, causing orphaned timers to accumulate in memory:Solution
Systematically added timeout tracking and cleanup logic to all affected components:
Changes Made
lib/hooks/useLiveFeed.ts
timeoutIdsRefto track all setTimeout IDs created for event highlight animationsdisconnect()function to clear all pending timeouts before cleanupcomponents/dashboard/RawDataDialog.tsx
timeoutRefto CopyButton componentuseEffectcleanup to clear timeout on component unmountcomponents/dashboard/ExportDataDialog.tsx
timeoutRefto track export completion timeoutuseEffectcleanup to clear timeout on component unmountcomponents/dashboard/SecurityMetricsDashboard.tsx
Acceptance Criteria
Testing
Impact
This fix prevents memory leaks that occur when users navigate away from the dashboard while live feeds are active, improving application performance and stability over time.
##Closes #43