Skip to content

Fix memory leaks and high memory usage problems#6

Open
fklnc94 wants to merge 1 commit intodevfrom
fix/memory-leaks-7035002435365596964
Open

Fix memory leaks and high memory usage problems#6
fklnc94 wants to merge 1 commit intodevfrom
fix/memory-leaks-7035002435365596964

Conversation

@fklnc94
Copy link
Contributor

@fklnc94 fklnc94 commented Mar 21, 2026

This change fixes several potential memory leaks found in the extension:

  1. highlightObserver.ts: The start function now calls stop() if it's already observing, preventing multiple MutationObserver instances and stale timers.
  2. SmartCaptureMode.ts: Fixed the destroy method to explicitly clear animationFrameId and remove the chrome.storage.onChanged listener to prevent memory leaks from unused listeners and active animation frames holding onto detached DOM nodes.
  3. SavedLinkCard.tsx: Correctly tracks timeoutId and pollInterval to clear them when the component unmounts.
  4. useThumbnail.ts: Correctly added a cancelled flag to the useEffect hook to prevent state updates after unmount, and cleared the polling interval upon component unmount.

PR created automatically by Jules for task 7035002435365596964 started by @fklnc94

- Ensure `HighlightObserver` stops prior observer instances before starting a new one.
- Correctly unregister `chrome.storage.onChanged` listener in `SmartCaptureMode` and clear animation frames on `destroy`.
- Clear `setTimeout` and `setInterval` on component unmount in `SavedLinkCard` and `useThumbnail`.
- Use `cancelled` flags to prevent state updates on unmounted React components.

Co-authored-by: fklnc94 <164671181+fklnc94@users.noreply.github.com>
@google-labs-jules
Copy link

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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