Title: Will this Observable create a memory leak?
Tags: rxjs;rxjs5
Question: Will this Observable create a memory leak?
becuase every time you run it, it will keep the initial select stream open?!?!

```return this.store.select(store =&gt; store.appDb.appBaseUrl)                          
            .mergeMap(url =&gt; {
                return this.http.get(url)
                    .debug('received ' + url)
                    .map(res =&gt; res.json())
            })
```

and if so, will adding a take(1) fix it?

```return this.store.select(store =&gt; store.appDb.appBaseUrl)                          
               .take(1) // <--------------- stop after 1?
               .mergeMap(url =&gt; {
                return this.http.get(url)
                    .debug('received ' + url)
                    .map(res =&gt; res.json())
            })
```

tx Sean


Here is the accepted answer: Simply having an hot observable ```this.store.select``` does not immediately imply that you have a memory leak. It is your task to store a reference to your subscription on that observable and dispose of it when done.

I find it helpful to annotate my streams with ```.take(X)``` as the last thing i do when i know how many elements i expect because this will make the stream dispose automatically after emitting the expected amount.

```return this.store.select(store =&gt; store.appDb.appBaseUrl)                          
  .mergeMap(url =&gt; this.http.get(url)
    .debug('received ' + url)
    .map(res =&gt; res.json())
  )
  .take(1)
```

Comment for this answer: I see, well the subscription is managed by the effects library.. but I do call this action multiple times..


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:12/28/16', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<rxjs><rxjs5>', 'Title': 'Will this Observable create a memory leak?', 'ViewCount': 815, 'id': 41369546, 'user_AboutMe': '', 'user_AccountId': 2326211.0, 'user_DisplayName': 'born2net', 'user_Reputation': 22779.0, 'user_Views': 483.0, 'user_id': 2040670.0}}