angular icon indicating copy to clipboard operation
angular copied to clipboard

Memory leak when creating/destroying Web Components exported with @angular/elements

Open aetzlecx opened this issue 4 years ago • 2 comments

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:

gh_bug_heap_detailed2

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

aetzlecx avatar Sep 27 '21 08:09 aetzlecx

Could it be that this issue is related to https://github.com/angular/angular/issues/41047?

aetzlecx avatar Sep 27 '21 08:09 aetzlecx

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)?

gkalpak avatar Sep 29 '21 08:09 gkalpak

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.

Screenshot 2023-07-05 at 01 08 48

So no issue !

JeanMeche avatar Jul 04 '23 23:07 JeanMeche

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.

Screenshot 2023-07-05 at 01 08 48

So no issue !

Thanks for cross checking. Can I ask how you tested this? Did you use my original code or something else?

aetzlecx avatar Jul 05 '23 05:07 aetzlecx

Yes, I did use the repo you provided !

JeanMeche avatar Jul 05 '23 06:07 JeanMeche

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.