Memory leak when creating/destroying Web Components exported with @angular/elements
Which @angular/* package(s) are the source of the bug?
elements
Is this a regression?
No
Description
While experimenting to get the hang behind https://github.com/angular/angular/issues/38778 I discovered that the heap memory increases over the time when web-components are created and destroyed (removed from the DOM).
Within this simple GH project it can be reproduced: https://github.com/aetzlecx/ng-elements-memory-leak
After a couple of thousand creations/destroys it can be seen that the heap increases:

Please provide a link to a minimal reproduction of the bug
https://github.com/aetzlecx/ng-elements-memory-leak
Please provide the exception or error you saw
there are no exceptions/errors, just an increasing heap
Please provide the environment you discovered this bug in
No response
Anything else?
No response
Could it be that this issue is related to https://github.com/angular/angular/issues/41047?
Thx for reporting this, @aetzlecx :+1: Yes, #41047 could be related. Can you please check whether this also happens when using AOT and also if it happens in production mode (or only in dev mode)?
I did some tests on the provided repo (v11, which does not include the fix for #41001 ). There is indeed a high memory usage but it's cleared by the garbage collector.
So no issue !
I did some tests on the provided repo (v11, which does not include the fix for #41001 ). There is indeed a high memory usage but it's cleared by the garbage collector.
So no issue !
Thanks for cross checking. Can I ask how you tested this? Did you use my original code or something else?
Yes, I did use the repo you provided !
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.
