-
Notifications
You must be signed in to change notification settings - Fork 293
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
OverlayMixin causes a memory leak #2300
Comments
The memory leak has more than one problem areas. Indeed, the extra line in the With minimal edits we could use a WeakMap for caching styles
|
Unfortunately, the fix is not so simple: Some of the errors can easily be fixed by checking if the manager has the controller to begin with. Still, 2 errors remain with that approach:
|
I've looked into using a WeakSet instead of an array in the OverlayManager, but at some point the |
Got it working: #2302 |
Reproduction Recipe
Expected behavior
There are no detached HTMLElements
Actual Behavior
The component with the overlay-mixin can not be garbage collected.
Additional context
This bug has also been tested and reproduced with the LionSelectRich.
Based on research this bug is partially caused by the OverlayManager, which adds every OverlayController to a list, but never removes it.
The OverlayController should probably be removed from the list during the disconnectedCallback of the OverlayMixin. Unfortunately even when taking this step the memory leak persists so there must be another cause for the memory leak.
Lion version
0.7.3
Code base example
https://github.com/Sciurus7/lion-overlay-mixin-memory-leak
Additional research notes
The memory leak definitely seems to be linked to the OverlaysManager. When setting this.manager to null in the OverlayController constructor the memory leak will disappear. Some data collected during the investigation.
While the OverlayConstructor will add itself to a list in the OverlaysManager during its initialization, it never removes itself of this list while it is being removed. This can be remedied by removing the OverlayController from that list when it’s torndown. This should be done done in the OverlayMixin:
Even after the above change the memory leak persists. This happens even when the OverlayManager is basically an empty class with just empty methods and no props.
During a simple lifecycle of a component with an OverlayMixin where it is just created and removed he following methods are called on the manager:
The text was updated successfully, but these errors were encountered: