mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
fix(core): do not retain dynamically compiled components and modules (#42003)
The JIT compiler has a mapping from component to the owning NgModule and tracks whether a certain NgModule class has been verified; these maps causes any JIT compiled component and NgModule to be retained even if they are no longer referenced from anywhere else. This commit switches the maps to `WeakMap` to allow garbage collecting any components and NgModules that are no longer referenced elsewhere. Fixes #19997 PR Close #42003
This commit is contained in:
parent
bd2e66cf2b
commit
5bb7c0ef3a
1 changed files with 4 additions and 4 deletions
|
|
@ -375,12 +375,12 @@ function getAnnotation<T>(type: any, name: string): T|null {
|
|||
* NgModule the component belongs to. We keep the list of compiled components here so that the
|
||||
* TestBed can reset it later.
|
||||
*/
|
||||
let ownerNgModule = new Map<Type<any>, NgModuleType<any>>();
|
||||
let verifiedNgModule = new Map<NgModuleType<any>, boolean>();
|
||||
let ownerNgModule = new WeakMap<Type<any>, NgModuleType<any>>();
|
||||
let verifiedNgModule = new WeakMap<NgModuleType<any>, boolean>();
|
||||
|
||||
export function resetCompiledComponents(): void {
|
||||
ownerNgModule = new Map<Type<any>, NgModuleType<any>>();
|
||||
verifiedNgModule = new Map<NgModuleType<any>, boolean>();
|
||||
ownerNgModule = new WeakMap<Type<any>, NgModuleType<any>>();
|
||||
verifiedNgModule = new WeakMap<NgModuleType<any>, boolean>();
|
||||
moduleQueue.length = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue