-
Notifications
You must be signed in to change notification settings - Fork 161
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
When removing a custom component with @Tag, a DetachedHTMLElement occurs #14422
Comments
@mshabarov this sounds like something to be taken care in flow |
Thanks @knoobie ! That might be an issue in core. |
Seem to reproduce for me with Edge. In Chrome I used Memory tool and similarly did garbage collect and took a memory snapshot after each 20 click: there the memory consumption increased ~10MB on every iteration, and detached element counts doubled. If using default Divs, Chrome's memory consumption does not increase. So the issue clearly reproduces with Chrome as well. |
With Firefox, with just Divs, the memory consumption seems to grow to a degree, and then drop down eventually. With my-divs the memory consumption just keeps going up. So I suppose I can confirm that this happens on Firefox as well. |
Hello, I just found the issue #13851. Could it be that this bug is a duplicate of the 13851? |
Hi @mshabarov, that is great news!!! I'm looking forward to the results of the re-test! |
Vaadin 14.8.18 now released and it contains the patch for this 18c4058 . |
Hi @mshabarov, I re-tested with V14.8.18 (using a clean workspace and emptying the local Maven repository) and unfortunately the problem still seems to exist - both in the example attached in the issue (see also the new screenshot) as well as in our application, the memory consumption increases when custom components are added to the DOM and does not increase when they are removed afterwards |
Taking a look at a heap dump in Chrome, my guess is that the memory leak may be in Flow client
Flow registers a callback that captures Looking at the retainers tree, the code relative to the |
Did a quick test, changing the code to attach the callback to a promise that gets fulfilled after a second if the custom element is not registered in the meanwhile, and it seems that with this workaround there are leaks
Before garbage collection After garbage collection |
Polymer binding callback was attached to the promise returned by customElements.whenDefined, but this promise may never complete if the input element is not a custom element, causing memory leaks on browser because of element capture. This change introduces a new promise that completes either when whenDefined is fulfilled or after a fixed timeout, allowing the garbage collector to clean resources. Fixes #14422
#14729) Polymer binding callback was attached to the promise returned by customElements.whenDefined, but this promise may never complete if the input element is not a custom element, causing memory leaks on browser because of element capture. This change introduces a new promise that completes either when whenDefined is fulfilled or after a fixed timeout, allowing the garbage collector to clean resources. Fixes #14422
#14729) Polymer binding callback was attached to the promise returned by customElements.whenDefined, but this promise may never complete if the input element is not a custom element, causing memory leaks on browser because of element capture. This change introduces a new promise that completes either when whenDefined is fulfilled or after a fixed timeout, allowing the garbage collector to clean resources. Fixes #14422
#14729) Polymer binding callback was attached to the promise returned by customElements.whenDefined, but this promise may never complete if the input element is not a custom element, causing memory leaks on browser because of element capture. This change introduces a new promise that completes either when whenDefined is fulfilled or after a fixed timeout, allowing the garbage collector to clean resources. Fixes #14422
#14729) Polymer binding callback was attached to the promise returned by customElements.whenDefined, but this promise may never complete if the input element is not a custom element, causing memory leaks on browser because of element capture. This change introduces a new promise that completes either when whenDefined is fulfilled or after a fixed timeout, allowing the garbage collector to clean resources. Fixes #14422
#14729) Polymer binding callback was attached to the promise returned by customElements.whenDefined, but this promise may never complete if the input element is not a custom element, causing memory leaks on browser because of element capture. This change introduces a new promise that completes either when whenDefined is fulfilled or after a fixed timeout, allowing the garbage collector to clean resources. Fixes #14422
#14729) Polymer binding callback was attached to the promise returned by customElements.whenDefined, but this promise may never complete if the input element is not a custom element, causing memory leaks on browser because of element capture. This change introduces a new promise that completes either when whenDefined is fulfilled or after a fixed timeout, allowing the garbage collector to clean resources. Fixes #14422
#14729) (#14755) Polymer binding callback was attached to the promise returned by customElements.whenDefined, but this promise may never complete if the input element is not a custom element, causing memory leaks on browser because of element capture. This change introduces a new promise that completes either when whenDefined is fulfilled or after a fixed timeout, allowing the garbage collector to clean resources. Fixes #14422 Co-authored-by: Marco Collovati <marco@vaadin.com>
#14729) (#14754) Polymer binding callback was attached to the promise returned by customElements.whenDefined, but this promise may never complete if the input element is not a custom element, causing memory leaks on browser because of element capture. This change introduces a new promise that completes either when whenDefined is fulfilled or after a fixed timeout, allowing the garbage collector to clean resources. Fixes #14422 Co-authored-by: Marco Collovati <marco@vaadin.com>
#14729) (#14757) Polymer binding callback was attached to the promise returned by customElements.whenDefined, but this promise may never complete if the input element is not a custom element, causing memory leaks on browser because of element capture. This change introduces a new promise that completes either when whenDefined is fulfilled or after a fixed timeout, allowing the garbage collector to clean resources. Fixes #14422 Co-authored-by: Marco Collovati <marco@vaadin.com>
#14729) (CP: 2.7) (#14758) Polymer binding callback was attached to the promise returned by customElements.whenDefined, but this promise may never complete if the input element is not a custom element, causing memory leaks on browser because of element capture. This change introduces a new promise that completes either when whenDefined is fulfilled or after a fixed timeout, allowing the garbage collector to clean resources. Fixes #14422
#14729) (CP: 2.8) (#14756) Polymer binding callback was attached to the promise returned by customElements.whenDefined, but this promise may never complete if the input element is not a custom element, causing memory leaks on browser because of element capture. This change introduces a new promise that completes either when whenDefined is fulfilled or after a fixed timeout, allowing the garbage collector to clean resources. Fixes #14422
This ticket/PR has been released with Vaadin 14.8.19. |
This ticket/PR has been released with Vaadin 23.2.4. |
Sorry for not getting back earlier to you, as I was out of order thanks to COVID-19. We retested the issue with both the sample program and our main application and the issue is gone - memory usage in the browser is much better now! |
This ticket/PR has been released with Vaadin 23.1.13. |
This ticket/PR has been released with Vaadin 14.9.0.beta1 and is also targeting the upcoming stable 14.9.0 version. |
Description
We have found that the RAM usage within the browser increases with each interaction in our applications.
We could trace this back to an "embed" mechanism in our application, where we dynamically add and remove Components (e.g. HorizontalLayout and VerticalLayout) with a number of child components.
During profiling of the code in the browser with several "embed" actions, we found that a lot of DetachedHTMLElements - each corresponding to one of the components removed from the DOM.
We tried to reproduce this in a minimal example (which is attached below), and found that the DetachedHTMLElements seem to occur when we use custom components with an "@tag" annotation. This is even the case, when the custom component is inherited from the Vaadin Div component - as soon as @tag("my-div") was added, the DetachedHTMLElements occur.
Our first thought was that this might have something to do with reusing a detached HTML component, but when the same component is added and removed twice, two instances of the DetachedHTMLElement can be found.
The issue did not seem to be browser related and occured in our standard browser mix: Chrome, Firefox and Edge. Safari was not tested.
Expected outcome
There should not be a DetachedHTMLElement when a custom Component using @tag is used.
Minimal reproducible example
The
attached project contains an example.
It runs on localhost:8181
Steps to reproduce
Note: we use the Edge browser to reproduce the example because of it "Detached Elements" development tool, but the increased memory usage can also be seen in other browsers.
To reproduce
Environment
Vaadin version(s): 14.8.13
OS: Windows 10 Enterprise (Build 20H2, OS build 19042.1889)
Browsers
Chrome, Firefox, Edge
The text was updated successfully, but these errors were encountered: