angular/packages/core/test/render3/i18n
Kristiyan Kostadinov 071c8af8ba perf(core): avoid storing LView in __ngContext__ (#45051)
These changes combine #41358 and #41894.

Currently we save a reference to an `LView` on most DOM nodes created by Angular either by saving the `LView` directly in the `__ngContext__` or by saving the `LContext` which has a reference to the `LView`. This can be a problem if the DOM node is retained in memory, because the `LView` has references to all of the child nodes of the view, as well as other internal data structures.

Previously we tried to resolve the issue by clearing the `__ngContext__` when a node is removed (see https://github.com/angular/angular/pull/36011), but we decided not to proceeed, because it can slow down destruction due to a megamorphic write.

These changes aim to address the issue while reducing the performance impact by assigning a unique ID when an `LView` is created and adding it to `__ngContext__`. All active views are tracked in a map where their unique ID is used as the key. We don't need to worry about leaks within that map,  because `LView`s are an internal data structure and we have complete control over when they are  created and destroyed.

Fixes #41047.

PR Close #45051
2022-02-18 13:32:11 -08:00
..
i18n_insert_before_index_spec.ts test(core): make tests more resilient to header offset changes (#41883) 2021-04-29 13:51:07 -07:00
i18n_parse_spec.ts perf(core): avoid storing LView in __ngContext__ (#45051) 2022-02-18 13:32:11 -08:00
i18n_spec.ts fix(core): handle multiple i18n attributes with expression bindings (#41882) 2021-04-30 14:20:15 -07:00