Memory leak in subscriptions
See original GitHub issueSteps to reproduce:
Subscribe to a channel, then call subscription.unsubscribe()
.
Expected: A subscription is completely removed.
Actual result:
Subscriptions stored in an internal Centrifuge._subs
object and they are never removed.
I create a single page application and while a user is navigated between pages the app unsubscribes from channels required on a given page and subscribes to a new channels on a next page. It turns out that number of subscriptions stored in Centrifuge._subs
increases unless a user reloads a browser tab.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Preventing Angular Subscription Memory Leaks | Jake Cyr
A simple way to avoid this is to save a reference to the subscription and unsubscribe in the ngOnDestroy lifecycle method. For example:...
Read more >Angular- How to avoid Memory Leaks from Subscriptions?
Failing to Unsubscribe can cause memory leaks. Solution. There are many solutions on to this problem. But the most elegant and error-proof solution...
Read more >How to prevent memory leak of subscriptions creation when ...
there is a memory leak beacuse each time pageChange emits a new subscription is created. That subscription will be completed after one emission ......
Read more >RxJS: Why memory leaks occur when using a Subject
It's not uncommon to see the words 'unsubscribe', 'memory leaks', 'subject' in the same phrase when reading upon RxJS-related materials.
Read more >Avoid memory leaks when subscribing to RxJS Observables ...
[01:32] The problem is that we have a memory leak here. The observable in our numbersService continues to emit values because the NumberService...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@vladvelici hello, the problem that @aleksei-savitski-softswiss described relates to a scenario where many subscriptions to different channels get created on the same page and no page reload happens for a long time (SPA application). In this case all once created subscriptions stay in internal
_subs
map of client and there is no public way to release them even though we know that we don’t need those subscriptions anymore. Just created pr that should fix this.Released in 2.5.0, let’s see how it goes