Skip to content

Commit 2cf4da0

Browse files
DavidANeilleonsenft
authored andcommitted
fix(core): hold constructors weakly in DepsTracker cache
Otherwise a component can be held in memory longer than the component constructor is reachable from application code. (cherry picked from commit cab5ddd)
1 parent f15d33d commit 2cf4da0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/core/src/render3/deps_tracker/deps_tracker.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ import {
3131
* An implementation of DepsTrackerApi which will be used for JIT and local compilation.
3232
*/
3333
class DepsTracker implements DepsTrackerApi {
34-
private ownerNgModule = new Map<ComponentType<any>, NgModuleType<any>>();
34+
private ownerNgModule = new WeakMap<ComponentType<any>, NgModuleType<any>>();
3535
private ngModulesWithSomeUnresolvedDecls = new Set<NgModuleType<any>>();
36-
private ngModulesScopeCache = new Map<NgModuleType<any>, NgModuleScope>();
37-
private standaloneComponentsScopeCache = new Map<ComponentType<any>, StandaloneComponentScope>();
36+
private ngModulesScopeCache = new WeakMap<NgModuleType<any>, NgModuleScope>();
37+
private standaloneComponentsScopeCache = new WeakMap<
38+
ComponentType<any>,
39+
StandaloneComponentScope
40+
>();
3841

3942
/**
4043
* Attempts to resolve ng module's forward ref declarations as much as possible and add them to

0 commit comments

Comments
 (0)