Does lambda in Android use a memory leak cause?

I watch this presentation, and at 13:42 they say that using lambda in transit:

enter image description here

api.getEvents()
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .doOnSubscribe(() -> loadingIndication.show())
    .doOnUnsubscribe(() -> loadingIndication.hide())
    .subscribe(...);

causes a leak.

Can you explain how the leak works in this case? Does a leak appear depending on how we compile the code and which class we put the RxJava code in (for example, in Activity, Application, in Service)?

+4
source share
1 answer

, lambdas , , , Activity. , .

api.getEvents()
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .doOnSubscribe(() -> loadingIndication.show())
    .doOnUnsubscribe(() -> loadingIndication.hide())
    .subscribe(events -> {}, throwable -> {});

, , CompositeDisposable Disposable, , compositeDisposable.add() compositeDisposable.clear() onDestroy().

+1

Source: https://habr.com/ru/post/1678863/


All Articles