mirror of
https://github.com/angular/angular.git
synced 2026-11-23 07:05:14 -05:00
In89d47d814d, RouterLink internals were refactored to use signals, introducing a computed signal `_urlTree`. Because every `<a routerLink>` maintains an active RouterLink directive instance for the lifetime of the view/request, the computed signal permanently cached the returned UrlTree (and its cloned queryParams map and segment tree) in `ReactiveNode.value` for every link. During server-side rendering (SSR), especially when query parameters are large or when `defaultQueryParamsHandling: 'merge'` is enabled, each rendered link held a full copy of the query parameter map pinned in the heap. In an application with 100 links and thousands of query parameters, this pinned over 50 MB of heap per in-flight request, causing server workers to crash with Out of Memory (OOM) under concurrent load (#70908). This change moves the reactive dependencies (`path`, `fragment`, and `queryParams`) directly into `reactiveHref` so it computes and retains only the serialized href string. The intermediate UrlTree and its queryParams dictionary are discarded immediately after serialization and collected during young-generation GC scavenges rather than remaining pinned in the heap. The public `urlTree` getter and `onClick` handler now compute the tree on demand, restoring the memory profile prior to89d47d814d. Fixes #70908
Angular
The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.
Usage information and reference details can be found in Angular documentation.
License: MIT