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

com.squareup.leakcanary.internal.DisplayLeakActivity has leaked #1

Closed
evant opened this issue May 8, 2015 · 4 comments
Closed

com.squareup.leakcanary.internal.DisplayLeakActivity has leaked #1

evant opened this issue May 8, 2015 · 4 comments

Comments

@evant
Copy link

evant commented May 8, 2015

* com.squareup.leakcanary.internal.DisplayLeakActivity has leaked:
* GC ROOT static com.android.internal.os.ZygoteInit.mResources
* references android.content.res.Resources.mContext
* references android.app.ContextImpl.mOuterContext
* leaks com.squareup.leakcanary.internal.DisplayLeakActivity instance
* Reference Key: bd8db00d-ce02-4f73-97fe-4bd36c65502f
* Device: samsung samsung GT-I9500 ja3gub
* Android Version: 4.4.2 API: 19
* Durations: watch=5015ms, gc=145ms, heap dump=543ms, analysis=13738ms
@evant
Copy link
Author

evant commented May 8, 2015

Also,

* com.willowtreeapps.leakleak.MainActivity has leaked:
* GC ROOT static android.view.ViewConfiguration.sConfigurations
* references android.util.SparseArray.mValues
* references array java.lang.Object[].[0]
* references android.view.ViewConfiguration.mContext
* leaks com.willowtreeapps.leakleak.MainActivity instance
* Reference Key: 238d140a-1864-4d7b-9734-605df0da7693
* Device: samsung samsung GT-I9500 ja3gub
* Android Version: 4.4.2 API: 19
* Durations: watch=5035ms, gc=138ms, heap dump=584ms, analysis=9665ms

Could reproduce both in a project with just a blank activity on that device (galaxy s4)

hprof: https://drive.google.com/file/d/0B1aqwLiIm64cb0VONzhwb2VCN3M/view?usp=sharing

@pyricau
Copy link
Member

pyricau commented May 9, 2015

The first one is really wrong. The global app wide resource instance has been built with a context that's the activity instead of the application instance.

Resources doesn't have a mContext field so this leak might not exist in the latest versions of AOSP. I also can't find a version that has it.

I think we could add an excluded ref for android.content.res.Resources.mContext in Samsung / API 19. If you want to fix this leak for your app, you could access ZygoteInit.mResources using a reflection and replace the instance with the one from getApplicationContext().getResources() (if that one isn't stupidly holding to the activity as well), OR you could (via reflection again) maybe change the context in Resources.mContext.

Same goes for the second one. I can't find android.view.ViewConfiguration.mContext. I suspect Samsung is playing a dirty game of changing the sources here. I would ignore this one too.

@xckevin
Copy link

xckevin commented May 10, 2015

I got this, based on com.squareup.leakcanary:leakcanary-android:1.3

* com.squareup.leakcanary.internal.DisplayLeakActivity has leaked:
* GC ROOT static android.view.inputmethod.InputMethodManager.mInstance
* references android.view.inputmethod.InputMethodManager.mCurRootView
* references com.android.internal.policy.impl.PhoneWindow$DecorView.mContext
* leaks com.squareup.leakcanary.internal.DisplayLeakActivity instance
* Reference Key: 891001d9-2b87-458c-a6f2-66c20ba0625d
* Device: samsung samsung GT-I9308 m0zm
* Android Version: 4.0.4 API: 15
* Durations: watch=5014ms, gc=225ms, heap dump=1449ms, analysis=55747ms

@MatFl
Copy link

MatFl commented Aug 17, 2015

I'm also getting the android.view.ViewConfiguration.mContext leak in a activity of my app. The device is a 2012 Nexus 7 (with an older cyanogenmod version (4.3.1)). Could you also make an exclude for this?

It should be noted, that this leak only occurs in a activity which is opened from the launcher.

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

No branches or pull requests

4 participants