Description
Hi & thanks for this amazing library!
For the past few days I've been confused by some memory leaks that caused by RxJava or, more likely, my misunderstanding of RxJava. I've reduced the issue to a very simple test case that you can find here: https://gist.github.com/Thomvis/18474b51b1b4dff79191f93330ae627e.
The issue has to do with switchMap
. I'd expect that when the source Observable emits an onNext event (containing a new Observable), the operator will unsubscribe from the previous Observable and release all references to that Observable. The unsubscribing part is happening, but the releasing is not. Because the Observable is not released, any upstream operators, anonymous inner classes and their captures are also not released and subsequently not garbage collected.
I've read #1292 and #3074, but I'm not sure if they're related.
So what I'm hoping to get from this issue is one of the following:
- My test is wrong
- I'm using
switchMap
wrong / have wrong assumptions on the memory model - (There's a bug in OperatorSwitch)
Thanks in advance,
Thomas