A memory leak detection library for Android.

Overview

LeakCanary 🐤

A memory leak detection library for Android.

square.github.io/leakcanary

License

Copyright 2015 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Android 6.0 Heap dump parsing failure

    Android 6.0 Heap dump parsing failure

    This happens on both: 1.3.1 and 1.4-SNAPSHOT

    * FAILURE:
    java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
            at com.squareup.leakcanary.HeapAnalyzer.findLeakingReference(HeapAnalyzer.java:160)
            at com.squareup.leakcanary.HeapAnalyzer.checkForLeak(HeapAnalyzer.java:95)
            at com.squareup.leakcanary.internal.HeapAnalyzerService.onHandleIntent(HeapAnalyzerService.java:57)
            at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.os.HandlerThread.run(HandlerThread.java:61)
    * Reference Key: 88f1eda2-7ddd-46df-a20b-7fb23672bc08
    * Device: htc google Nexus 9 volantis
    * Android Version: 6.0 API: 23 LeakCanary: 1.3.1
    
    opened by Exaper 51
  • #159 Renamed resources leading with

    #159 Renamed resources leading with "__"

    Build tools "1.3.0 rc1" changed the rules for resources. This commit simply removes the lead "__" from the offending resources in the project.

    opened by ToxicBakery 51
  • Library leakcanary-android-1.3 is not in list of external libraries

    Library leakcanary-android-1.3 is not in list of external libraries

    I have a project with lots of dependencies. When I add

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

    to main build.gradle, leakcanary-android is not in list of external libraries after gradle sync, although leakcanary-analyzer and leakcanary-watcher are there. See screenshot: screen shot 2015-05-09 at 18 59 23

    On a blank project however everything works fine: screen shot 2015-05-09 at 18 59 09

    opened by zaur 40
  • Memory leak caused by Samsung Clipboard (SemClipboardManager)

    Memory leak caused by Samsung Clipboard (SemClipboardManager)

    Observing frequent memory leak on Samsung S6 Edge with Android 7.0 involving our activity context and Samsungs' clipboard manager

    D/LeakCanary: In im.example.app.debug:2.22.0:0.
    D/LeakCanary: * im.example.app.ui.activities.GroupChatActivity has leaked:
    D/LeakCanary: * GC ROOT com.samsung.android.content.clipboard.SemClipboardManager$2.this$0 (anonymous subclass of android.sec.clipboard.IClipboardDataPasteEvent$Stub)
    D/LeakCanary: * references com.samsung.android.content.clipboard.SemClipboardManager.mContext
    D/LeakCanary: * leaks im.example.app.ui.activities.GroupChatActivity instance
    D/LeakCanary: * Retaining: 1.6 MB.
    D/LeakCanary: * Reference Key: 48f5a969-d8c4-434f-a4af-e2ff53157ddd
    D/LeakCanary: * Device: samsung samsung SM-G925F zeroltexx
    D/LeakCanary: * Android Version: 7.0 API: 24 LeakCanary: 1.5 00f37f5
    D/LeakCanary: * Durations: watch=5013ms, gc=173ms, heap dump=4561ms, analysis=227966ms
    D/LeakCanary: * Details:
    D/LeakCanary: * Instance of com.samsung.android.content.clipboard.SemClipboardManager$2
    D/LeakCanary: |   static $classOverhead = byte[744]@315280385 (0x12cacc01)
    D/LeakCanary: |   this$0 = [email protected]224 (0x1463e9c0)
    D/LeakCanary: |   mDescriptor = [email protected] (0x12c13820)
    D/LeakCanary: |   mObject = 490498265248
    D/LeakCanary: |   mOwner = [email protected]77952 (0x13c1f3c0)
    D/LeakCanary: |   shadow$_klass_ = com.samsung.android.content.clipboard.SemClipboardManager$2
    D/LeakCanary: |   shadow$_monitor_ = 0
    D/LeakCanary: * Instance of com.samsung.android.content.clipboard.SemClipboardManager
    D/LeakCanary: |   static ACTION_REMOVE_CLIP = [email protected] (0x12c16680)
    D/LeakCanary: |   static $classOverhead = byte[904]@1980290401 (0x7608d561)
    D/LeakCanary: |   static sService = [email protected] (0x12c01a00)
    D/LeakCanary: |   static ACTION_DISMISS_CLIPBOARD = [email protected] (0x12c26b80)
    D/LeakCanary: |   static ACTION_CLIPBOARD_CLOSED = [email protected] (0x12c269d0)
    D/LeakCanary: |   static EXTRA_DARK_THEME = [email protected] (0x12c3b6c8)
    D/LeakCanary: |   static EXTRA_NO_TOAST = [email protected] (0x12c4bf20)
    D/LeakCanary: |   static ACTION_CLIPBOARD_OPENED = [email protected] (0x12c26790)
    D/LeakCanary: |   static EXTRA_EXTRA_PATH = [email protected] (0x12c308d0)
    D/LeakCanary: |   static TAG = [email protected] (0x12c5a820)
    D/LeakCanary: |   static EXTRA_PATH = [email protected] (0x6f555eb0)
    D/LeakCanary: |   static EXTRA_TYPE = [email protected] (0x6f54c6c0)
    D/LeakCanary: |   static ACTION_ADD_CLIP = [email protected] (0x12c16200)
    D/LeakCanary: |   FAIL_SET_DATA = 1
    D/LeakCanary: |   KEY_DATA = [email protected] (0x6f5b7e48)
    D/LeakCanary: |   KEY_FILTER = [email protected] (0x6f6c4350)
    D/LeakCanary: |   PROTECTED_DATA_MAX = 3
    D/LeakCanary: |   SUCCESS_AND_SAVE_BITMAP = 2
    D/LeakCanary: |   SUCCESS_SET_DATA = 0
    D/LeakCanary: |   mClipboardPasteEvent = [email protected]77952 (0x13c1f3c0)
    D/LeakCanary: |   mCocktailBarManager = [email protected] (0x13c1f380)
    D/LeakCanary: |   mContext = [email protected] (0x13f3a600)
    D/LeakCanary: |   mHandler = [email protected]77920 (0x13c1f3a0)
    D/LeakCanary: |   mIsFiltered = false
    D/LeakCanary: |   mIsMaximumSize = false
    D/LeakCanary: |   mOnClipboardEventServiceListener = [email protected]77984 (0x13c1f3e0)
    D/LeakCanary: |   mOnClipboardEventServiceListeners = [email protected] (0x13bc9880)
    D/LeakCanary: |   mPasteListener = null
    D/LeakCanary: |   mPersonaManager = [email protected] (0x13bc9868)
    D/LeakCanary: |   mRegInterface = null
    D/LeakCanary: |   mSetDataHandler = null
    D/LeakCanary: |   mTypeId = 0
    D/LeakCanary: |   shadow$_klass_ = com.samsung.android.content.clipboard.SemClipboardManager
    D/LeakCanary: |   shadow$_monitor_ = 0
    D/LeakCanary: * Instance of im.example.app.ui.activities.GroupChatActivity
    D/LeakCanary: |   static $change = null
    D/LeakCanary: |   static serialVersionUID = 4181920779988445483
    D/LeakCanary: |   static $classOverhead = byte[5848]@317517825 (0x12ecf001)
    D/LeakCanary: |   static TAG = [email protected] (0x12c639e0)
    D/LeakCanary: |   DESCRIPTION_MIN_LENGTH_FOR_POPUP = 50
    D/LeakCanary: |   bottomButton = [email protected] (0x13a02800)
    D/LeakCanary: |   bottomButtonWrapper = [email protected] (0x13999000)
    D/LeakCanary: |   buttonProgressBar = [email protected] (0x13a01800)
    D/LeakCanary: |   chatWrapper = null
    D/LeakCanary: |   onlineMembersCount = 1
    D/LeakCanary: |   privateView = null
    D/LeakCanary: |   adapter = [email protected] (0x138e1160)
    D/LeakCanary: |   allBottomLoaded = true
    D/LeakCanary: |   allTopLoaded = false
    D/LeakCanary: |   alreadyLoading = false
    D/LeakCanary: |   chatEditor = [email protected] (0x138a9920)
    D/LeakCanary: |   emojiSkinPopupView = null
    D/LeakCanary: |   fromCountedSerial = null
    D/LeakCanary: |   headersDecoration = com.ti[email protected]328033992 (0x138d66c8)
    D/LeakCanary: |   highlightMessage = false
    D/LeakCanary: |   inputControls = [email protected] (0x13876000)
    D/LeakCanary: |   lastSeenCountedSerial = [email protected] (0x140191f0)
    D/LeakCanary: |   lastSeenSerial = [email protected] (0x14019200)
    D/LeakCanary: |   myMessages = false
    D/LeakCanary: |   newMessageHeader = [email protected] (0x138d6678)
    D/LeakCanary: |   resumed = true
    D/LeakCanary: |   scrollToNewMessageHeaderOnSync = false
    D/LeakCanary: |   storedPositionTopOffset = 0
    D/LeakCanary: |   subscribed = true
    D/LeakCanary: |   targetSerial = null
    D/LeakCanary: |   titleHintShowing = false
    D/LeakCanary: |   typingSubscriptions = java.util.Has[email protected] (0x136321c8)
    D/LeakCanary: |   typingUsers = [email protected] (0x136321f0)
    D/LeakCanary: |   channel = [email protected] (0x131ee368)
    D/LeakCanary: |   goToBottomButton = [email protected] (0x1382d800)
    D/LeakCanary: |   imageShowClicked = false
    D/LeakCanary: |   lastVisibleLink = [email protected] (0x6f4fb508)
    D/LeakCanary: |   layoutManager = [email protected] (0x13a9af20)
    D/LeakCanary: |   linkPopupView = null
    D/LeakCanary: |   membership = [email protected] (0x137c8478)
    D/LeakCanary: |   popupWindow = null
    D/LeakCanary: |   progressBar = [email protected] (0x1382d400)
    D/LeakCanary: |   radialPopupWindow = [email protected] (0x12fedcc0)
    D/LeakCanary: |   recyclerView = [email protected] (0x1382e000)
    D/LeakCanary: |   currentSubTitle = [email protected] (0x13f02580)
    D/LeakCanary: |   appBarLayout = null
    D/LeakCanary: |   bottomNavigationView = null
    D/LeakCanary: |   collapsingToolbarLayout = null
    D/LeakCanary: |   contentOverlay = [email protected] (0x13f3ac00)
    D/LeakCanary: |   contentWrapper = [email protected] (0x137a0800)
    D/LeakCanary: |   coordinatorLayout = null
    D/LeakCanary: |   fab = null
    D/LeakCanary: |   menuIncrementedId = -1
    D/LeakCanary: |   progressBar = [email protected] (0x137a1000)
    D/LeakCanary: |   rightButton = [email protected] (0x137a0c00)
    D/LeakCanary: |   subTitleProgressBar = [email protected] (0x137a1400)
    D/LeakCanary: |   tabLayout = null
    D/LeakCanary: |   toolbar = [email protected] (0x1374fc00)
    D/LeakCanary: |   toolbarContainer = null
    D/LeakCanary: |   toolbarContentWrapper = [email protected] (0x1374ec00)
    D/LeakCanary: |   toolbarGroupLogo = [email protected] (0x13754c00)
    D/LeakCanary: |   toolbarMode = [email protected]76 (0x131ddcd0)
    D/LeakCanary: |   toolbarSubTitle = [email protected] (0x137a1800)
    D/LeakCanary: |   toolbarSubTitleWrapper = [email protected] (0x137a1c00)
    D/LeakCanary: |   toolbarTitle = [email protected] (0x1379e400)
    D/LeakCanary: |   toolbarUserLogo = [email protected] (0x1377b000)
    D/LeakCanary: |   appLayout = [email protected] (0x13743400)
    D/LeakCanary: |   customTabActivityHelper = [email protected]326213032 (0x13719da8)
    D/LeakCanary: |   pendingRunnable = null
    D/LeakCanary: |   subscriptions = [email protected] (0x137ded40)
    D/LeakCanary: |   tracker = [email protected] (0x12d47c90)
    D/LeakCanary: |   mDelegate = [email protected] (0x13787ee0)
    D/LeakCanary: |   mEatKeyUpEvent = false
    D/LeakCanary: |   mResources = null
    D/LeakCanary: |   mThemeId = 2131361857
    D/LeakCanary: |   mCreated = true
    D/LeakCanary: |   mFragments = [email protected] (0x137ded60)
    D/LeakCanary: |   mHandler = [email protected] (0x13804960)
    D/LeakCanary: |   mNextCandidateRequestIndex = 0
    D/LeakCanary: |   mOptionsMenuInvalidated = false
    D/LeakCanary: |   mPendingFragmentActivityResults = [email protected] (0x13719dd8)
    D/LeakCanary: |   mReallyStopped = true
    D/LeakCanary: |   mRequestedPermissionsFromFragment = false
    D/LeakCanary: |   mResumed = false
    D/LeakCanary: |   mRetaining = false
    D/LeakCanary: |   mStopped = true
    D/LeakCanary: |   mStartedActivityFromFragment = false
    D/LeakCanary: |   mStartedIntentSenderFromFragment = false
    D/LeakCanary: |   mExtraDataMap = android.support.v4.util.SimpleA[email protected] (0x13715a48)
    D/LeakCanary: |   mActionBar = null
    D/LeakCanary: |   mActionModeTypeStarting = 0
    D/LeakCanary: |   mActivityInfo = [email protected] (0x12c05dc0)
    D/LeakCanary: |   mActivityTransitionState = [email protected] (0x13800e78)
    D/LeakCanary: |   mAppLockCheckRunnable = [email protected] (0x137ded80)
    D/LeakCanary: |   mAppLockIsInMultiWindowMode = false
    D/LeakCanary: |   mApplication = [email protected] (0x12cffb80)
    D/LeakCanary: |   mCalled = true
    D/LeakCanary: |   mChangeCanvasToTranslucent = false
    D/LeakCanary: |   mChangingConfigurations = false
    D/LeakCanary: |   mComponent = [email protected] (0x1380eff0)
    D/LeakCanary: |   mConfigChangeFlags = 0
    D/LeakCanary: |   mCurrentConfig = [email protected] (0x1378df88)
    D/LeakCanary: |   mDecor = null
    D/LeakCanary: |   mDefaultKeyMode = 0
    D/LeakCanary: |   mDefaultKeySsb = null
    D/LeakCanary: |   mDestroyed = true
    D/LeakCanary: |   mDoReportFullyDrawn = false
    D/LeakCanary: |   mEatKeyUpEvent = false
    D/LeakCanary: |   mEmbeddedID = null
    D/LeakCanary: |   mEnableDefaultActionBarUp = true
    D/LeakCanary: |   mEnterTransitionListener = [email protected] (0x6fc40e68)
    D/LeakCanary: |   mExitTransitionListener = [email protected] (0x6fc40e68)
    D/LeakCanary: |   mFinished = true
    D/LeakCanary: |   mFlipfont = 0
    D/LeakCanary: |   mFragments = [email protected] (0x137deda0)
    D/LeakCanary: |   mHandler = [email protected] (0x138049c0)
    D/LeakCanary: |   mHasCurrentPermissionsRequest = false
    D/LeakCanary: |   mIdent = 179641163
    D/LeakCanary: |   mInstanceTracker = [email protected] (0x137ded90)
    D/LeakCanary: |   mInstrumentation = [email protected] (0x131d4358)
    D/LeakCanary: |   mIntent = [email protected] (0x137f1fc0)
    D/LeakCanary: |   mLastNonConfigurationInstances = null
    D/LeakCanary: |   mMainThread = [email protected] (0x12c04160)
    D/LeakCanary: |   mManagedCursors = [email protected] (0x13715a60)
    D/LeakCanary: |   mManagedDialogs = null
    D/LeakCanary: |   mMenuInflater = null
    D/LeakCanary: |   mParent = null
    D/LeakCanary: |   mPolicyManager = null
    D/LeakCanary: |   mReferrer = [email protected] (0x137e2bd8)
    D/LeakCanary: |   mResultCode = 0
    D/LeakCanary: |   mResultData = null
    D/LeakCanary: |   mResumed = false
    D/LeakCanary: |   mScreenChangeListener = null
    D/LeakCanary: |   mSearchEvent = null
    D/LeakCanary: |   mSearchManager = null
    D/LeakCanary: |   mStartedActivity = false
    D/LeakCanary: |   mStopped = true
    D/LeakCanary: |   mTaskDescription = [email protected] (0x13804980)
    D/LeakCanary: |   mTemporaryPause = false
    D/LeakCanary: |   mTitle = [email protected] (0x12cff910)
    D/LeakCanary: |   mTitleColor = 0
    D/LeakCanary: |   mTitleReady = true
    D/LeakCanary: |   mToken = [email protected] (0x1381dfc0)
    D/LeakCanary: |   mTranslucentCallback = null
    D/LeakCanary: |   mUiThread = [email protected] (0x76076c38)
    D/LeakCanary: |   mVisibleBehind = false
    D/LeakCanary: |   mVisibleFromClient = true
    D/LeakCanary: |   mVisibleFromServer = true
    D/LeakCanary: |   mVoiceInteractor = null
    D/LeakCanary: |   mWindow = [email protected] (0x13c01d20)
    D/LeakCanary: |   mWindowAdded = true
    D/LeakCanary: |   mWindowManager = [email protected] (0x13719fb8)
    D/LeakCanary: |   mInflater = [email protected] (0x13877ac0)
    D/LeakCanary: |   mOverrideConfiguration = null
    D/LeakCanary: |   mResources = [email protected] (0x136feb40)
    D/LeakCanary: |   mTheme = [email protected] (0x137dec60)
    D/LeakCanary: |   mThemeResource = 2131361857
    D/LeakCanary: |   mBase = [email protected] (0x139d5200)
    D/LeakCanary: |   shadow$_klass_ = im.example.app.ui.activities.GroupChatActivity
    D/LeakCanary: |   shadow$_monitor_ = 1073746630
    D/LeakCanary: * Excluded Refs:
    D/LeakCanary: | Field: android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue (always)
    D/LeakCanary: | Thread:FinalizerWatchdogDaemon (always)
    D/LeakCanary: | Thread:main (always)
    D/LeakCanary: | Thread:LeakCanary-Heap-Dump (always)
    D/LeakCanary: | Class:java.lang.ref.WeakReference (always)
    D/LeakCanary: | Class:java.lang.ref.SoftReference (always)
    D/LeakCanary: | Class:java.lang.ref.PhantomReference (always)
    D/LeakCanary: | Class:java.lang.ref.Finalizer (always)
    D/LeakCanary: | Class:java.lang.ref.FinalizerReference (always)
    
    opened by rafaelekol 39
  • Heap analysis failed for Obfuscated App

    Heap analysis failed for Obfuscated App

    Description

    I ran the app from android studio setting up LeakCanary for obfuscated apps and it failed during heap analysis. I turned off obfuscation in progaurd-rules.pro and it worked.

    m.d
    at shark.c$o$a.a()
    at shark.c$o$a.a()
    at shark.q0.a()
    at shark.c$o.a()
    at shark.o.a()
    at shark.o.a()
    at shark.o.a()
    at shark.o.a()
    at shark.o.a()
    at leakcanary.internal.HeapAnalyzerService.a()
    at leakcanary.internal.HeapAnalyzerService.a()
    at leakcanary.internal.i.onHandleIntent()
    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.os.HandlerThread.run(HandlerThread.java:61)
    
    Build.VERSION.SDK_INT: 23
    Build.MANUFACTURER: LGE
    LeakCanary version: 2.2
    Analysis duration: 75543 ms
    Heap dump file path: /storage/emulated/0/Download/leakcanary-com.colevit.furmate/2020-04-25_23-53-20_181.hprof
    Heap dump timestamp: 1587839082676
    

    Steps to Reproduce

    hprof: 2020-04-25_23-53-20_181.hprof.zip

    Expected behavior: It should analyse the heap and show leak trace with de-obfuscated names.

    Version Information

    • LeakCanary version: 2.2
    • Android OS version: 23
    • Gradle version: 5.6.4
    • Android Gradle plugin version: 3.5.3

    Additional Information

    This is tested on a release build though I also tested on debug build as well with code obfuscation and it failed.

    type: bug 
    opened by Guneetgstar 36
  •  Unable to get provider leakcanary.internal.LeakCanaryFileProvider

    Unable to get provider leakcanary.internal.LeakCanaryFileProvider

    Error message:

    E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.xincaidong.truemerger, PID: 29219
        java.lang.RuntimeException: Unable to get provider leakcanary.internal.LeakCanaryFileProvider: java.lang.ClassNotFoundException: Didn't find class "leakcanary.internal.LeakCanaryFileProvider" on path: DexPathList[[zip file "/data/app/com.xincaidong.truemerger-dH6uDnSLWeCztjnKidrcTA==/base.apk"],nativeLibraryDirectories=[/data/app/com.xincaidong.truemerger-dH6uDnSLWeCztjnKidrcTA==/lib/arm64, /data/app/com.xincaidong.truemerger-dH6uDnSLWeCztjnKidrcTA==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
            at android.app.ActivityThread.installProvider(ActivityThread.java:6542)
            at android.app.ActivityThread.installContentProviders(ActivityThread.java:6030)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5936)
            at android.app.ActivityThread.access$1200(ActivityThread.java:200)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1673)
            at android.os.Handler.dispatchMessage(Handler.java:106)
            at android.os.Looper.loop(Looper.java:201)
            at android.app.ActivityThread.main(ActivityThread.java:6815)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
         Caused by: java.lang.ClassNotFoundException: Didn't find class "leakcanary.internal.LeakCanaryFileProvider" on path: DexPathList[[zip file "/data/app/com.xincaidong.truemerger-dH6uDnSLWeCztjnKidrcTA==/base.apk"],nativeLibraryDirectories=[/data/app/com.xincaidong.truemerger-dH6uDnSLWeCztjnKidrcTA==/lib/arm64, /data/app/com.xincaidong.truemerger-dH6uDnSLWeCztjnKidrcTA==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:171)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
            at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:121)
            at androidx.core.app.CoreComponentFactory.instantiateProvider(CoreComponentFactory.java:60)
            at android.app.ActivityThread.installProvider(ActivityThread.java:6526)
            at android.app.ActivityThread.installContentProviders(ActivityThread.java:6030) 
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5936) 
            at android.app.ActivityThread.access$1200(ActivityThread.java:200) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1673) 
            at android.os.Handler.dispatchMessage(Handler.java:106) 
            at android.os.Looper.loop(Looper.java:201) 
            at android.app.ActivityThread.main(ActivityThread.java:6815) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873) 
    

    Dependency:

    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-3'
    

    不集成的时候,都是可以运行的,一集成之后就跑不了。项目是使用了AndroidX的,语言是java

    Edit with translation from Google translate:

    When it is not integrated, it can be run, and it cannot run after integration. The project uses AndroidX and the language is java

    type: bug 
    opened by CaiJinFu 34
  • LeakCanary in Unit Test Artifact

    LeakCanary in Unit Test Artifact

    Hi.

    I got NPE when i run test using Unit Test build variants. Do you have any best practice to do this ?

    java.lang.NullPointerException
        at com.squareup.leakcanary.internal.LeakCanaryInternals.isInServiceProcess(LeakCanaryInternals.java:130)
        at com.squareup.leakcanary.LeakCanary.isInAnalyzerProcess(LeakCanary.java:146)
        at com.squareup.leakcanary.LeakCanary.install(LeakCanary.java:48)
        at com.squareup.leakcanary.LeakCanary.install(LeakCanary.java:37)
        at com.vidio.android.VidioApplication.onCreate(VidioApplication.java:18)
        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)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:168)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69)
        at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:48)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
        at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
        at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:105)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360)
        at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
    

    Is it caused by multiple flavour on release ?

    type: documentation 
    opened by linggom 33
  • ViewGroup.ViewLocationHolder leak in Android P

    ViewGroup.ViewLocationHolder leak in Android P

    I'm testing my app with the new leak canary and on different devices (as well as virtual devices). everything looks fine on all devices except one device which is the only one running Android 8. the analyzing process looks fine but whenever it finishes it shows a few leaks (which other devices won't show!).

    every time I check the trace I end up either with ReportFragment or InputMethodManager.

    is anything actually leaking? is this an excluded leak?

    thanks in advance

    photo_2018-08-06_10-16-39

    type: leak 
    opened by seyedjafariy 31
  • LeakCanary 1.5.2 and 1.6-Snapshot causing build failure

    LeakCanary 1.5.2 and 1.6-Snapshot causing build failure

    Got error like this below with LeakCanary 1.5.2 and 1.6-Snapshot. However, 1.5.1 is fine. The build is ran with Jenkins, it is always a clean build.

    I am using android gradle plugin 2.3.3: classpath 'com.android.tools.build:gradle:2.3.3'

    :app:transformClassesWithDexForArm7Debug FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:transformClassesWithDexForArm7Debug'.
    > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/squareup/leakcanary/watcher/R;
    
    * Try:
    Run with --info or --debug option to get more log output.
    
    * Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithDexForArm7Debug'.
    	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
    	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    	at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    	at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
    	at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    	at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:242)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
    	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:235)
    	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:224)
    	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:121)
    	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:77)
    	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:102)
    	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:96)
    	at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:612)
    	at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:567)
    	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:96)
    	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:57)
    	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:122)
    	at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    	at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
    	at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
    	at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:46)
    	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
    	at org.gradle.initialization.DefaultGradleLauncher$ExecuteTasks.run(DefaultGradleLauncher.java:253)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
    	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:170)
    	at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:44)
    	at org.gradle.initialization.DefaultGradleLauncher$1.run(DefaultGradleLauncher.java:122)
    	at org.gradle.internal.work.DefaultWorkerLeaseService$2.execute(DefaultWorkerLeaseService.java:124)
    	at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:116)
    	at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:99)
    	at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:66)
    	at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    	at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    	at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
    	at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
    	at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
    	at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
    	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:44)
    	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
    	at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
    	at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
    	at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:51)
    	at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
    	at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
    	at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
    	at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
    	at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
    	at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
    	at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42)
    	at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:50)
    	at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
    	at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
    	at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173)
    	at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:287)
    	at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:260)
    	at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:33)
    	at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    	at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    	at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    	at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:253)
    	at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:182)
    	at org.gradle.launcher.Main.doAction(Main.java:33)
    	at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    	at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
    	at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
    	at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    	at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:31)
    	at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:108)
    	at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
    Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/squareup/leakcanary/watcher/R;
    	at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
    	at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
    	at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:176)
    	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    	at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:168)
    	at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
    	at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
    	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:317)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:309)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:185)
    	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:95)
    	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
    	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    	... 87 more
    Caused by: com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/squareup/leakcanary/watcher/R;
    	at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:453)
    	at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:185)
    	at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:181)
    	at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
    	... 99 more
    Caused by: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/squareup/leakcanary/watcher/R;
    	at com.android.builder.core.DexByteCodeConverter.dexInProcess(DexByteCodeConverter.java:180)
    	at com.android.builder.core.DexByteCodeConverter.runDexer(DexByteCodeConverter.java:158)
    	at com.android.builder.core.DexByteCodeConverter.convertByteCode(DexByteCodeConverter.java:143)
    	at com.android.builder.core.AndroidBuilder.convertByteCode(AndroidBuilder.java:1345)
    	at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:443)
    	... 102 more
    Caused by: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/squareup/leakcanary/watcher/R;
    	at com.android.builder.core.DexByteCodeConverter.dexInProcess(DexByteCodeConverter.java:178)
    	... 106 more
    Caused by: com.android.dex.DexException: Multiple dex files define Lcom/squareup/leakcanary/watcher/R;
    	at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:584)
    	at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:539)
    	at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:521)
    	at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)
    	at com.android.dx.merge.DexMerger.merge(DexMerger.java:191)
    	at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:522)
    	at com.android.dx.command.dexer.Main.runMonoDex(Main.java:344)
    	at com.android.dx.command.dexer.Main.run(Main.java:292)
    	at com.android.builder.internal.compiler.DexWrapper.run(DexWrapper.java:54)
    	at com.android.builder.core.DexByteCodeConverter.lambda$dexInProcess$0(DexByteCodeConverter.java:174)
    
    
    opened by zwang 31
  • Leak analysis failed: OutOfMemoryError

    Leak analysis failed: OutOfMemoryError

    LeakCanary Version: 1.4-beta2

    
    * FAILURE:
    java.lang.OutOfMemoryError: Failed to allocate a 2807208 byte allocation with 2467638 free bytes and 2MB until OOM
        at com.squareup.haha.trove.TLongHashSet.rehash(TLongHashSet.java:162)
        at com.squareup.haha.trove.THash.postInsertHook(THash.java:283)
        at com.squareup.haha.trove.TLongHashSet.add(TLongHashSet.java:146)
        at com.squareup.haha.perflib.analysis.TopologicalSort$TopologicalSortVisitor.doVisit(TopologicalSort.java:91)
        at com.squareup.haha.perflib.analysis.TopologicalSort.compute(TopologicalSort.java:36)
        at com.squareup.haha.perflib.Snapshot.computeDominators(Snapshot.java:311)
        at com.squareup.leakcanary.HeapAnalyzer.findLeakTrace(HeapAnalyzer.java:157)
        at com.squareup.leakcanary.HeapAnalyzer.checkForLeak(HeapAnalyzer.java:91)
        at com.squareup.leakcanary.internal.HeapAnalyzerService.onHandleIntent(HeapAnalyzerService.java:58)
        at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
    
    
    opened by jamesbluecrow 30
  • Could not dump heap, previous analysis still is in progress.

    Could not dump heap, previous analysis still is in progress.

    More than ten minutes. Android Studio 3.0.1, Android 5.1.1 or 7.1.1 .

    public class MyApplication extends Application {
        private RefWatcher refWatcher;
    
        @Override
        public void onCreate() {
            super.onCreate();
            if (LeakCanary.isInAnalyzerProcess(this)) {
                // This process is dedicated to LeakCanary for heap analysis.
                // You should not init your app in this process.
                return;
            }
            refWatcher=LeakCanary.install(this);
        }
    
        public static RefWatcher getRefWatcher(Context context){
            MyApplication myApplication= (MyApplication) context.getApplicationContext();
            return myApplication.refWatcher;
        }
    }
    

    in Activity class

       @Override
        protected void onDestroy() {
            super.onDestroy();
            MyApplication.getRefWatcher(getApplicationContext()).watch(Main2Activity.this);
        }
    
    opened by a442509097 29
  • Doc issue with api/leakcanary/-android-leak-fixes/-a-c-c-e-s-s-i-b-i-l-i-t-y_-n-o-d-e_-i-n-f-o/ page

    Doc issue with api/leakcanary/-android-leak-fixes/-a-c-c-e-s-s-i-b-i-l-i-t-y_-n-o-d-e_-i-n-f-o/ page

    The links on this page https://square.github.io/leakcanary/api/leakcanary/-android-leak-fixes/-a-c-c-e-s-s-i-b-i-l-i-t-y_-n-o-d-e_-i-n-f-o/

    seem to be broken

    For example the correct link is https://android.googlesource.com/platform/frameworks/base/+/6f8ec1fd8c159b09d617ed6d9132658051443c0c%5E%21

    However on the website it breaks after the + sign for some reason

    type: documentation 
    opened by tinder-ishankhanna 0
  • Inconsistent version of Kotlin dependencies.

    Inconsistent version of Kotlin dependencies.

    Description

    [Description of the issue]

    Steps to Reproduce

    1. Check version number declared in project: https://github.com/square/leakcanary/blob/f9462209ab553c76ad77673f7bebbd155fa76fa9/gradle/libs.versions.toml#L15-L19

    2. Check version number published in Maven:

    • https://mvnrepository.com/artifact/com.squareup.leakcanary/leakcanary-android-core/2.9.1 -> Kotlin 1.3.72
    • https://mvnrepository.com/artifact/com.squareup.leakcanary/leakcanary-android/2.9.1 -> Kotlin 1.4.21

    Expected behavior: Same version from all modules published as transitive dep.

    Version Information

    • LeakCanary version: at least 2.8.1 and 2.9.1

    Additional Information

    Reason: core has an explicit dependency: https://github.com/square/leakcanary/blob/f9462209ab553c76ad77673f7bebbd155fa76fa9/leakcanary-android-core/build.gradle#L12

    main artifact doesn't: https://github.com/square/leakcanary/blob/main/leakcanary-android/build.gradle which means it "inherits" the version number from the KGP (plugins { id("org.jetbrains.kotlin.android")) applied to the project.

    Recommended fix:

    # See https://kotlinlang.org/docs/gradle.html#dependency-on-the-standard-library
    kotlin.stdlib.default.dependency=false
    
    • re-add missing dependencies explicitly if necessary.
    type: bug 
    opened by TWiStErRob 1
  • 250+ MB Memory Usage by Shark package

    250+ MB Memory Usage by Shark package

    Description

    My app has leakcanary enabled and it crashed due to memory pressure. I pulled a heap dump and noticed that shark had a total of 250MB+ in retained size.

    Is shark expected to hold this much amount of memory ?

    Screenshot from 2022-09-08 10-09-10

    Version Information

    • LeakCanary version: 2.9.1
    • Android OS version: Pixel 6; Android 13
    • Gradle version: 7.1.1
    type: bug 
    opened by sahil2441 2
  • [Android 13] WRITE_EXTERNAL_STORAGE is removed when app targets Android 13

    [Android 13] WRITE_EXTERNAL_STORAGE is removed when app targets Android 13

    Steps to Reproduce

    App > Updated that app targets 33 > Apps is running > Leak canary pops up > It can't see notification

    Expected behavior: [What you expect to happen] App > Updated that app targets 33 > Apps is running > Leak canary pops up > It can see notification

    Version Information

    • LeakCanary version: 2.9.1
    • Android OS version: Andriod 13
    • Gradle version: 7.2.1

    Additional Information

    Any additional information, configuration or data that might be necessary to reproduce the issue. From Android 13 devices, WRITE_EXTERNAL_STORAGE is removed. https://issuetracker.google.com/issues/237634019 https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions

    WRITE_EXTERNAL_STORAGE is using in those classes. Please check this. leakcanary.internal.RequestStoragePermissionActivit leakcanary.internal.LeakDirectoryProvider https://github.com/square/leakcanary/blob/5e69400174e40ce2efac2e493f414783723a8067/leakcanary-android-core/src/main/java/leakcanary/internal/LeakDirectoryProvider.kt#L71

    type: bug 
    opened by SeungwonLee 0
  • Common shared internals

    Common shared internals

    Just dumping some raw notes about the future architecture:

    A thing you can call to trigger a heap dump + analysis That thing is a simple interface which takes a Trigger reason, typed. Maybe it's an Any? Maybe marker interface. This will make it possible to tag, but also skip conditions by wrapping them in a "force" condition.

    There's a condition that returns Yes or Nope with a reason.

    In tests the trigger will likely be "DetectLeaksAssert" and we'd skip any other request.

    DetectLeaksInterceptor looks very much like the conditions we want.

    Also somewhat similar to leakcanary.internal.HeapDumpControl.iCanHasHeap However there the reason is a lazy string, and we have NotifyingNope which triggers notifications. So we need a way to have silent canceling and noisy canceling.

    Thing is, in the general leakcanary case we don't always need the string reason.

    Then we trigger. We also need to pull a directory id. That requires doing additional prework like saving android ids, storing the dump timestamp.

    Getting a file might fail. Dumping might fail.

    There's some notion of parallel threads and multiple jobs here. Every time we get a request to trigger, we should store that, and make it possible for anyone to cancel that request / all requests at any time. Maybe the request has a stage? but maybe not because we want decoupling.

    heap dump directory: releases want to have some control over the file itself and delete it immediately. also wants to run GC. but not check for retained.

    After the heap is dumped, we migth want to analyze it, and even double analyze. Might want to send it to another process. etc.

    We're essentially sending a file to the thing.

    type: enhancement 
    opened by pyricau 0
  • AndroidJUnitRunner cannot find extra class com.squareup.leakcanary.FailTestOnLeakRunListener

    AndroidJUnitRunner cannot find extra class com.squareup.leakcanary.FailTestOnLeakRunListener

    Description

    I am trying to run leak canary along with my Android Instrumentation tests. I followed the LeakCanary documentation https://square.github.io/leakcanary/upgrading-to-leakcanary-2.0/#running-leakcanary-in-instrumentation-tests

    However, the instrumentation test app fails to start with the following error:

    java.lang.RuntimeException: Exception thrown in onCreate() of ComponentInfo{<app component>/androidx.test.runner.AndroidJUnitRunner}: java.lang.IllegalArgumentException: Could not find extra class com.squareup.leakcanary.FailTestOnLeakRunListener
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6709)
            at android.app.ActivityThread.access$1300(ActivityThread.java:237)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
            at android.os.Handler.dispatchMessage(Handler.java:106)
            at android.os.Looper.loop(Looper.java:223)
            at android.app.ActivityThread.main(ActivityThread.java:7656)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
    

    Steps to Reproduce

    Project build.gradle contains the following:

    dependencies {
        compileOnly 'org.projectlombok:lombok:1.18.12'
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation 'androidx.annotation:annotation:1.0.0'
        implementation 'androidx.core:core:1.0.0'
        implementation 'androidx.appcompat:appcompat:1.2.0'
        implementation 'com.github.bumptech.glide:glide:4.6.1'
        testImplementation 'junit:junit:4.12'
        testImplementation 'org.robolectric:robolectric:4.2'
        testImplementation 'org.robolectric:shadows-httpclient:4.2'
        testImplementation 'androidx.test:core:1.1.0'
        testImplementation 'org.mockito:mockito-core:2.25.0'
        androidTestImplementation 'org.mockito:mockito-core:2.25.0'
        androidTestImplementation 'androidx.test.ext:junit:1.1.0'
        androidTestImplementation 'androidx.annotation:annotation:1.0.0'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
        androidTestImplementation 'androidx.test:runner:1.1.1'
        androidTestImplementation 'androidx.test:rules:1.1.1'
        androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
        androidTestImplementation 'com.linkedin.dexmaker:dexmaker:2.25.0'
        androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito:2.25.0'
        testImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
        androidTestImplementation 'com.squareup.leakcanary:leakcanary-android-instrumentation:2.9.1'
        androidTestUtil 'androidx.test:orchestrator:1.1.1'
        api "com.google.auto.value:auto-value-annotations:1.7"
        api 'com.google.guava:guava:27.0.1-jre'
        annotationProcessor "com.google.auto.value:auto-value:1.7"
        annotationProcessor 'org.projectlombok:lombok:1.18.12'
    }
    
    android {
        compileSdkVersion 31
        ndkVersion "23.0.7599858"
        buildToolsVersion "30.0.2"
        defaultConfig {
            minSdkVersion 22
            targetSdkVersion 31
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
            testInstrumentationRunnerArguments clearPackageData: 'true'
            testInstrumentationRunnerArgument "listener", "com.squareup.leakcanary.FailTestOnLeakRunListener"
            renderscriptTargetApi 22
        }
    }
    

    Expected behavior: The instrumentation tests should start and execute.

    Version Information

    • LeakCanary version: 2.9.1
    • Android OS version: 31
    • Gradle version: 6.8.1
    type: documentation 
    opened by sourabhdas1991 1
Releases(v2.9.1)
An app performance monitor(APM) , like "Android Studio profiler", you can easily monitor the performance of your app real time in browser

AndroidGodEye English README.md 中文 README_zh.md Android developer lack of monitoring of performance data,especially in production environment. so we n

AndroidKy 2.5k Sep 20, 2022
Android TextView with rich support of compound drawables

TextViewRichDrawable This is a tiny library which empowers TextView's (and its inheritors) compound drawables with size specifying, vector support and

Oleksandr Tolstykh 135 Jul 13, 2022
A simple plugin to patch the memory leak in Kotlin Gradle Plugin 1.5.0

kgp-150-leak-patcher A simple plugin to automatically patch the memory leak in Kotlin Gradle Plugin 1.5.0 in https://youtrack.jetbrains.com/issue/KT-4

Zac Sweers 40 Dec 20, 2021
Reproducible sample with Fix for Memory Leak in RecyclerView Adapter

Memory Leak RecyclerView Adapter Reproducible Sample with Fix Video Instructions: https://www.youtube.com/c/awesomedevnotes Code Only the relevant and

Awesome Dev Notes | Android Dev Notes YouTube 7 Jun 7, 2022
☯️Sophisticated and cool intro with Material Motion Animations(No more viewpager transformer or Memory leak)

Material Intro Sophisticated and cool intro with Material Motion Animations. Who's using Material Intro? ?? Check out who's using Material Intro Inclu

Ranbir Singh 34 Sep 8, 2022
Glide Bitmap Pool is a memory management library for reusing the bitmap memory

Glide Bitmap Pool About Glide Bitmap Pool Glide Bitmap Pool is a memory management library for reusing the bitmap memory. As it reuses bitmap memory ,

AMIT SHEKHAR 572 Sep 10, 2022
A sample project in Kotlin to demonstrate AndroidX, MVVM, Coroutines, Hilt, Room, Data Binding, View Binding, Retrofit, Moshi, Leak Canary and Repository pattern.

This repository contains a sample project in Kotlin to demonstrate AndroidX, MVVM, Coroutines, Hilt, Room, Data Binding, View Binding, Retrofit, Moshi, Leak Canary and Repository pattern

Areg Petrosyan 36 Sep 18, 2022
A sample project in Kotlin to demonstrate Jetpack Compose, MVVM, Coroutines, Hilt, Room, Coil, Retrofit, Moshi, Leak Canary and Repository pattern

Jetpack-Compose-Boilerplate This repository contains a sample project in Kotlin to demonstrate Jetpack Compose, MVVM, Coroutines, Hilt, Room, Coil, Re

Areg Petrosyan 11 Aug 24, 2022
With Viola android face detection library, you can detect faces in a bitmap, crop faces using predefined algorithm and get additional information from the detected faces.

Viola Viola android face detection library detects faces automatically from a bitmap, crop faces using the predefined algorithms, and provides supplem

Darwin Francis 57 Sep 7, 2022
An Android library for managing images and the memory they use.

Fresco Fresco is a powerful system for displaying images in Android applications. Fresco takes care of image loading and display, so you don't have to

Facebook 16.9k Sep 20, 2022
Memory efficient android library for managing individual fragment backstack.

fragstack : Android library for managing individual fragment backstack. An Easy to use library for managing individual fragment back stack as Instagra

Abhishesh 21 Feb 6, 2021
Android device shake detection.

Seismic Android device shake detection. Download Download the latest .jar or depend via Maven: <dependency> <groupId>com.squareup</groupId> <artif

Square 1.2k Sep 18, 2022
[Android] Screenshot detection while user using your app

[Android] Screenshot detection while user using your app

Akexorcist 134 Sep 8, 2022
An Android project containing image recognition and object detection models.

An Android project containing image recognition and object detection models. Users can input images into the deep learning model by taking photos, opening photo albums, and real-time previews on the Android side. After the calculation on the Android side is completed, the model will output the prediction result and show it to the user.

null 6 Feb 26, 2022
TensorFlow Lite Object Detection Android Demo

GSoC Project 2021 - TensorFlow Description This repository contains the project where I contributed to the TensorFlow Team during GSoC in the year 202

Sayan Nath 4 Jul 18, 2022
A sample project of implementing Liveness Detection and Identity OCR on Android app using Kredibel Vision SDK

Vision Sample (Android) A sample project of implementing Liveness Detection and Identity OCR on Android app using Kredibel Vision SDK. You can checkou

null 9 Aug 4, 2022
Based on Android + NodeMCU platform to achieve object detection and tracking, AI capabilities come from Google MLKit.

Based on Android + NodeMCU platform to achieve object detection and tracking, AI capabilities come from Google MLKit.

null 1 Apr 4, 2022
compaKTset is a small library aimed at providing you with the most memory efficient Set implementation for any particular data type of your choosing.

compaKTset is a small library aimed at providing you with the most memory efficient Set implementation for any particular data type of your choosing.

Ignat Beresnev 3 Nov 16, 2021
A Kotlin library providing a simple, high-performance way to use off-heap native memory in JVM applications.

native_memory_allocator A library which uses sun.misc.Unsafe to allocate off-heap native memory. Motivation The goal of this project is to provide a s

Target 4 Jun 27, 2022