Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(memory): Unsubscribe event listeners when using Observable.fromEvent #5325

Merged
merged 3 commits into from Jun 27, 2017
Merged

fix(memory): Unsubscribe event listeners when using Observable.fromEvent #5325

merged 3 commits into from Jun 27, 2017

Conversation

Eddman
Copy link
Contributor

@Eddman Eddman commented Jun 23, 2017

Listeners created using Observable.fromEvent have to be unsubscribed to prevent memory leaks. Especially when the target is document/window.

In addition fixed a small leak in CdkMonitorFocus.

Future TODOs: few services are registering listeners on window/document (eg. FocusOriginMonitor) and theses produce huge leaks in Karma test suites. Angular creates new instances for each spec (in addition to new Zone for each spec). An issue already raised in Zone.js (angular/zone.js/issues/822) to consult what's the correct approach.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 23, 2017
@jelbourn
Copy link
Member

@Eddman can you rebase this PR?

@Eddman
Copy link
Contributor Author

Eddman commented Jun 26, 2017

@jelbourn Done.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jun 26, 2017
@tinayuangao tinayuangao merged commit 1b351cd into angular:master Jun 27, 2017
@Eddman Eddman deleted the memory_fix branch June 29, 2017 08:15
amcdnl pushed a commit to amcdnl/material2 that referenced this pull request Jul 8, 2017
…ent (angular#5325)

* Fixed memory leak in CdkMonitorFocus

* Unsubscribe events that are registered under window/document using Observable.fromEvent.

* Fixed tslint problems.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants