Memory leaks in general in RxJava

225 Views Asked by At

I wanted to ask something with regards to memory leaks in general in RxJava.

Once a Single or Completable's subscription terminates (i.e. after onSuccess or onError, etc. is called), is it safe to assume that there will be no memory retained by this subscription? I wanted to ask specifically about Single or Completable because the documentation says that they terminate immediately after the execution of the subscription callbacks, unlike Observables which have to be disposed of explicitly.

For example in Android, if I had a Single or Completable that contained a strong reference to an Activity or Context, and the activity was destroyed before the Single/Completable finishes executing, it would only leak memory temporarily until the Single/Completable emits a value; and once it emits a value and thus the subscription is terminated, its reference to the activity/context would be gone along with this subscription, and hence there will be no memory leak anymore, is that correct?

0

There are 0 best solutions below