EzDevInfo.com

leakcanary

A memory leak detection library for Android and Java.

NullPointerException from LeakCanary when running Robolectric tests

Added LeakCanary (1.3) to my Application:

@Override
public void onCreate() {
    super.onCreate();
    Fabric.with(this, new Crashlytics());
    LeakCanary.install(this);

When I run the Robolectric test suite for my application I get a NullPointerException in LeakCanary.

Caused by: java.lang.NullPointerException
at com.squareup.leakcanary.LeakCanary.isInServiceProcess(LeakCanary.java:165)
at com.squareup.leakcanary.LeakCanary.isInAnalyzerProcess(LeakCanary.java:141)
at com.squareup.leakcanary.LeakCanary.install(LeakCanary.java:52)
at com.squareup.leakcanary.LeakCanary.install(LeakCanary.java:43)
at com.package.application.MyApplication.onCreate(MyApplication.java:50)
at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:131)
at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:431)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:224)

I added that Im using Crashlytics to point out that it (and other methods as well) receives the same Application but does not throw any Exceptions.

Wasn't sure if this should be here or on GitHub issues for LeakCanary. Anyone else experiencing this issue?


Source: (StackOverflow)

Why is this a memory leak

I came across a library for memory leak detection in Android (Java) called LeakCanary but cannot understand the example where they leak the memory. Could anybody please explain how and why the code shown in their example is a memory leak.

class Cat {
}
class Box {
  Cat hiddenCat;
}
class Docker {
  static Box container;
}

// ...

Box box = new Box();
Cat schrodingerCat = new Cat();
box.hiddenCat = schrodingerCat;
Docker.container = box;

and then they watch the variable schrodingerCat for leaks which gives a leak shown as follows (which I dont know how to relate to the above code).

* GC ROOT static Docker.container
* references Box.hiddenCat
* leaks Cat instance

Any help with the explanation of the leak and how the detection relates to it would be very helpful. Also some good articles for beginners would be nice.

Thanks!


Source: (StackOverflow)

Advertisements

Android memory leak on textview - LeakCanary (Leak can be ignored)

I keep having the following memory leak as displayed by LeakCanary, when I go from my splash screen to the mainactivity. I understand that this is an expected leak due to fault in the Android OS itself, but is there a way I can avoid this (by setting specifics of some TextView somewhere?)

05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * LEAK CAN BE IGNORED.
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * com.gmspartnersltd.earthmiles.views.ActivitySignUp_ has leaked:
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * GC ROOT static android.text.TextLine.sCached
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * references array android.text.TextLine[].[1]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * references android.text.TextLine.mCharacterStyleSpanSet
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * references android.text.SpanSet.spans
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * references array android.text.style.CharacterStyle[].[1]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * references com.gmspartnersltd.earthmiles.views.ActivitySignUp$2.this$0 (anonymous class extends android.text.style.ClickableSpan)
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * leaks com.gmspartnersltd.earthmiles.views.ActivitySignUp_ instance
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ [ 05-22 08:54:52.160 13969:18091 D/LeakCanary ]
    * Reference Key: bb8124a9-2829-4ff3-8ded-13cf35f80f54
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * Device: Genymotion generic Google Nexus 5 - 5.0.0 - API 21 - 1080x1920 vbox86p
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * Android Version: 5.0 API: 21 LeakCanary: 1.3.1
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * Durations: watch=10898ms, gc=137ms, heap dump=5529ms, analysis=9193ms
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ [ 05-22 08:54:52.160 13969:18091 D/LeakCanary ]
    * Details:
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * Class android.text.TextLine
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   static $staticOverhead = byte[] [id=0x70622169;length=24;size=40]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   static sCached = android.text.TextLine[] [id=0x70775010;length=3]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   static DEBUG = false
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   static TAB_INCREMENT = 20
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * Array of android.text.TextLine[]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   [0] = android.text.TextLine [id=0x1309a2e0]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   [1] = android.text.TextLine [id=0x12eed650]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   [2] = null
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * Instance of android.text.TextLine
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   static $staticOverhead = byte[] [id=0x70622169;length=24;size=40]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   static sCached = android.text.TextLine[] [id=0x70775010;length=3]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   static DEBUG = false
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   static TAB_INCREMENT = 20
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mCharacterStyleSpanSet = android.text.SpanSet [id=0x12e32d80]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mChars = null
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mDirections = null
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mMetricAffectingSpanSpanSet = android.text.SpanSet [id=0x12e32d60]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mPaint = null
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mReplacementSpanSpanSet = android.text.SpanSet [id=0x12e32da0]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mSpanned = android.text.SpannedString [id=0x132dabe0]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mTabs = null
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mText = null
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mWorkPaint = android.text.TextPaint [id=0x1300f5c0]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mCharsValid = false
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mDir = 1
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mHasTabs = false
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mLen = 1
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mStart = 0
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * Instance of android.text.SpanSet
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   classType = java.lang.Class [id=0x703bb448;name=android.text.style.CharacterStyle]
05-22 08:54:52.160  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   spanEnds = int[] [id=0x1309fd60;length=2;size=24]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   spanFlags = int[] [id=0x1309fda0;length=2;size=24]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   spanStarts = int[] [id=0x1309fd20;length=2;size=24]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   spans = android.text.style.CharacterStyle[] [id=0x1309fce0;length=2]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   numberOfSpans = 1
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * Array of android.text.style.CharacterStyle[]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   [0] = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   [1] = com.gmspartnersltd.earthmiles.views.ActivitySignUp$2 [id=0x130952c0]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * Instance of com.gmspartnersltd.earthmiles.views.ActivitySignUp$2
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   this$0 = com.gmspartnersltd.earthmiles.views.ActivitySignUp_ [id=0x13361800]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ * Instance of com.gmspartnersltd.earthmiles.views.ActivitySignUp_
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   onViewChangedNotifier_ = org.androidannotations.api.view.OnViewChangedNotifier [id=0x13052dc0]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   birthday = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   buttonNext = android.support.v7.widget.AppCompatButton [id=0x13459c00]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   confirmPassword = java.lang.String [id=0x132f01a0]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   editTextConformPassword = android.support.v7.widget.AppCompatEditText [id=0x13458400]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   editTextEmail = android.support.v7.widget.AppCompatEditText [id=0x1339b000]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   editTextFirstName = android.support.v7.widget.AppCompatEditText [id=0x13396c00]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   editTextLastName = android.support.v7.widget.AppCompatEditText [id=0x13398800]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   editTextPassword = android.support.v7.widget.AppCompatEditText [id=0x13456c00]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   email = java.lang.String [id=0x132f0040]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   facebook = com.facebook.android.Facebook [id=0x1307ee00]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   fbUserId = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   firstName = java.lang.String [id=0x132f0080]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   gender = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   lastName = java.lang.String [id=0x132f00e0]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   location = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mAsyncRunner = com.facebook.android.AsyncFacebookRunner [id=0x130952a0]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   password = java.lang.String [id=0x132f0140]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   termsOfUse = android.support.v7.widget.AppCompatTextView [id=0x1345a000]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   text = android.text.SpannableString [id=0x1310eaa0]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   fromFacebook = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   etHelpMessage = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mProgressHUD = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   positiveAction = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   showBusyAnimationRequesterCount = 0
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mDelegate = android.support.v7.app.AppCompatDelegateImplV11 [id=0x12ecfd80]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mAllLoaderManagers = android.support.v4.util.SimpleArrayMap [id=0x131d80a0]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mContainer = android.support.v4.app.FragmentActivity$2 [id=0x13052db0]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mFragments = android.support.v4.app.FragmentManagerImpl [id=0x12f7cf60]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mHandler = android.support.v4.app.FragmentActivity$1 [id=0x1310ea80]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mLoaderManager = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mCheckedForLoaderManager = true
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mCreated = true
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mLoadersStarted = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mOptionsMenuInvalidated = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mReallyStopped = true
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mResumed = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mRetaining = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mStopped = true
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mActionBar = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mActivityInfo = android.content.pm.ActivityInfo [id=0x12db0180]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mActivityTransitionState = android.app.ActivityTransitionState [id=0x1304b600]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mAllLoaderManagers = android.util.ArrayMap [id=0x131c9d00]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mApplication = com.gmspartnersltd.earthmiles.globalstate.App [id=0x12c6e8c0]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mComponent = android.content.ComponentName [id=0x12f64150]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mContainer = android.app.Activity$1 [id=0x13052d70]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mCurrentConfig = android.content.res.Configuration [id=0x12f97520]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mDecor = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mDefaultKeySsb = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mEmbeddedID = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mEnterTransitionListener = android.app.SharedElementCallback$1 [id=0x70765ba8]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mExitTransitionListener = android.app.SharedElementCallback$1 [id=0x70765ba8]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mFragments = android.app.FragmentManagerImpl [id=0x12f7cef0]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mHandler = android.os.Handler [id=0x1310ea60]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mInstanceTracker = android.os.StrictMode$InstanceTracker [id=0x13052d90]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mInstrumentation = android.app.Instrumentation [id=0x12c33f70]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mIntent = android.content.Intent [id=0x12f3b300]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mLastNonConfigurationInstances = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mLoaderManager = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mMainThread = android.app.ActivityThread [id=0x12c2b100]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mManagedCursors = java.util.ArrayList [id=0x1310ea40]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mManagedDialogs = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mMenuInflater = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mParent = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mResultData = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mSearchManager = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mTitle = java.lang.String [id=0x12e6d7e0]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mToken = android.os.BinderProxy [id=0x12fe86a0]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mTranslucentCallback = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mUiThread = java.lang.Thread [id=0x73b43540]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mVoiceInteractor = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mWindow = com.android.internal.policy.impl.PhoneWindow [id=0x12e5d580]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mWindowManager = android.view.WindowManagerImpl [id=0x1310ed20]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mCalled = true
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mChangeCanvasToTranslucent = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mChangingConfigurations = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mCheckedForLoaderManager = true
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mConfigChangeFlags = 0
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mDefaultKeyMode = 0
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mDestroyed = true
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mDoReportFullyDrawn = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mEnableDefaultActionBarUp = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mFinished = true
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mIdent = 24993652
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mLoadersStarted = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mResultCode = 0
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mResumed = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mStartedActivity = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mStopped = true
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mTemporaryPause = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mTitleColor = 0
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mTitleReady = true
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mVisibleBehind = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mVisibleFromClient = true
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mVisibleFromServer = false
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mWindowAdded = true
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mInflater = com.android.internal.policy.impl.PhoneLayoutInflater [id=0x13152580]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mOverrideConfiguration = null
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mResources = android.content.res.Resources [id=0x12c33f20]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mTheme = android.content.res.Resources$Theme [id=0x1310ed40]
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mThemeResource = 2131689670
05-22 08:54:52.161  13969-18091/com.gmspartnersltd.earthmiles.debug D/LeakCanary﹕ |   mBase = android.app.ContextImpl [id=0x12c81100]

Source: (StackOverflow)

how to use leakcanary, how to add leakcanary as a jar to build a apk with .mk file

LeakCanary is a memory leak detection library for Android and Java. LeakCanary

My project is based on android make file system, which relies on some android internal interfaces and custom methods.

How can I add the LeakCanary as a lib into my app to detect memory leak.

My solution: First, I have to build the LeakCanary as a jar file, but how to. as it's a gradle directory structure, and I have never used Gradle before.

Any tip is precious.


Source: (StackOverflow)

Retained fragment leak

I'm using the simple activity with the retained fragment which holds some data used by the activity. The retained fragment uses the loader to get the data from a content provider. On configuration change (screen rotation) the activity is recreated and the old instance is leaked as reported by LeakCanary library (retained fragment -> loader manager -> old activity). This reproduced with the support-v4 23.0.0 library (and the previous versions also). The sample of the activity with the retained fragment where leak is reproduced (no useful code here, only to demonstrate the leak):

package com.leaksample;

import android.database.Cursor;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v7.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    private ModelFragment mModelFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        FragmentManager fm = getSupportFragmentManager();
        mModelFragment = (ModelFragment) fm.findFragmentByTag(ModelFragment.TAG);
        if (mModelFragment == null) {
            mModelFragment = new ModelFragment();
            fm.beginTransaction()
                    .add(mModelFragment, ModelFragment.TAG)
                    .commit();
            fm.executePendingTransactions();
        }
    }

    public static class ModelFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> {
        private static final String TAG = ModelFragment.class.getSimpleName();

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setRetainInstance(true);
            getLoaderManager().initLoader(0, null, this);
        }

        @Override
        public Loader<Cursor> onCreateLoader(int id, Bundle args) {
            return new CursorLoader(getActivity(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                    new String[]{MediaStore.Images.Media.DATA}, null, null, null);
        }

        @Override
        public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
        }

        @Override
        public void onLoaderReset(Loader<Cursor> loader) {
        }
    }
}

The stack from LeakCanary:

08-29 19:52:34.129  15271-16632/com.leaksample D/LeakCanary﹕ In com.leaksample:1.0:1.
08-29 19:52:34.129  15271-16632/com.leaksample D/LeakCanary﹕ * com.leaksample.MainActivity has leaked:
08-29 19:52:34.129  15271-16632/com.leaksample D/LeakCanary﹕ * GC ROOT thread java.lang.Thread.<Java Local> (named 'Binder_1')
08-29 19:52:34.129  15271-16632/com.leaksample D/LeakCanary﹕ * references android.view.ViewRootImpl.mContext
08-29 19:52:34.129  15271-16632/com.leaksample D/LeakCanary﹕ * references com.leaksample.MainActivity.mModelFragment
08-29 19:52:34.129  15271-16632/com.leaksample D/LeakCanary﹕ * references com.leaksample.MainActivity$ModelFragment.mLoaderManager
08-29 19:52:34.129  15271-16632/com.leaksample D/LeakCanary﹕ * references android.support.v4.app.LoaderManagerImpl.mHost
08-29 19:52:34.129  15271-16632/com.leaksample D/LeakCanary﹕ * references android.support.v4.app.FragmentActivity$HostCallbacks.this$0
08-29 19:52:34.129  15271-16632/com.leaksample D/LeakCanary﹕ * leaks com.leaksample.MainActivity instance

Maybe I'm doing something wrong and forgot to call some close or release method? I think using the retained fragment with the loader is a common pattern and should not be memory leaks here.


Source: (StackOverflow)

Understanding ViewTreeObserver leak

I am using LeakCanary 1.3.1-SNAPSHOT. I found a leak concerning ViewTreeObserver.OnScrollChangedListener setup and I fixed it like in the following code:

  private ViewTreeObserver.OnScrollChangedListener scrollViewChangeListener;

  @Override protected void onFinishInflate() {
      super.onFinishInflate();
      ButterKnife.inject(this);
      scrollViewChangeListener = new ViewTreeObserver.OnScrollChangedListener() {
      @Override public void onScrollChanged() {
        EventDetailsView.this.onScrollChanged(scrollView.getScrollY());
      }
    };
      scrollView.getViewTreeObserver()
        .addOnScrollChangedListener(scrollViewChangeListener);
  }
  @Override public void onDetachedFromWindow() {
      super.onDetachedFromWindow();
      scrollView.getViewTreeObserver().removeOnScrollChangedListener(scrollViewChangeListener);
  }

However LeakCanary still report it as a leak, any idea why?

* com.couchsurfing.mobile.ui.events.detail.EventDetailsScreen$Presenter has leaked:
* GC ROOT android.view.inputmethod.InputMethodManager$1.this$0 (anonymous class extends com.android.internal.view.IInputMethodClient$Stub)
* references android.view.inputmethod.InputMethodManager.mCurRootView
* references com.android.internal.policy.impl.PhoneWindow$DecorView.mAttachInfo
* references android.view.View$AttachInfo.mTreeObserver
* references android.view.ViewTreeObserver.mOnScrollChangedListeners
* references android.view.ViewTreeObserver$CopyOnWriteArray.mData
* references java.util.ArrayList.array
* references array java.lang.Object[].[0]
* references com.couchsurfing.mobile.ui.events.detail.EventDetailsView$1.this$0 (anonymous class implements android.view.ViewTreeObserver$OnScrollChangedListener)
* references com.couchsurfing.mobile.ui.events.detail.EventDetailsView.presenter
* leaks com.couchsurfing.mobile.ui.events.detail.EventDetailsScreen$Presenter instance* Reference Key: 69d0a429-ae27-48fc-a8e0-033c920dd07c
* Device: LGE google Nexus 5 hammerhead
* Android Version: 5.1 API: 22 LeakCanary: 1.3.1-SNAPSHOT
* Durations: watch=5032ms, gc=165ms, heap dump=2932ms, analysis=29907ms* Details:
* Instance of android.view.inputmethod.InputMethodManager$1
|   this$0 = android.view.inputmethod.InputMethodManager [id=0x130239c0]
|   mDescriptor = java.lang.String [id=0x6f5e3f38]
|   mObject = -1601862176
|   mOwner = android.view.inputmethod.InputMethodManager$1 [id=0x13112da0]
* Instance of android.view.inputmethod.InputMethodManager
|   static $staticOverhead = byte[] [id=0x6fe25d29;length=240;size=256]
|   static CONTROL_START_INITIAL = 256
|   static CONTROL_WINDOW_FIRST = 4
|   static CONTROL_WINDOW_IS_TEXT_EDITOR = 2
|   static CONTROL_WINDOW_VIEW_HAS_FOCUS = 1
|   static DEBUG = false
|   static DISPATCH_HANDLED = 1
|   static DISPATCH_IN_PROGRESS = -1
|   static DISPATCH_NOT_HANDLED = 0
|   static HIDE_IMPLICIT_ONLY = 1
|   static HIDE_NOT_ALWAYS = 2
|   static INPUT_METHOD_NOT_RESPONDING_TIMEOUT = 2500
|   static MSG_BIND = 2
|   static MSG_DUMP = 1
|   static MSG_FLUSH_INPUT_EVENT = 7
|   static MSG_SEND_INPUT_EVENT = 5
|   static MSG_SET_ACTIVE = 4
|   static MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER = 9
|   static MSG_TIMEOUT_INPUT_EVENT = 6
|   static MSG_UNBIND = 3
|   static NOT_AN_ACTION_NOTIFICATION_SEQUENCE_NUMBER = -1
|   static PENDING_EVENT_COUNTER = java.lang.String [id=0x6f5bb948]
|   static REQUEST_UPDATE_CURSOR_ANCHOR_INFO_NONE = 0
|   static RESULT_HIDDEN = 3
|   static RESULT_SHOWN = 2
|   static RESULT_UNCHANGED_HIDDEN = 1
|   static RESULT_UNCHANGED_SHOWN = 0
|   static SHOW_FORCED = 2
|   static SHOW_IMPLICIT = 1
|   static TAG = java.lang.String [id=0x6f5a76e0]
|   static sInstance = android.view.inputmethod.InputMethodManager [id=0x130239c0]
|   mActive = true
|   mBindSequence = 1523
|   mClient = android.view.inputmethod.InputMethodManager$1 [id=0x13112da0]
|   mCompletions = null
|   mCurChannel = android.view.InputChannel [id=0x1304a850]
|   mCurId = java.lang.String [id=0x1325dd80]
|   mCurMethod = com.android.internal.view.IInputMethodSession$Stub$Proxy [id=0x1304a840]
|   mCurRootView = com.android.internal.policy.impl.PhoneWindow$DecorView [id=0x12eac000]
|   mCurSender = android.view.inputmethod.InputMethodManager$ImeInputEventSender [id=0x12c72850]
|   mCurrentTextBoxAttribute = android.view.inputmethod.EditorInfo [id=0x133036c0]
|   mCursorAnchorInfo = null
|   mCursorCandEnd = 0
|   mCursorCandStart = 0
|   mCursorRect = android.graphics.Rect [id=0x13112d40]
|   mCursorSelEnd = 0
|   mCursorSelStart = 0
|   mDummyInputConnection = android.view.inputmethod.BaseInputConnection [id=0x13112dc0]
|   mFullscreenMode = false
|   mH = android.view.inputmethod.InputMethodManager$H [id=0x13112de0]
|   mHasBeenInactive = false
|   mIInputContext = android.view.inputmethod.InputMethodManager$ControlledInputConnectionWrapper [id=0x13113310]
|   mLastSentUserActionNotificationSequenceNumber = -1
|   mMainLooper = android.os.Looper [id=0x12c76be0]
|   mNextServedView = com.couchsurfing.mobile.ui.drawer.DrawerView [id=0x131f8c00]
|   mNextUserActionNotificationSequenceNumber = 1
|   mPendingEventPool = android.util.Pools$SimplePool [id=0x13110fe0]
|   mPendingEvents = android.util.SparseArray [id=0x13112d80]
|   mRequestUpdateCursorAnchorInfoMonitorMode = 0
|   mServedConnecting = false
|   mServedInputConnection = null
|   mServedInputConnectionWrapper = null
|   mServedView = com.couchsurfing.mobile.ui.drawer.DrawerView [id=0x131f8c00]
|   mService = com.android.internal.view.IInputMethodManager$Stub$Proxy [id=0x13110fc0]
|   mTmpCursorRect = android.graphics.Rect [id=0x13112d20]
|   mViewToScreenMatrix = android.graphics.Matrix [id=0x13110fd0]
|   mViewTopLeft = int[] [id=0x13112d60;length=2;size=24]
* Instance of com.android.internal.policy.impl.PhoneWindow$DecorView
|   mActionMode = null
|   mActionModePopup = null
|   mActionModeView = null
|   mBackgroundFallback = com.android.internal.widget.BackgroundFallback [id=0x12fdd8e0]
|   mBackgroundPadding = android.graphics.Rect [id=0x12ffd9a0]
|   mBarEnterExitDuration = 250
|   mChanging = false
|   mDefaultOpacity = -1
|   mDownY = 0
|   mDrawingBounds = android.graphics.Rect [id=0x12ffd980]
|   mFeatureId = -1
|   mFrameOffsets = android.graphics.Rect [id=0x12ffd9e0]
|   mFramePadding = android.graphics.Rect [id=0x12ffd9c0]
|   mHideInterpolator = android.view.animation.PathInterpolator [id=0x12ffdb00]
|   mLastBottomInset = 144
|   mLastHasBottomStableInset = true
|   mLastHasTopStableInset = true
|   mLastRightInset = 0
|   mLastTopInset = 75
|   mLastWindowFlags = -2122252032
|   mMenuBackground = null
|   mNavigationColorViewState = com.android.internal.policy.impl.PhoneWindow$ColorViewState [id=0x12ff2c70]
|   mNavigationGuard = null
|   mRootScrollY = 0
|   mShowActionModePopup = null
|   mShowInterpolator = android.view.animation.PathInterpolator [id=0x12ffda60]
|   mStatusColorViewState = com.android.internal.policy.impl.PhoneWindow$ColorViewState [id=0x12ff2c40]
|   mStatusGuard = null
|   mWatchingForMenu = false
|   this$0 = com.android.internal.policy.impl.PhoneWindow [id=0x12db9e00]
|   mForeground = null
|   mForegroundBoundsChanged = true
|   mForegroundGravity = 119
|   mForegroundInPadding = true
|   mForegroundPaddingBottom = 0
|   mForegroundPaddingLeft = 0
|   mForegroundPaddingRight = 0
|   mForegroundPaddingTop = 0
|   mForegroundTintList = null
|   mForegroundTintMode = null
|   mHasForegroundTint = false
|   mHasForegroundTintMode = false
|   mMatchParentChildren = java.util.ArrayList [id=0x12ffd960]
|   mMeasureAllChildren = false
|   mOverlayBounds = android.graphics.Rect [id=0x12ffd940]
|   mSelfBounds = android.graphics.Rect [id=0x12ffd920]
|   mAnimationListener = null
|   mCachePaint = null
|   mChildAcceptsDrag = false
|   mChildCountWithTransientState = 0
|   mChildTransformation = null
|   mChildren = android.view.View[] [id=0x130064c0;length=12]
|   mChildrenCount = 3
|   mCurrentDrag = null
|   mCurrentDragView = null
|   mDisappearingChildren = null
|   mDragNotifiedChildren = null
|   mFirstHoverTarget = null
|   mFirstTouchTarget = null
|   mFocused = android.widget.LinearLayout [id=0x12eac800]
|   mGroupFlags = 2375763
|   mHoveredSelf = false
|   mInvalidateRegion = null
|   mInvalidationTransformation = null
|   mLastTouchDownIndex = 0
|   mLastTouchDownTime = 137539724
|   mLastTouchDownX = 605.0
|   mLastTouchDownY = 1177.0
|   mLayoutAnimationController = null
|   mLayoutCalledWhileSuppressed = false
|   mLayoutMode = 0
|   mLayoutTransitionListener = android.view.ViewGroup$3 [id=0x12fdd850]
|   mLocalPoint = null
|   mNestedScrollAxes = 0
|   mOnHierarchyChangeListener = null
|   mPersistentDrawingCache = 2
|   mPreSortedChildren = null
|   mSuppressLayout = false
|   mTempPoint = float[] [id=0x12c0a220;length=2;size=24]
|   mTransition = null
|   mTransitioningViews = null
|   mVisibilityChangingChildren = null
|   mAccessibilityCursorPosition = -1
|   mAccessibilityDelegate = null
|   mAccessibilityTraversalAfterId = -1
|   mAccessibilityTraversalBeforeId = -1
|   mAccessibilityViewId = -1
|   mAnimator = null
|   mAttachInfo = android.view.View$AttachInfo [id=0x12c4fcc0]
|   mAttributes = null
|   mBackground = android.graphics.drawable.ColorDrawable [id=0x13014f80]
|   mBackgroundRenderNode = android.view.RenderNode [id=0x12c73740]
|   mBackgroundResource = 0
|   mBackgroundSizeChanged = false
|   mBackgroundTint = null
|   mBottom = 1920
|   mCachingFailed = false
|   mClipBounds = null
|   mContentDescription = null
|   mContext = com.couchsurfing.mobile.ui.MainActivity [id=0x12db9c80]
|   mCurrentAnimation = null
|   mDrawableState = null
|   mDrawingCache = null
|   mDrawingCacheBackgroundColor = 0
|   mFloatingTreeObserver = null
|   mGhostView = null
|   mHasPerformedLongPress = false
|   mID = -1
|   mInputEventConsistencyVerifier = null
|   mKeyedTags = null
|   mLabelForId = -1
|   mLastIsOpaque = true
|   mLayerPaint = null
|   mLayerType = 0
|   mLayoutInsets = null
|   mLayoutParams = android.view.WindowManager$LayoutParams [id=0x12f1f7e0]
|   mLeft = 0
|   mLeftPaddingDefined = true
|   mListenerInfo = android.view.View$ListenerInfo [id=0x13109940]
|   mMatchIdPredicate = null
|   mMatchLabelForPredicate = null
|   mMeasureCache = android.util.LongSparseLongArray [id=0x13400120]
|   mMeasuredHeight = 1920
|   mMeasuredWidth = 1080
|   mMinHeight = 0
|   mMinWidth = 0
|   mNestedScrollingParent = null
|   mNextFocusDownId = -1
|   mNextFocusForwardId = -1
|   mNextFocusLeftId = -1
|   mNextFocusRightId = -1
|   mNextFocusUpId = -1
|   mOldHeightMeasureSpec = 1073743744
|   mOldWidthMeasureSpec = 1073742904
|   mOutlineProvider = android.view.ViewOutlineProvider$1 [id=0x6fcd7240]
|   mOverScrollMode = 1
|   mOverlay = null
|   mPaddingBottom = 0
|   mPaddingLeft = 0
|   mPaddingRight = 0
|   mPaddingTop = 0
|   mParent = android.view.ViewRootImpl [id=0x13313400]
|   mPendingCheckForLongPress = null
|   mPendingCheckForTap = null
|   mPerformClick = null
|   mPrivateFlags = 25201976
|   mPrivateFlags2 = 1611867680
|   mPrivateFlags3 = 4
|   mRecreateDisplayList = false
|   mRenderNode = android.view.RenderNode [id=0x12ffd880]
|   mResources = android.content.res.Resources [id=0x12c078e0]
|   mRight = 1080
|   mRightPaddingDefined = true
|   mScrollCache = null
|   mScrollX = 0
|   mScrollY = 0
|   mSendViewScrolledAccessibilityEvent = null
|   mSendViewStateChangedAccessibilityEvent = null
|   mSendingHoverAccessibilityEvents = false
|   mStateListAnimator = null
|   mSystemUiVisibility = 0
|   mTag = null
|   mTempNestedScrollConsumed = null
|   mTop = 0
|   mTouchDelegate = null
|   mTouchSlop = 24
|   mTransformationInfo = android.view.View$TransformationInfo [id=0x1349e7c0]
|   mTransientStateCount = 0
|   mTransitionName = null
|   mUnscaledDrawingCache = null
|   mUnsetPressedState = null
|   mUserPaddingBottom = 0
|   mUserPaddingEnd = -2147483648
|   mUserPaddingLeft = 0
|   mUserPaddingLeftInitial = 0
|   mUserPaddingRight = 0
|   mUserPaddingRightInitial = 0
|   mUserPaddingStart = -2147483648
|   mVerticalScrollFactor = 0.0
|   mVerticalScrollbarPosition = 0
|   mViewFlags = 402655360
|   mWindowAttachCount = 1
* Instance of android.view.View$AttachInfo
|   mAccessibilityFetchFlags = 0
|   mAccessibilityFocusDrawable = null
|   mAccessibilityWindowId = 2147483647
|   mApplicationScale = 1.0
|   mCanvas = null
|   mContentInsets = android.graphics.Rect [id=0x13364ee0]
|   mDebugLayout = false
|   mDisabledSystemUiVisibility = 0
|   mDisplay = android.view.Display [id=0x12f75b50]
|   mDisplayState = 2
|   mDrawingTime = 137551407
|   mForceReportNewAttributes = false
|   mGivenInternalInsets = android.view.ViewTreeObserver$InternalInsetsInfo [id=0x13364f40]
|   mGlobalSystemUiVisibility = 0
|   mHandler = android.view.ViewRootImpl$ViewRootHandler [id=0x13364d00]
|   mHardwareAccelerated = true
|   mHardwareAccelerationRequested = true
|   mHardwareRenderer = android.view.ThreadedRenderer [id=0x13323dc0]
|   mHasNonEmptyGivenInternalInsets = false
|   mHasSystemUiListeners = true
|   mHasWindowFocus = true
|   mHighContrastText = false
|   mIWindowId = null
|   mIgnoreDirtyState = false
|   mInTouchMode = true
|   mInvalidateChildLocation = int[] [id=0x13370060;length=2;size=24]
|   mKeepScreenOn = false
|   mKeyDispatchState = android.view.KeyEvent$DispatcherState [id=0x13364fc0]
|   mOverscanInsets = android.graphics.Rect [id=0x13364ec0]
|   mOverscanRequested = false
|   mPanelParentWindowToken = null
|   mPendingAnimatingRenderNodes = null
|   mPoint = android.graphics.Point [id=0x133582f0]
|   mRecomputeGlobalAttributes = false
|   mRootCallbacks = android.view.ViewRootImpl [id=0x13313400]
|   mRootView = com.android.internal.policy.impl.PhoneWindow$DecorView [id=0x12eac000]
|   mScalingRequired = false
|   mScrollContainers = java.util.ArrayList [id=0x13364fa0]
|   mSession = android.view.IWindowSession$Stub$Proxy [id=0x13358290]
|   mSetIgnoreDirtyState = true
|   mStableInsets = android.graphics.Rect [id=0x13364f20]
|   mSystemUiVisibility = 0
|   mTempArrayList = java.util.ArrayList [id=0x133701a0]
|   mTmpInvalRect = android.graphics.Rect [id=0x133700c0]
|   mTmpLocation = int[] [id=0x13370080;length=2;size=24]
|   mTmpMatrix = android.graphics.Matrix [id=0x133582d0]
|   mTmpOutline = android.graphics.Outline [id=0x13370180]
|   mTmpRectList = java.util.ArrayList [id=0x13370120]
|   mTmpTransformLocation = float[] [id=0x133700a0;length=2;size=24]
|   mTmpTransformRect = android.graphics.RectF [id=0x133700e0]
|   mTmpTransformRect1 = android.graphics.RectF [id=0x13370100]
|   mTmpTransformation = android.view.animation.Transformation [id=0x13370140]
|   mTransparentLocation = int[] [id=0x13370040;length=2;size=24]
|   mTreeObserver = android.view.ViewTreeObserver [id=0x133656c0]
|   mTurnOffWindowResizeAnim = false
|   mUnbufferedDispatchRequested = false
|   mUse32BitDrawingCache = true
|   mViewRequestingLayout = null
|   mViewRootImpl = android.view.ViewRootImpl [id=0x13313400]
|   mViewScrollChanged = false
|   mViewVisibilityChanged = false
|   mVisibleInsets = android.graphics.Rect [id=0x13364f00]
|   mWindow = android.view.ViewRootImpl$W [id=0x13364e80]
|   mWindowId = null
|   mWindowLeft = 0
|   mWindowToken = android.view.ViewRootImpl$W [id=0x13364e80]
|   mWindowTop = 0
|   mWindowVisibility = 0
* Instance of android.view.ViewTreeObserver
|   mAlive = true
|   mOnComputeInternalInsetsListeners = null
|   mOnDrawListeners = null
|   mOnEnterAnimationCompleteListeners = null
|   mOnGlobalFocusListeners = null
|   mOnGlobalLayoutListeners = android.view.ViewTreeObserver$CopyOnWriteArray [id=0x1315a300]
|   mOnPreDrawListeners = android.view.ViewTreeObserver$CopyOnWriteArray [id=0x13345760]
|   mOnScrollChangedListeners = android.view.ViewTreeObserver$CopyOnWriteArray [id=0x12fd3220]
|   mOnTouchModeChangeListeners = java.util.concurrent.CopyOnWriteArrayList [id=0x133a1420]
|   mOnWindowAttachListeners = null
|   mOnWindowFocusListeners = null
|   mOnWindowShownListeners = null
|   mWindowShown = false
* Instance of android.view.ViewTreeObserver$CopyOnWriteArray
|   mAccess = android.view.ViewTreeObserver$CopyOnWriteArray$Access [id=0x12fa1960]
|   mData = java.util.ArrayList [id=0x12fd3240]
|   mDataCopy = null
|   mStart = false
* Instance of java.util.ArrayList
|   static $staticOverhead = byte[] [id=0x6fcffb29;length=16;size=32]
|   static MIN_CAPACITY_INCREMENT = 12
|   static serialVersionUID = 8683452581122892189
|   array = java.lang.Object[] [id=0x13094a40;length=12]
|   size = 1
|   modCount = 1
* Array of java.lang.Object[]
|   [0] = com.couchsurfing.mobile.ui.events.detail.EventDetailsView$1 [id=0x12fa1950]
|   [1] = null
|   [2] = null
|   [3] = null
|   [4] = null
|   [5] = null
|   [6] = null
|   [7] = null
|   [8] = null
|   [9] = null
|   [10] = null
|   [ 

Source: (StackOverflow)

Stuck at "Dumping memory, app will freeze. Brrr." message

I'm trying to use LeakCanary to detect memory leaks in my app, but it does not go further than the message "Dumping memory, app will freeze. Brrr." I've been waiting for about 20 minutes or so, but no changes. Same behaviour on these devices: 1. Asus fonepad 8 (Android 5.0 stock) 2. Sony Xperia SP (Android 5.1.1 CM 12.1 custom) 3. HTC Desire C (Android 4.4 CM 11 custom)

I did everything as its advised in instruction:

public class ExampleApplication extends Application {

  @Override public void onCreate() {
    super.onCreate();
    LeakCanary.install(this);
  }
}

Source: (StackOverflow)

ViewRootImpl mFallbackEventHandler memory Leak

I found this memory leak using leak canary, I think is related to the InputHandler. It might be a bug on Android sdk

11-23 19:14:12.267 6871-8173/com.example D/LeakCanary: * com.example.ui.record.RecordActivity has leaked:
11-23 19:14:12.267 6871-8173/com.example D/LeakCanary: * GC ROOT android.view.ViewRootImpl[.this$0 (anonymous class implements android.view.InputHandler)
11-23 19:14:12.267 6871-8173/com.example D/LeakCanary: * references android.view.ViewRootImpl.mFallbackEventHandler
11-23 19:14:12.267 6871-8173/com.example D/LeakCanary: * references com.android.internal.policy.impl.PhoneFallbackEventHandler.mContext
11-23 19:14:12.267 6871-8173/com.example D/LeakCanary: * leaks com.example.ui.record.RecordActivity instance
11-23 19:14:12.267 6871-8173/com.example D/LeakCanary: * Reference Key: f8f44240-d6e0-475e-aaa4-bd6aa90de2bd]

Source: (StackOverflow)

Error building with leak canary

Getting an error with leak canary when doing my gradle sync:

Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material'.

My build:

compileSdkVersion 17
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.assistek.ediary"
    minSdkVersion 12
    targetSdkVersion 12
}


dependencies {
compile 'joda-time:joda-time:2.4'
compile 'joda-time:joda-time:2.4'
compile 'joda-time:joda-time:2.2'
compile files('libs/android-support-v13.jar')
compile files('libs/commons-collections-3.2.1.jar')
compile files('libs/commons-lang-2.6.jar')
compile files('libs/commons-net-2.2.jar')
compile files('libs/ksoap2-android-assembly-2.6.0-jar-with-dependencies.jar')
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'

}

Too old a builde for this library?


Source: (StackOverflow)

Android Leak Canary and StreetViewPanoramaFragment

I've added Leak Canary to a personal Android application and the following stack trace was generated:

05-13 06:49:15.589  27088-28230/com.upwardsnorthwards.blueplaqueslondon D/LeakCanary﹕ In com.upwardsnorthwards.blueplaqueslondon:1.2:3.
* com.upwardsnorthwards.blueplaqueslondon.activities.PanoramaActivity has leaked:
* GC ROOT thread com.google.maps.api.android.lib6.gmm6.streetview.bf.v (named 'Renderer')
* references com.google.maps.api.android.lib6.gmm6.streetview.f.mParent
* references android.widget.FrameLayout.mParent
* references android.widget.FrameLayout.mContext
* leaks com.upwardsnorthwards.blueplaqueslondon.activities.PanoramaActivity instance
* Reference Key: 9d5d97cd-865a-4f93-92c1-63f7a8589525
* Device: motorola motorola XT1021 condor_tescogb
* Android Version: 4.4.4 API: 19
* Durations: watch=5024ms, gc=236ms, heap dump=745ms, analysis=39070ms

The PanoramaActivity which is causing this has an onCreate method which looks like:

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_panorama);
    final StreetViewPanoramaFragment streetViewPanoramaFragment =
            (StreetViewPanoramaFragment) getFragmentManager()
                    .findFragmentById(R.id.street_view_panorama);
    streetViewPanoramaFragment.getStreetViewPanoramaAsync(this);
    final Intent intent = getIntent();
    if (intent != null) {
        placemark = (Placemark) intent
                .getParcelableExtra(BluePlaquesConstants.PANORAMA_CLICKED_PARCLEABLE_KEY);
    }
}

The .xml layout file for this activity looks like:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/street_view_panorama"
    android:name="com.google.android.gms.maps.StreetViewPanoramaFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

My gradle file for the project looks like:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.github.hotchemi:android-rate:0.4.2'
    compile 'com.squareup:otto:1.3.6'
}

The full source for the application is available at https://github.com/seanoshea/BluePlaquesLondon-Android and I've created an issue to track this at https://github.com/seanoshea/BluePlaquesLondon-Android/issues/69.

Has anyone else run into this problem? Might you be able to suggest a solution?

Cheers,

Sean


Source: (StackOverflow)

How can I include LeakCanary when using both build types and product flavors?

The LeakCanary documentation mentions the following for handling build types:

 dependencies {
   debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
   releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
 }

However, what about when using multiple product flavors as well? I'm receiving an error Gradle DSL method not found on the buildTypeCompile functions.

Here is a skeleton of my current Gradle file:

android {
    ...

    dependencies {
        debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
        ciCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
        qaCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
        uatCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
        prodCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
        releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
    }

    productFlavors {
        foo {
            buildTypes {
                ci {
                    ...
                }

                qa {
                    ...
                }
            }
        }

        bar {
            buildTypes {
                ci {
                    ...
                }

                qa {
                    ...
                }
            }
        }
    }
}

Source: (StackOverflow)

LeakCanary's DisplayLeakActivity has leaked, any insights?

I recently added the LeakCanary library to my application. After detecting a couple activity leaks and viewing them, I saw that LeakCanary's DisplayLeakActivity had leaked. I can't find anything in the reference path that is part of my application, and as far as I can tell, I have followed the instructions for proper usage (they're pretty straightforward :) ).

The reference path is as follows:

In com.chris:0.890:890.

  • com.squareup.leakcanary.internal.DisplayLeakActivity has leaked:
  • GC ROOT android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue
  • references android.os.MessageQueue.mMessages
  • references android.os.Message.callback
  • references android.view.View$ScrollabilityCache.host
  • references android.widget.ListView.mContext
  • leaks com.squareup.leakcanary.internal.DisplayLeakActivity instance

  • Reference Key: 48e6a173-9de4-436f-9eef-0913ebabadf6

  • Device: LGE lge LG-LS980 g2_spr_us
  • Android Version: 4.4.2 API: 19
  • Durations: watch=5127ms, gc=246ms, heap dump=3729ms, analysis=18335ms

It should be noted that this has only occured on an LG G2. I have not seen it on any other devices. Has anyone seen this or does anyone know what might be causing it?


Source: (StackOverflow)

Avoiding memory leak from crittercism in android

We use crittercism in our app for crash reporting. We've recently began using LeakCanary, and the app is finding leaks which appear to be caused by crittercism. Does anyone know of a way to configure or manipulate crittercism's android SDK to avoid this leak?

* com.my.app.activity.MyActivity has leaked:
* GC ROOT com.my.app.AppInstance.mActivityLifecycleCallbacks
* references java.util.ArrayList.array
* references array java.lang.Object[].[1]
* references crittercism.android.av.g
* references crittercism.android.bd.mPendingResult
* references android.app.LoadedApk$ReceiverDispatcher$Args.this$0
* references android.app.LoadedApk$ReceiverDispatcher.mContext
* leaks com.my.app.activity.MyActivity instance

* Device: motorola motorola XT1254 quark_verizon
* Android Version: 4.4.4 API: 19 LeakCanary: 1.3.1
* Durations: watch=6008ms, gc=210ms, heap dump=3730ms, analysis=29858ms

Source: (StackOverflow)

Memory leak by AttachInfo.mRootCallbacks reported by LeakCanary

I'm using LeakCanary library to troubleshoot a memory leak of my activity. After fixing several issues I got this logcat output :

  • com.MyPackage.activities.MyActivity has leaked:
  • GC ROOT com.MyPackage.MyView.mAttachInfo
  • references android.view.View$AttachInfo.mRootCallbacks
  • references android.view.ViewRootImpl.mContext
  • leaks com.MyPackage.activities.MyActivity instance
  1. I have no idea what this reference mean. The view is keeping a reference to the activity which prevents it from being GCed? When and how should I handle it?
  2. I used Eclipse memory analyze tool tool and found that there are actually no instances of my activity alive. Does that make sense?

Also opened this as an issue for canary.


Edit 1 : relevant implementation :

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

     MyView.InteractionCallbacks interactionCallback = new InteractionCallbackImplementation(
     mNewView = new MyView(getActivity().getApplicationContext(), 
     LayoutInflater li = (LayoutInflater) getActivity().getApplicationContext().getSystemService(
                                                                                          Service.LAYOUT_INFLATER_SERVICE);
     ViewGroup fragmentLayout = (ViewGroup) li.inflate(R.layout.fragment_layout, container, false);
     fragmentLayout.addView(mNewView, 0);
}

public static class InteractionCallbackImplementation implements MyView.InteractionCallbacks {

        WeakReference<MyFragment> frag;
        public InteractionCallbackImplementation(MyFragment myFragment){
            frag = new WeakReference<myFragment>(myFragment);
        }

        @Override
        public void partsSelected(long[] parts) {
               // ...
        }
}

The view : Is a part of external jar which handles gl rendering. has a reference to the fragment.

public class MyView extends GLSurfaceView implements Renderer {
     private void runOnUiThread(Runnable runnable) {
          this.getHandler().post(runnable);
     }
}

What I know is that when I leave the activity :

  1. The activity is destroyed and there are no instances of the activity anymore.
  2. The fragment is destroyed.
  3. The view is detached.

So why would the canary library claim that - there’s a leaked reference?

When and how should a view lose it's reference to it's context?


Source: (StackOverflow)

Reading LeakCanary Log

I have installed LeakCanary to see if my app had memory leaks.

It appears so, but I can't read the log, any one can tell me how, or give the good tutorial I can't find???

In the doc in github, it says:

Once you have the leak trace, figure out which reference in the path should not exist. Then figure out why that reference still exists.

But I don't know how to do it.

Tx!

Here is my log.

In com.myapp.mobile:1.3:33.
* LEAK CAN BE IGNORED.
* com.myapp.mobile.SplashScreen has leaked:
* GC ROOT static android.view.ViewConfiguration.
* references android.util.SparseArray.mValues
* references array java.lang.Object[].[0]
* references android.view.ViewConfiguration.mContext
* leaks com.myapp.mobile.SplashScreen instance
[ 07-17 14:59:07.213 32231:  770 D/LeakCanary ]

* Device: samsung samsung SGH-I337M jflteub
* Android Version: 4.4.2 API: 19 LeakCanary: 1.3.1
* Durations: watch=5014ms, gc=155ms, heap dump=1322ms, 
[ 07-17 14:59:07.213 32231:  770 D/LeakCanary ]

* Class android.view.ViewConfiguration
|   static $staticOverhead = byte[] [
|   static DEFAULT_LONG_PRESS_TIMEOUT = 500
|   static DOUBLE_TAP_MIN_TIME = 40
|   static DOUBLE_TAP_SLOP = 100
|   static DOUBLE_TAP_TIMEOUT = 300
|   static DOUBLE_TAP_TOUCH_SLOP = 8
|   static EDGE_SLOP = 12
|   static FADING_EDGE_LENGTH = 12
|   static GLOBAL_ACTIONS_KEY_TIMEOUT = 500
|   static HOVER_TAP_SLOP = 20
|   static HOVER_TAP_TIMEOUT = 150
|   static JUMP_TAP_TIMEOUT = 500
|   static KEY_REPEAT_DELAY = 50
|   static MAXIMUM_DRAWING_CACHE_SIZE = 1536000
|   static MAXIMUM_FLING_VELOCITY = 8000
|   static MINIMUM_FLING_VELOCITY = 50
|   static OVERFLING_DISTANCE = 6
|   static OVERSCROLL_DISTANCE = 0
|   static PAGING_TOUCH_SLOP = 16
|   static PRESSED_STATE_DURATION = 64
|   static SCROLL_BAR_DEFAULT_DELAY = 300
|   static SCROLL_BAR_FADE_DURATION = 250
|   static SCROLL_BAR_SIZE = 10
|   static SCROLL_FRICTION = 0.015
|   static 
|   static TAP_TIMEOUT = 180
|   static TOUCH_SLOP = 8
|   static WINDOW_TOUCH_SLOP = 16
|   static ZOOM_CONTROLS_TIMEOUT = 3000
|   static sConfigurations = android.util.SparseArray [
* Instance of android.util.SparseArray
|   static $staticOverhead = byte[] [
|   static DELETED = java.lang.Object [id=0x41884b48]
|   mValues = java.lang.Object[] [id=0x421af900;length=5
|   mKeys = int[] [id=0x421af8d8;length=5;size=32]
|   mSize = 1
|   mGarbage = false
* Array of java.lang.Object[]
|   [0] = android.view.ViewConfiguration [id=0x42a8a2d8]
|   [1] = null
|   [2] = null
|   [3] = null
|   [4] = null
* Instance of android.view.ViewConfiguration
|   static $staticOverhead = byte[] [
|   static DEFAULT_LONG_PRESS_TIMEOUT = 500
|   static DOUBLE_TAP_MIN_TIME = 40
|   static DOUBLE_TAP_SLOP = 100
|   static DOUBLE_TAP_TIMEOUT = 300
|   static DOUBLE_TAP_TOUCH_SLOP = 8
|   static EDGE_SLOP = 12
|   static FADING_EDGE_LENGTH = 12
|   static GLOBAL_ACTIONS_KEY_TIMEOUT = 500
|   static HOVER_TAP_SLOP = 20
|   static HOVER_TAP_TIMEOUT = 150
|   static JUMP_TAP_TIMEOUT = 500
|   static KEY_REPEAT_DELAY = 50
|   static MAXIMUM_DRAWING_CACHE_SIZE = 1536000
|   static MAXIMUM_FLING_VELOCITY = 8000
|   static MINIMUM_FLING_VELOCITY = 50
|   static OVERFLING_DISTANCE = 6
|   static OVERSCROLL_DISTANCE = 0
|   static PAGING_TOUCH_SLOP = 16
|   static PRESSED_STATE_DURATION = 64
|   static SCROLL_BAR_DEFAULT_DELAY = 300
|   static SCROLL_BAR_FADE_DURATION = 250
|   static SCROLL_BAR_SIZE = 10
|   static SCROLL_FRICTION = 0.015
|   static 
|   static TAP_TIMEOUT = 180
|   static TOUCH_SLOP = 8
|   static WINDOW_TOUCH_SLOP = 16
|   static ZOOM_CONTROLS_TIMEOUT = 3000
|   static sConfigurations = android.util.SparseArray [
|   mContext = com.myapp.mobile.SplashScreen [
|   mDoubleTapSlop = 300
|   mDoubleTapTouchSlop = 48
|   mEdgeSlop = 36
|   mFadingEdgeLength = 36
|   mFadingMarqueeEnabled = false
|   mMaximumDrawingCacheSize = 8294400
|   mMaximumFlingVelocity = 24000
|   mMinimumFlingVelocity = 150
|   mOverflingDistance = 18
|   mOverscrollDistance = 0
|   mPagingTouchSlop = 96
|   mScrollbarSize = 30
|   mTouchSlop = 48
|   mWindowTouchSlop = 48
|   sHasPermanentMenuKey = true
|   sHasPermanentMenuKeySet = true
* Instance of com.myapp.mobile.SplashScreen
|   ctx = com.myapp.mobile.SplashScreen [id=0x42a7c450]
|   prefs = android.app.SharedPreferencesImpl [
|   mActionBar = null
|   mActivityInfo = android.content.pm.ActivityInfo [
|   mAllLoaderManagers = android.util.ArrayMap [
|   mApplication = com.myapp.mobile.MyApplication [
|   mWindowManager = android.view.WindowManagerImpl [
|   mWindow = com.android.internal.policy.impl.
|   mUiThread = java.lang.Thread [id=0x4180aea0]
|   mTranslucentCallback = null
|   mComponent = android.content.ComponentName [
|   mToken = android.os.BinderProxy [id=0x42a03820]
|   mContainer = android.app.Activity$1 [id=0x42a7c5c8]
|   mCurrentConfig = android.content.res.Configuration [
|   mDecor = null
|   mTitle = java.lang.String [id=0x42a85570]
|   mDefaultKeySsb = null
|   mSearchManager = null
|   mResultData = null
|   mEmbeddedID = null
|   mParent = null
|   mMenuInflater = null
|   mFragments = android.app.FragmentManagerImpl [
|   mHandler = android.os.Handler [id=0x42a7c670]
|   mManagedDialogs = null
|   mInstanceTracker = android.os.
|   mInstrumentation = android.app.Instrumentation [
|   mIntent = android.content.Intent [id=0x42a03568]
|   mLastNonConfigurationInstances = null
|   mLoaderManager = null
|   mManagedCursors = java.util.ArrayList [id=0x42a7c5d8
|   mMainThread = android.app.ActivityThread [
|   mLoadersStarted = false
|   mIdent = 1123061480
|   mFinished = true
|   mEnableDefaultActionBarUp = false
|   mResultCode = 0
|   mDoReportFullyDrawn = false
|   mResumed = false
|   mDestroyed = true
|   mStartedActivity = false
|   mStopped = true
|   mTemporaryPause = false
|   mDefaultKeyMode = 0
|   mTitleColor = 0
|   mTitleReady = true
|   mConfigChangeFlags = 0
|   mCheckedForLoaderManager = true
|   mChangingConfigurations = false
|   mVisibleFromClient = true
|   mVisibleFromServer = false
|   mChangeCanvasToTranslucent = false
|   mWindowAdded = true
|   mCalled = true
|   mBase = android.app.ContextImpl [id=0x42a7c690]
|   mInflater = com.android.internal.policy.impl.
|   mOverrideConfiguration = null
|   mResources = android.content.res.Resources [
|   mTheme = android.content.res.Resources$Theme [
|   mThemeResource = 2131296377
|   mBase = android.app.ContextImpl [id=0x42a7c690]

In com.myapp.mobile:1.3:33.
* com.myapp.mobile.MetricaTabs has leaked:
* GC ROOT static com.myapp.mobile.MetricaTabs.ctx
* leaks com.myapp.mobile.MetricaTabs instance
[ 07-17 15:00:10.945 32231: 1926 D/LeakCanary ]

* Device: samsung samsung SGH-I337M jflteub
* Android Version: 4.4.2 API: 19 LeakCanary: 1.3.1
* Durations: watch=5015ms, gc=218ms, heap dump=1071ms, 
[ 07-17 15:00:10.945 32231: 1926 D/LeakCanary ]

* Class com.myapp.mobile.MetricaTabs
|   static $staticOverhead = byte[] [
|   static ENCUESTA = 5
|   static METRICA_DATOS = 0
|   static METRICA_ENCUESTAS = 1
|   static TEN_SECONDS = 10000
|   static ctx = com.myapp.mobile.MetricaTabs [
|   static errorList = java.util.ArrayList [
|   static idCaptura = 4
|   static idEncuesta = 0
|   static imageFileUri = null
|   static lMetricas = java.util.ArrayList [
|   static listLV = null
|   static rclForm = android.support.v7.widget.
|   static transparentEt = android.support.v7.widget.
* Instance of com.myapp.mobile.MetricaTabs
|   static $staticOverhead = byte[] [
|   static ENCUESTA = 5
|   static METRICA_DATOS = 0
|   static METRICA_ENCUESTAS = 1
|   static TEN_SECONDS = 10000
|   static ctx = com.myapp.mobile.MetricaTabs [
|   static errorList = java.util.ArrayList [
|   static idCaptura = 4
|   static idEncuesta = 0
|   static imageFileUri = null
|   static lMetricas = java.util.ArrayList [
|   static listLV = null
|   static rclForm = android.support.v7.widget.
|   static transparentEt = android.support.v7.widget.
|   ab = android.support.v7.internal.app.
|   adbForm = null
|   eh = com.myapp.mobile.sqlite.EncuestaHandler [
|   tabLayout = android.support.design.widget.TabLayout 
|   loc = null
|   mCaptura = null
|   mEncuesta = null
|   mSectionsPagerAdapter = com.myapp.mobile.
|   mViewPager = android.support.v4.view.ViewPager [
|   metrica = null
|   prefs = android.app.SharedPreferencesImpl [
|   numTab = 0
|   saveAndNew = false
|   encuesta = 0
|   mDelegate = android.support.v7.app.
|   mAllLoaderManagers = android.support.v4.util.
|   mLoaderManager = null
|   mContainer = android.support.v4.app.
|   mHandler = android.support.v4.app.
|   mFragments = android.support.v4.app.
|   mCreated = true
|   mCheckedForLoaderManager = true
|   mLoadersStarted = false
|   mOptionsMenuInvalidated = false
|   mReallyStopped = true
|   mResumed = false
|   mRetaining = false
|   mStopped = true
|   mActionBar = null
|   mActivityInfo = android.content.pm.ActivityInfo [
|   mAllLoaderManagers = android.util.ArrayMap [
|   mApplication = com.myapp.mobile.MyApplication [
|   mWindowManager = android.view.WindowManagerImpl [
|   mWindow = com.android.internal.policy.impl.
|   mUiThread = java.lang.Thread [id=0x4180aea0]
|   mTranslucentCallback = null
|   mComponent = android.content.ComponentName [
|   mToken = android.os.BinderProxy [id=0x42f18c40]
|   mContainer = android.app.Activity$1 [id=0x42a92978]
|   mCurrentConfig = android.content.res.Configuration [
|   mDecor = null
|   mTitle = java.lang.String [id=0x42fb8850]
|   mDefaultKeySsb = null
|   mSearchManager = null
|   mResultData = null
|   mEmbeddedID = null
|   mParent = null
|   mMenuInflater = null
|   mFragments = android.app.FragmentManagerImpl [
|   mHandler = android.os.Handler [id=0x429fd658]
|   mManagedDialogs = null
|   mInstanceTracker = android.os.
|   mInstrumentation = android.app.Instrumentation [
|   mIntent = android.content.Intent [id=0x42f2ded8]
|   mLastNonConfigurationInstances = null
|   mLoaderManager = null
|   mManagedCursors = java.util.ArrayList [id=0x42a145a8
|   mMainThread = android.app.ActivityThread [
|   mLoadersStarted = false
|   mIdent = 1136727720
|   mFinished = true
|   mEnableDefaultActionBarUp = false
|   mResultCode = 0
|   mDoReportFullyDrawn = false
|   mResumed = false
|   mDestroyed = true
|   mStartedActivity = false
|   mStopped = true
|   mTemporaryPause = false
|   mDefaultKeyMode = 0
|   mTitleColor = 0
|   mTitleReady = true
|   mConfigChangeFlags = 0
|   mCheckedForLoaderManager = true
|   mChangingConfigurations = false
|   mVisibleFromClient = true
|   mVisibleFromServer = true
|   mChangeCanvasToTranslucent = false
|   mWindowAdded = true
|   mCalled = true
|   mBase = android.app.ContextImpl [id=0x429f95b0]
|   mInflater = com.android.internal.policy.impl.
|   mOverrideConfiguration = null
|   mResources = android.content.res.Resources [
|   mTheme = android.content.res.Resources$Theme [
|   mThemeResource = 2131296377
|   mBase = android.app.ContextImpl [id=0x429f95b0]

Source: (StackOverflow)