Skip to content

fix: prevent memory leak by cancelling all timers in onClose#885

Open
vibhutomer wants to merge 1 commit intoCCExtractor:mainfrom
vibhutomer:fix-timer-leak
Open

fix: prevent memory leak by cancelling all timers in onClose#885
vibhutomer wants to merge 1 commit intoCCExtractor:mainfrom
vibhutomer:fix-timer-leak

Conversation

@vibhutomer
Copy link

@vibhutomer vibhutomer commented Mar 12, 2026

Description

This PR addresses a memory leak in the HomeController where background timers were not being properly disposed of when the controller was closed.

Proposed Changes

  • Modified the onClose() method in lib/app/modules/home/controllers/home_controller.dart.
  • Added explicit .cancel() calls for the periodic _timer and the nullable _delayTimer.
  • This ensures that background processes are halted when the user navigates away from the Home screen, saving battery and preventing potential null-pointer exceptions during UI updates.

Fixes #884

Screenshots

N/A - This is a background performance fix. No visible UI changes, but it improves memory management and battery efficiency.

Checklist

  • Tests have been added or updated to cover the changes
  • Documentation has been updated to reflect the changes
  • Code follows the established coding style guidelines
  • All tests are passing

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.

Bug: Memory Leak in HomeController due to uncancelled Timers

1 participant