forked from tensorflow/tensorboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
timeseries: fix memory leaks involving CardObserver and shareReplay (t…
…ensorflow#5254) This addresses 2 non-trivial sources of memory leaks observed when filtering tags in the Time Series dashboard. a) CardObserver used to track Elements that were destroyed via ngOnDestroy and stored them in a `Set<Element>`. Now with a WeakSet instead, we cover cases when the browser's IntersectionObserverEntry is not handled for some reason. b) The rxjs operator "shareReplay" has some known gotchas [1], [2]. When more observables subscribe to a source containing `shareReplay(1)` in its operator chain, the source remains subscribed even after the other observables unsubscribe. This change uses the `takeUntil(ngUnsubscribe$)` pattern to ensure any component using a `shareReplay` will not keep it subscribed after the component is gone. Alternatively we could use `refCount`, but this opts for the `takeUntil` pattern already used widely in the codebase. Manually checked that the dashboard still operates properly, and in Angular's dev mode, using a specific demo logdir, adding and clearing a "." tag filter has these characteristics: Before this change: 5.8 MB, 5.5K DOM nodes added each cycle After this change: 0.05 MB, <10 DOM nodes added each cycle Googlers, see b/196996936 [1] ReactiveX/rxjs#5034 [2] ReactiveX/rxjs#5931
- Loading branch information
Showing
5 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters