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

[drag-drop] Memory Leak: DragRef _resizeSubscription - failing to unsubscribe #17255

Closed
Achilles1515 opened this issue Oct 1, 2019 · 1 comment · Fixed by #17257 or hrueger/AGLight#112
Assignees
Labels
P2 The issue is important to a large percentage of users, with a workaround

Comments

@Achilles1515
Copy link

After fighting a memory leak in my app (involving dynamically generating/removing CDK drag-drop items - and those removed items still lingering around in memory) for longer than I'd like to admit, I finally figured out the memory leak only occurs when the cdkDrag items contain a cdkDragBoundary property.

This bug was introduced in release 8.2.0 (#16874) when _resizeSubscription was added.

image

All the subscriptions in the screenshot above are being unsubscribed in the dragRef._removeSubscriptions() method except for the _resizeSubscription.

image

As a result, the _resizeSubscription is not closed within the dragRef.dispose() method.

image

Simply adding this._resizeSubscription.unsubscribe(); to the dragRef._removeSubscriptions() method appears to fix the problem.

I just double checked and the memory leak I am experiencing does not occur on CDK v8.1.4.

Environment

  • Angular:
  • CDK/Material: 8.2.0+
  • Browser(s):
  • Operating System (e.g. Windows, macOS, Ubuntu):
@crisbeto crisbeto self-assigned this Oct 1, 2019
@crisbeto crisbeto added has pr P2 The issue is important to a large percentage of users, with a workaround labels Oct 1, 2019
crisbeto added a commit to crisbeto/material2 that referenced this issue Oct 1, 2019
Fixes the viewort resize subscription not being removed when the `DragRef` is destroyed.

Fixes angular#17255.
mmalerba pushed a commit that referenced this issue Oct 18, 2019
Fixes the viewort resize subscription not being removed when the `DragRef` is destroyed.

Fixes #17255.
@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 Nov 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
2 participants