Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leak in MediaScannerConnection #26

Closed
fasteque opened this issue May 10, 2015 · 9 comments · Fixed by #111
Closed

Leak in MediaScannerConnection #26

fasteque opened this issue May 10, 2015 · 9 comments · Fixed by #111

Comments

@fasteque
Copy link

In com.fastebro.androidrgbtool:1.5.0:10.
* com.fastebro.androidrgbtool.ui.MainActivity has leaked:
* GC ROOT android.media.MediaScannerConnection$1.this$0 (anonymous class extends android.media.IMediaScannerListener$Stub)
* references android.media.MediaScannerConnection.mContext
* leaks com.fastebro.androidrgbtool.ui.MainActivity instance

* Reference Key: b9ba263e-f5ce-4117-bfa5-23f921e13052
* Device: motorola google Nexus 6 shamu
* Android Version: 5.1 API: 22
* Durations: watch=5048ms, gc=153ms, heap dump=1707ms, analysis=15593ms

My code simply call the scanFile like the ExternalStorage official APIs demo.
Found it while testing my app but I'm not able to reproduce it systematically.

@pyricau
Copy link
Member

pyricau commented May 10, 2015

Dang. That's another binder leak.

Can you give me a link to the ExternalStorage official APIs demo sources?

@fasteque
Copy link
Author

@pyricau
Copy link
Member

pyricau commented May 10, 2015

When passing an activity context, the service should automatically unbind when the activity is destroyed. MediaScannerConnection#mService should have been null.

Could you provide a link to the heap dump so that I have a look?

@fasteque
Copy link
Author

I'd like to do that but it looks like I can't share with any app (Inbox, GMail, beam transfer, upload on Google Drive, ...): is it stored in the private app space?

@pyricau
Copy link
Member

pyricau commented May 10, 2015

Yes. This will be fixed in #27 . In the meantime, you can use adb shell "run-as com.your.packagename cp <source> <dest>" to copy to sd card and then access it.

@fasteque
Copy link
Author

Yep, I tried earlier to run that command, always getting "permission-denied" error or "read-only file system"... maybe because my device is encrypted?
Anyway, I finally managed to get the content of my app folder with an adb backup without encryption, so please find here below the links:
https://dl.dropboxusercontent.com/u/91338451/heap_dump_0.hprof
https://dl.dropboxusercontent.com/u/91338451/heap_dump_0.hprof.result

Let me know if you have any trouble getting the files.

Thanks!

@andhie
Copy link

andhie commented May 11, 2015

@fasteque if cp didnt work, try with cat. i have tested it to be working
adb shell "run-as com.your.packagename cat /data/data/com.your.packagename/files/detected_leaks/heap_dump_0.hprof.result > /sdcard/dump_0.hprof"

@pyricau
Copy link
Member

pyricau commented May 17, 2015

pyricau added a commit that referenced this issue May 17, 2015
Yky pushed a commit to Yky/leakcanary that referenced this issue Feb 21, 2016
@southsea
Copy link

It seems never call onServiceDisconnected method on MediaScannerConnection class when App exits.
That can't release mService and mClient, then leak occured.

Pengchengxiang pushed a commit to XLibrarys/leakcanary that referenced this issue Jan 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants