Skip to content

Weird route caching, or leak on routed component's properties #54241

@amdor

Description

@amdor

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

No

Description

Setup:

  • Angular: 17.1.0, Chrome
  • a new application with 2 components and routing
  • components’ HTML is just a link back and forth
  • a property eating a lot of space in component B so it’s easy to see the leak
  • Chrome’s performance monitoring

When you navigate away from component B, and run GC manually the heap size does not shrink back (since I used big properties it's a 50MB difference).

For all observations and scenarios I tried see this dramatic-titled article

Live: https://blitz-1a72a.firebaseapp.com/
StackBlitz: https://stackblitz.com/edit/stackblitz-starters-ljmfcl?file=src%2Fsecond.component.ts

Please provide a link to a minimal reproduction of the bug

https://blitz-1a72a.firebaseapp.com/

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular 17.1.0

Anything else?

Since the supposed leak is not growing every time I navigate back and forth I'm suspecting some sort of caching. But child component's of B are properly cleaned up, B's DOM objects (nodes) are also properly cleaned up (unless there is a ViewChild in B, see the @for I added and the slight memory decrease when navigating back), so I'm wondering if it really is some sort of caching how much sense does it make to partially cache destroyed routed components? How many cache hits would there be, are top level routing components always initialised with the same data? (with random string I made sure there is cache hit in my case)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions