-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Ivy doesn’t deallocate memory of destroyed components correctly #35148
Comments
Kudos for such a well documented repro steps. I wish more people would provide examples such as these. It looks to me that |
OK, I was able to find a root cause and will work on a fix. Root cause is that for perf reasons we cache The fix is to simply clear the |
@mhevery Thanks for your support. I have to add something: We used |
Root cause is that for perf reasons we cache `LFrame` so that we don't have to allocate it all the time. To be extra fast we clear the `LFrame` on `enterView()` rather that on `leaveView()`. The implication of this strategy is that the deepest `LFrame` will retain objects until the `LFrame` allocation depth matches the deepest object. The fix is to simply clear the `LFrame` on `leaveView()` rather then on `enterView()` Fix angular#35148
@mhevery In the repro, the |
no need to do anything. |
Root cause is that for perf reasons we cache `LFrame` so that we don't have to allocate it all the time. To be extra fast we clear the `LFrame` on `enterView()` rather that on `leaveView()`. The implication of this strategy is that the deepest `LFrame` will retain objects until the `LFrame` allocation depth matches the deepest object. The fix is to simply clear the `LFrame` on `leaveView()` rather then on `enterView()` Fix angular#35148
Root cause is that for perf reasons we cache `LFrame` so that we don't have to allocate it all the time. To be extra fast we clear the `LFrame` on `enterView()` rather that on `leaveView()`. The implication of this strategy is that the deepest `LFrame` will retain objects until the `LFrame` allocation depth matches the deepest object. The fix is to simply clear the `LFrame` on `leaveView()` rather then on `enterView()` Fix angular#35148
Root cause is that for perf reasons we cache `LFrame` so that we don't have to allocate it all the time. To be extra fast we clear the `LFrame` on `enterView()` rather that on `leaveView()`. The implication of this strategy is that the deepest `LFrame` will retain objects until the `LFrame` allocation depth matches the deepest object. The fix is to simply clear the `LFrame` on `leaveView()` rather then on `enterView()` Fix angular#35148
Root cause is that for perf reasons we cache `LFrame` so that we don't have to allocate it all the time. To be extra fast we clear the `LFrame` on `enterView()` rather that on `leaveView()`. The implication of this strategy is that the deepest `LFrame` will retain objects until the `LFrame` allocation depth matches the deepest object. The fix is to simply clear the `LFrame` on `leaveView()` rather then on `enterView()` Fix #35148 PR Close #35156
…35156) Root cause is that for perf reasons we cache `LFrame` so that we don't have to allocate it all the time. To be extra fast we clear the `LFrame` on `enterView()` rather that on `leaveView()`. The implication of this strategy is that the deepest `LFrame` will retain objects until the `LFrame` allocation depth matches the deepest object. The fix is to simply clear the `LFrame` on `leaveView()` rather then on `enterView()` Fix angular#35148 PR Close angular#35156
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 bug report
Affected Package
The issue is caused by package @angular/core@9.0.0-rc.14, earlier versions probably as well.
Is this a regression?
This issue does not occur in Angular 8 + View Engine.
Description
Ivy does not seem to correctly deallocate memory of destroyed components in all cases. We’ve noticed an issue that when navigating away from a route, at least some of the loaded components are getting destroyed but not deallocated and garbage collected. (The issue might not be restricted to routing.)
The problem is that unnecessary memory is not deallocated, which might lead to problems on mobile and other low-memory devices and might also have security implications (e.g. when sensitive state remains in memory, even after a user has logged out).
🔬 Minimal Reproduction
Here is a minimal repo of the problem. It’s a plain Angular CLI application with three routes and four components:
/#/route1
(Route1Component
) includes theContentComponent
as a child that loads the contents of a large file retrieved via the network into a field of its class duringngOnInit
, consuming some memory. This component logs to the console when it’s being initialized or destroyed./#/route2
(Route2Component
) androute3
(Route3Component
) don’t include this component.Repro steps:
ContentComponent
was destroyed, check the Console tab)Stop
ng serve
and compare this with the behavior of Angular 8:🔥 Exception or Error
The memory of
route1
’s components doesn’t seem to be correctly deallocated when leavingroute1
forroute2
on Angular 9/Ivy:As per DevTools, (at least) the component instance of the
ContentComponent
seems to be retained by acontextLView
array even after it has been destroyed:Is this behavior intended or is this a bug?
Researched by @ManuelRauber, @thomashilzendegen and me.
🌍 Your Environment
Angular Version:
Anything else relevant?
—
The text was updated successfully, but these errors were encountered: