RxPaparazzo: Memory Leak Media Scanner Connection

Has anybody encountered that LeakCanary is complaining about memory leaks? This happens when rxPaparazzo is used on an Activity, when used on fragment I don’t see any leaks. Below is what I am using the take either a picture or retrieve from gallery.

compositeSubscription.add(RxPaparazzo.takeImage(this)
                   .size(new CustomMaxSize(900))
                   .usingGallery()
                   .subscribeOn(Schedulers.io())
                   .observeOn(AndroidSchedulers.mainThread())
                   .doOnError(Timber::d)
                   .subscribe(response -> {
                       if (response.resultCode() != RESULT_OK) {
                           response.targetUI()
                                   .showUserCanceled();
                           return;
                       }
                       response.targetUI()
                               .loadPicture(response.data());
                   }));

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (5 by maintainers)

Most upvoted comments

A quick Google pulls up this commit in LeakCanary, it says that there is a problem with the MediaScannerConnection.scanFile() which fails to clean up the reference to the Context by not disconnecting properly. I’m not sure why they have version limited the bug as it’s not fixed.

https://github.com/square/leakcanary/pull/111/files https://code.google.com/p/android/issues/detail?id=173788

The suggested workaround is to self-manage the MediaScannerConnection.