angular/packages/core/src
Kristiyan Kostadinov 990067a0c6 perf(core): avoid storing LView in __ngContext__ (#41358)
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 #41358
2021-04-26 09:31:41 -07:00
..
change_detection refactor(core): remove the need for ɵɵinjectPipeChangeDetectorRef() (#41231) 2021-03-30 16:46:37 -07:00
compiler refactor(compiler): implement ngDeclareInjectable() (#41316) 2021-04-07 13:57:13 -07:00
debug perf(core): avoid storing LView in __ngContext__ (#41358) 2021-04-26 09:31:41 -07:00
di refactor(core): add single type for injector token (#41580) 2021-04-22 10:47:12 -07:00
i18n build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
interface docs(core): Fix typo in JSDoc for AbstractType<T> (#38541) 2020-08-20 09:30:17 -07:00
linker fix(core): Switch emitDistinctChangesOnlyDefaultValue to true (#41121) 2021-03-12 10:47:56 -08:00
metadata refactor(core): add single type for injector token (#41580) 2021-04-22 10:47:12 -07:00
reflection fix(core): detect synthesized constructors that have been downleveled using TS 4.2 (#41305) 2021-03-23 11:23:04 -07:00
render refactor(core): clean up circular dependencies (#39722) 2020-11-18 09:15:29 -08:00
render3 perf(core): avoid storing LView in __ngContext__ (#41358) 2021-04-26 09:31:41 -07:00
sanitization feat(core): manually annotate de-sugarred core tree-shakable providers with @pureOrBreakMyCode (#41096) 2021-03-08 10:30:08 -08:00
testability feat(core): drop support for zone.js 0.10.x (#40823) 2021-02-24 07:58:29 -08:00
util fix(core): address Trusted Types bug in Chrome 83 (#40815) 2021-02-12 16:59:58 -08:00
view fix(core): error if DebugRenderer2.destroyNode is called twice in a row (#41565) 2021-04-12 10:30:11 -07:00
zone fix(core): NgZone coaleascing options should trigger onStable correctly (#40540) 2021-02-22 10:01:31 -08:00
application_init.ts docs(core): add usage examples for APP_INITIALIZER token (#41095) 2021-03-08 09:58:18 -08:00
application_module.ts perf(core): use ngDevMode to tree-shake warning (#40876) 2021-02-17 11:41:28 -08:00
application_ref.ts perf(core): use ngDevMode to tree-shake warning (#40876) 2021-02-17 11:41:28 -08:00
application_tokens.ts docs: clean up api doc in core (#37053) 2020-06-30 12:11:15 -07:00
change_detection.ts fix(core): remove CollectionChangeRecord symbol (#38668) 2020-09-02 16:45:19 -07:00
codegen_private_exports.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
console.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
core.externs.js build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
core.ts fix(core): do not error when ngDevMode is undeclared (#39415) 2020-10-27 10:45:18 -07:00
core_private_export.ts refactor(core): rename ɵɵInjectableDef interface to ɵɵInjectableDeclaration (#41316) 2021-04-07 13:57:12 -07:00
core_render3_private_export.ts refactor(compiler-cli): introduce declaration function to declare class metadata (#41200) 2021-04-12 10:41:17 -07:00
di.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
error_handler.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
errors.ts refactor(core): reduce the number of circular deps (#38805) 2020-09-18 11:20:08 -07:00
event_emitter.ts refactor(core): remove deprecated rxjs signature usage in event emitter and make more minifier-friendly (#41450) 2021-04-07 11:53:09 -07:00
ivy_switch.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
linker.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
metadata.ts refactor(core): move injectAttributeImpl to avoid cycles (#37085) 2020-11-19 12:19:42 -08:00
platform_core_providers.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
r3_symbols.ts refactor(core): rename ɵɵInjectableDef interface to ɵɵInjectableDeclaration (#41316) 2021-04-07 13:57:12 -07:00
render.ts refactor(core): clean up circular dependencies (#39722) 2020-11-18 09:15:29 -08:00
version.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
zone.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00