-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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(store-devtools): resolve memory leak when devtools are destroyed #3965
Conversation
✅ Deploy Preview for ngrx-io canceled.Built without sensitive environment variables
|
The failing CIrcle is unrelated since it fails to install the Chrome driver. |
Thanks @arturovt. I pushed up a fix for CI to run the browser tests correctly. |
this.extensionStartSubscription = extensionStartSubscription; | ||
this.stateSubscription = liftedStateSubscription; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, why not just unsubscribe from these in the ngOnDestroy
instead of adding a destroy Subject?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, my VSCode initially marked them as unused, so I removed them first. Then I added takeUntil
since I saw it's already being used in other places too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can revert properties back and unsubscribe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that approach would be better in this case because the subscription references are already there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
This commit updates the implementation of the `StoreDevtools` and adds the `ngOnDestroy` hook, which ensures the teardown of internal subscriptions. Previously, this caused an excessive memory leak because subscription callbacks created closures that captured `this`, preventing `this` from being garbage collected.
StoreDevtools
This commit updates the implementation of the
StoreDevtools
and adds thengOnDestroy
hook, which ensures the teardown of internal subscriptions. Previously, this caused an excessive memory leak because subscription callbacks created closures that capturedthis
, preventingthis
from being garbage collected.