~/lightning

Observable trapped me in memory leak

Lightningat NG Poland 2018 · on Friday, 2018-11-16· [angular, web-performance]
slides:none on file

An Angular component subscribes to a service Observable and never unsubscribes, causing a memory leak; the fix is concrete: create a Subject<void> onDestroy, pipe every stream through takeUntil pattern, and call next/complete in ngOnDestroy lifecycle so all subscriptions drop. Example code shows subscribe → store nothing → leak, then refactor to pipe(takeUntil(this.onDestroy)) and push a value on destroy and the leak disappears.

AI-written summary · about

~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.