title: Angular Memory Leak using setInterval & observables
body: <p>I recently added this notification component to my fixed header and now I'm getting memory woes on my IIS server.  I don't think this component will ever get destroyed and I think that's the problem.  This component loads &amp; updates notification messages from my API server every 5 secs.  I'm pretty sure I'm getting a memory leak here -- somewhere.  HELP?!</p>
  
  <pre><code>ngOnInit(): void
  {
      this.intervalId = setInterval(() =&gt;
      {
          this.notificationService.getAll()
              .pipe(untilDestroyed(this))
              .subscribe(
                  data =&gt;
                  {
                      this.notifications = data;
                      this.cdRef.detectChanges();
                      this.store.dispatch(new actions.LoadNotificationsSuccess(this.notifications));
                  },
                  error =&gt;
                  {
                      console.log('error', error);
                      clearInterval(this.intervalId);
                  });
      }, 5000);
  }
  
  ngOnDestroy(): void
  {
      clearInterval(this.intervalId);
  }
  </code></pre>