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

Leaked activity not detected as a leak by LeakCanary #482

Closed
ajarl opened this issue Mar 31, 2016 · 8 comments
Closed

Leaked activity not detected as a leak by LeakCanary #482

ajarl opened this issue Mar 31, 2016 · 8 comments
Assignees
Milestone

Comments

@ajarl
Copy link

ajarl commented Mar 31, 2016

LeakCanary Version: 1.4-beta2

So I have an activity being leaked on configuration change. I think it's a MapView-related issue, but haven't been able to fix it yet. In any case, LeakCanary takes a heap dump and says it's analyzing it, and then comes back and says that no leak was found. However, the activity is clearly leaked as the memory usage keeps increasing until the app crashes with OOM if you keep rotating the screen.

I couldn't attach the heap dump file here as it is too large, but I uploaded it here

Notice there are 6 instances of the main activity (TaxiStockholmActivity) present in the heap.

This is what LeakCanary says in the LogCat:

03-31 09:44:48.469 12169-12215/se.taxistockholm.debug I/art: hprof: heap dump "/storage/emulated/0/Download/leakcanary-se.taxistockholm.debug/suspected_leak_heapdump.hprof" starting...
...
03-31 09:45:18.355 12169-14813/se.taxistockholm.debug D/LeakCanary: In se.taxistockholm.debug:4.1:112.
                                                                    * NO LEAK FOUND.

Tested on 5.1 (emulator) and 6.0 (device), same result. This is just a wild guess, but could it be that LeakCanary is unable to find a path to a GC root, maybe because it's somehow outside of the process (e.g. in Google Play services)?

@ajarl
Copy link
Author

ajarl commented Mar 31, 2016

I managed to fix the memory leak anyway. We weren't properly calling LocationServices.FusedLocationApi.removeLocationUpdates. Hopefully that helps to reproduce the issue so that LeakCanary can properly detect this leak as well.

@pyricau
Copy link
Member

pyricau commented Mar 31, 2016

Thanks!

@jrodbx jrodbx self-assigned this Jun 27, 2016
@jrodbx jrodbx added this to the 1.4 milestone Jun 27, 2016
@jrodbx
Copy link
Collaborator

jrodbx commented Sep 9, 2016

@ajarl: Thanks for providing the heap dump. Examining in MAT confirms what you found: multiple instances of TaxiStockholmActivity.

Tracing one shows that a GC root of type com.google.android.gms.location.internal.zzk$zzc (LocationClientHelper) is causing the leak and Leakcanary isn't detecting it.

screen shot 2016-09-09 at 2 24 42 am

Using git bisect, it looks like 3d1f524 is the reason. That commit excludes Binder GC roots from leak detection. zzk$zzc inherits from android.os.Binder.

screen shot 2016-09-09 at 2 24 57 am

@ash995
Copy link

ash995 commented Mar 6, 2018

app_dump_file.zip
I have attached the heap dump of my basic application in which you will be able to see that there are 34 instances of MainActivity, and leakcanary was not able to detect a leak. What could be the issue?
I am running leak canary version 1.5.4.

@JakeWharton
Copy link
Collaborator

JakeWharton commented Mar 6, 2018 via email

@ash995
Copy link

ash995 commented Mar 6, 2018

@JakeWharton Yeah I followed the guide to the dot. It detected a leak once, and then was not able to detect altogether.

@JakeWharton
Copy link
Collaborator

Can you reproduce the setup with the sample app then? This will allow us to debug why the leak isn't being found.

@jrodbx
Copy link
Collaborator

jrodbx commented Mar 6, 2018

please file a separate issue. this issue has been closed since 2016.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants