-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Description
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.
All the subscriptions in the screenshot above are being unsubscribed in the dragRef._removeSubscriptions()
method except for the _resizeSubscription
.
As a result, the _resizeSubscription
is not closed within the dragRef.dispose()
method.
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):