A memory leak detection library for Android.

Last update: Jun 22, 2022

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.

GitHub

https://github.com/square/leakcanary
Comments
  • 1. 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
    
    Reviewed by Exaper at 2015-09-01 21:05
  • 2. #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.

    Reviewed by ToxicBakery at 2015-05-29 14:02
  • 3. 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

    Reviewed by zaur at 2015-05-09 15:03
  • 4. 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 = [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 = im.example.app.ui.extensions.customtabs.CustomTabActivityHe[email protected] (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 = [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 = android.app.ActivityManager$Tas[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)
    
    Reviewed by rafaelekol at 2017-04-18 10:49
  • 5. 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.

    Reviewed by Guneetgstar at 2020-04-25 20:22
  • 6. 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

    Reviewed by CaiJinFu at 2019-09-26 08:01
  • 7. 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 ?

    Reviewed by linggom at 2015-05-22 09:58
  • 8. 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

    Reviewed by seyedjafariy at 2018-08-06 06:08
  • 9. 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)
    
    
    Reviewed by zwang at 2017-08-09 23:16
  • 10. 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)
    
    
    Reviewed by jamesbluecrow at 2016-04-01 08:09
  • 11. 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);
        }
    
    Reviewed by a442509097 at 2017-11-23 02:23
  • 12. IllegalStateException when using showLeakDisplayActivityLauncherIcon in robolectric unit tests

    Description

    Running LeakCanary.showLeakDisplayActivityLauncherIcon(true) from Unit tests results throws java.lang.IllegalStateException: LeakCanary not installed, see AppWatcher.manualInstall()

    [StackTrace]

    java.lang.IllegalStateException: LeakCanary not installed, see AppWatcher.manualInstall()
            at leakcanary.internal.InternalLeakCanary.getApplication(InternalLeakCanary.kt:52)
            at leakcanary.internal.InternalLeakCanary.setEnabledBlocking(InternalLeakCanary.kt:324)
            at leakcanary.LeakCanary.showLeakDisplayActivityLauncherIcon(LeakCanary.kt:401)
            at com.example.leakcanaryissue.LeakCanaryInitializer.init(LeakCanaryInitializer.kt:7)
            at com.example.leakcanaryissue.MyApp.onCreate(MyApp.kt:9)
            at com.example.leakcanaryissue.TestApp.onCreate(TestApp.kt:5)
            at org.robolectric.android.internal.AndroidTestEnvironment.lambda$installAndCreateApplication$2(AndroidTestEnvironment.java:350)
            at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:86)
            at org.robolectric.android.internal.AndroidTestEnvironment.installAndCreateApplication(AndroidTestEnvironment.java:350)
            at org.robolectric.android.internal.AndroidTestEnvironment.lambda$createApplicationSupplier$0(AndroidTestEnvironment.java:229)
            at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:53)
            at org.robolectric.android.internal.AndroidTestEnvironment.lambda$createApplicationSupplier$1(AndroidTestEnvironment.java:226)
            at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:167)
            at org.robolectric.RuntimeEnvironment.getApplication(RuntimeEnvironment.java:71)
            at org.robolectric.android.internal.AndroidTestEnvironment.setUpApplicationState(AndroidTestEnvironment.java:194)
            at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:325)
            at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:265)
            at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:88)
            at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
            at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
            at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
            at java.base/java.lang.Thread.run(Thread.java:829)
    

    The Project has a LeakCanaryInitializer file which initializes LeakCanary in Debug build.

    
    object LeakCanaryInitializer {
        fun init() {
            LeakCanary.showLeakDisplayActivityLauncherIcon(true)
            LeakCanary.config = LeakCanary.config.copy(dumpHeap = true)
        }
    }
    
    

    and this is being called from the Application class onCreate method:

    open class MyApp: Application() {
        override fun onCreate() {
            super.onCreate()
            if (BuildConfig.DEBUG) {
                LeakCanaryInitializer.init()
            }
        }
    }
    
    

    For testing, the project has a class Util.kt with a single method and uses UtilTests.kt to run tests on this class. The test uses robolectric and eventually makes a call to LeakCanary.showLeakDisplayActivityLauncherIcon(true) which throws an IllegalStateException.

    Steps to Reproduce

    I've created a minimal reproducible sample here https://github.com/ShivamPokhriyal/LeakCanaryIssue. Simply run ./gradlew :app:testDebugUnitTest --info in this project and it'll throw the error. Or Open the project in Android Studio and run UtilTest unit tests.

    Expected behavior: [What you expect to happen]

    As mentioned in LeakCanary docs,

    By default, LeakCanary will look for the org.junit.Test class in your classpath and if found, will disable itself to avoid running in tests.
    

    LeakCanary should disable itself when running unit tests, so a call to showLeakDisplayActivityLauncherIcon shouldn't have thrown an exception.

    Version Information

    • LeakCanary version: 2.9.1
    • Robolectric version: 4.7

    Additional Information

    [Any additional information, configuration or data that might be necessary to reproduce the issue.] Clone this repo https://github.com/ShivamPokhriyal/LeakCanaryIssue and run ./gradlew :app:testDebugUnitTest --info

    Reviewed by ShivamPokhriyal at 2022-06-20 05:29
  • 13. Memory leak on HostApduService

    I see cumulative memory leak when app is communicating with hardware reader via NFC. I see this leak when app is running on foreground and background. I verified this leak using Leak Canary lib. I see the issue on Android 11 and 12, both are [Samsung.]

    LeakTrace information

    ┬───
        │ GC Root: Global variable in native code
        │
        ├─ android.os.Handler$MessengerImpl instance
        │    Leaking: UNKNOWN
        │    Retaining 2.0 kB in 12 objects
        │    ↓ Handler$MessengerImpl.this$0
        │                            ~~~~~~
        ├─ android.nfc.cardemulation.HostApduService$MsgHandler instance
        │    Leaking: UNKNOWN
        │    Retaining 1.4 kB in 11 objects
        │    this$0 instance of com.example.myapplication.MyHostApduService
        │    ↓ HostApduService$MsgHandler.this$0
        │                                 ~~~~~~
        ╰→ com.example.myapplication.MyHostApduService instance
        ​     Leaking: YES (ObjectWatcher was watching this because com.example.myapplication.MyHostApduService received
        ​     Service#onDestroy() callback and Service not held by ActivityThread)
        ​     Retaining 1.4 kB in 10 objects
        ​     key = 973e5c36-af36-44a5-9f2e-9304be9a989b
        ​     watchDurationMillis = 5178
        ​     retainedDurationMillis = 174
        ​     mApplication instance of android.app.Application
        ​     mBase instance of android.app.ContextImpl
       
        METADATA
       
        Build.VERSION.SDK_INT: 29
        Build.MANUFACTURER: samsung
        LeakCanary version: 2.9.1
        App process name: com.example.myapplication
        Class count: 12221
        Instance count: 115035
        Primitive array count: 83235
        Object array count: 15185
        Thread count: 22
        Heap total bytes: 14196604
        Bitmap count: 5
        Bitmap total bytes: 79173
        Large bitmap count: 0
        Large bitmap total bytes: 0
        Db 1: open /data/user/0/com.example.myapplication/databases/leaks.db
        Stats: LruCache[maxSize=3000,hits=30041,misses=74443,hitRate=28%]
        RandomAccess[bytes=3534436,reads=74443,travel=19649182613,range=17538120,size=22508266]
        Analysis duration: 26083 ms
    
    Reviewed by iPartha at 2022-06-03 07:22
  • 14. [Android 13] Question for supporting or not FGS Task Manager

    Problem description

    As you know, from Android 13, FGS task manager will be added. It allows the user to stop foreground services. https://developer.android.com/about/versions/13/changes/fgs-manager

    I found leakcanary to use foreground services in the below paths. leakcanary/internal/HeapAnalyzerService leakcanary/internal/ForegroundServiceExtractionForegroundService

    I'm wondering are there updates for Android 13?

    Potential solutions

    Support or not support FGS task manager.

    Additional information

    https://youtu.be/t1_8WSEguDY?t=648 https://developer.android.com/about/versions/13/changes/fgs-manager

    Reviewed by SeungwonLee at 2022-06-03 02:02
  • 15. LeakCanary for JVM tests

    When running JVM tests, it'd be nice to be able to use LeakAssertions.assertNoLeaks() and the associated junit test rule. Currently they're implemented in a way that can only run on an Android device, but it should be easy enough to adapt to a JVM.

    One key question is whether this should be a single artifact that loads different code at runtime based on the env, or a different artifact. The general API shape and configuration points is likely to be very similar.

    Here's an example implementation: https://github.com/cashapp/paparazzi/pull/431

    Reviewed by pyricau at 2022-05-26 19:59
  • 16. Add a fast dumper with HeapDumper API.

    Fast dump

    @pyricau As we discussed in #2047 & #2127, I add a fast dumper with HeapDumper API #2237 in KOOM v2.2.0.

    How to use it

    1. Add a dependency in your build.gradle
    dependencies {
        implementation "com.kuaishou.koom:koom-fast-dump:2.2.0"
    }
    
    1. Initialize koom fast dump and set HeapDumper, then enjoy it.
        DefaultInitTask.init(applicationContext as Application)
        LeakCanary.config = LeakCanary.config.copy(
          heapDumper = HeapDumper {
            ForkJvmHeapDumper.getInstance().dump(it.absolutePath)
          })
    

    Additional information

    1. Compatibility
    • Support Android L and above(API level >= 21)
    • Support armeabi-v7a arm64-v8a x86 x86-64
    1. Min Sdk The minSdkVersion of fast dump is 18. If the minSdkVersion of your app is lower than that, it needs to be compatible with overrideLibrary in the manifest.
      <uses-sdk tools:overrideLibrary="com.kwai.koom.fastdump, com.kwai.android.base, com.kwai.koom.base" />
    
    1. STL Support Fast dump support both shared and static libc++, if you are worried about STL conflicts, please use the static version, or you will prefer to the shared version for package size.
    dependencies {
      // In shared mode, multiple modules share the same libc++_shared.so (STL), and the package 
      // size is small, but when multiple modules depend on different STL versions, the final 
      // compilation will conflict.
      implementation "com.kuaishou.koom:koom-fast-dump:2.2.0"
      // Or in static mode, each module has its own STL, the package size is large, and there are no 
      // compilation and runtime problems.
      implementation "com.kuaishou.koom:koom-fast-dump-static:2.2.0"
    }
    
    1. Key logcat Please check logcat prefix with OOMMonitor to see if fast dump works.
    16743 16766 I OOMMonitor_ForkJvmHeapDumper: dump xxx.hprof.
    16743 16766 I OOMMonitor_ForkJvmHeapDumper: before suspend and fork.
    // The pid changes from 16743 to 16807, and the child process starts to dump
    16807 16807 I mple.leakcanar: hprof: heap dump "xxx.hprof" starting...
    // The child process dump finished, it takes 6.4s
    16807 16807 I mple.leakcanar: hprof: heap dump completed (24MB) in 6.411s objects 330914 objects with stack traces 0
    16807 16807 I JNIBridge: process 16807 will exit!
    // The main process is notified by the completion of the child process dump
    16743 16766 I OOMMonitor_ForkJvmHeapDumper: dump true, notify from pid 16807
    
    Reviewed by alhah at 2022-05-23 16:31
  • 17. Test ordering issue when using @SkipLeakDetection without Orchestrator

    Description

    Using @SkipLeakDetection to disable leak detection for some tests seems to cause non-determinism based on ordering for leak-checking tests running after the tests with leak detection disabled.

    Steps to Reproduce

    My natural test ordering results in the following:

    • Group A of tests run first, which have @SkipLeakDetection due to existing leaks
    • Group B of tests, with leak detection enabled, run after, and analyzing causes out of memory errors

    https://github.com/alexvanyo/composelife/pull/360

    That PR reveals the issue by removing my workaround (using Orchestrator to keep the state between tests more independent bypasses the ordering issue).

    Logcat
    2022-05-22 18:16:21.695 26790-26804 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Background concurrent copying GC freed 1160400(29MB) AllocSpace objects, 22(440KB) LOS objects, 13% free, 151MB/175MB, paused 408us total 323.765ms
    2022-05-22 18:16:23.571 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Starting a blocking GC Alloc
    2022-05-22 18:16:23.571 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Starting a blocking GC Alloc
    2022-05-22 18:16:23.585 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Alloc young concurrent copying GC freed 330272(7762KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 183MB/183MB, paused 1.782ms total 13.090ms
    2022-05-22 18:16:23.585 26790-26804 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  WaitForGcToComplete blocked Background on HeapTrim for 13.699ms
    2022-05-22 18:16:23.585 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Starting a blocking GC Alloc
    2022-05-22 18:16:23.757 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Clamp target GC heap from 204MB to 192MB
    2022-05-22 18:16:23.757 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Alloc concurrent copying GC freed 96608(2551KB) AllocSpace objects, 2(40KB) LOS objects, 5% free, 180MB/192MB, paused 362us total 171.501ms
    2022-05-22 18:16:23.757 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Forcing collection of SoftReferences for 32MB allocation
    2022-05-22 18:16:23.757 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Starting a blocking GC Alloc
    2022-05-22 18:16:24.196 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Clamp target GC heap from 203MB to 192MB
    2022-05-22 18:16:24.196 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Alloc concurrent copying GC freed 50989(1228KB) AllocSpace objects, 2(44KB) LOS objects, 6% free, 179MB/192MB, paused 959us total 438.752ms
    2022-05-22 18:16:24.197 26790-26804 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  WaitForGcToComplete blocked Background on HeapTrim for 610.987ms
    2022-05-22 18:16:24.197 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    W  Throwing OutOfMemoryError "Failed to allocate a 33554456 byte allocation with 13020808 free bytes and 12MB until OOM, target footprint 201326592, growth limit 201326592" (VmSize 1488580 kB)
    2022-05-22 18:16:24.197 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Starting a blocking GC Alloc
    2022-05-22 18:16:24.198 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Starting a blocking GC Alloc
    2022-05-22 18:16:24.205 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Alloc young concurrent copying GC freed 4(79KB) AllocSpace objects, 0(0B) LOS objects, 6% free, 179MB/192MB, paused 1.413ms total 7.445ms
    2022-05-22 18:16:24.206 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Starting a blocking GC Alloc
    2022-05-22 18:16:24.372 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Clamp target GC heap from 203MB to 192MB
    2022-05-22 18:16:24.373 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Alloc concurrent copying GC freed 4(16KB) AllocSpace objects, 0(0B) LOS objects, 6% free, 179MB/192MB, paused 361us total 166.407ms
    2022-05-22 18:16:24.373 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Forcing collection of SoftReferences for 32MB allocation
    2022-05-22 18:16:24.373 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Starting a blocking GC Alloc
    2022-05-22 18:16:24.648 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Clamp target GC heap from 203MB to 192MB
    2022-05-22 18:16:24.649 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    I  Alloc concurrent copying GC freed 10(16KB) AllocSpace objects, 0(0B) LOS objects, 6% free, 179MB/192MB, paused 1.351ms total 275.580ms
    2022-05-22 18:16:24.649 26790-26815 oselife.ui.tes          com.alexvanyo.composelife.ui.test    W  Throwing OutOfMemoryError "Failed to allocate a 33554456 byte allocation with 13070024 free bytes and 12MB until OOM, target footprint 201326592, growth limit 201326592" (VmSize 1488580 kB)
    2022-05-22 18:16:24.657 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  Heap Analysis failed, retrying in 10s in case the heap dump was not fully baked yet. Copy of original heap dump available at /data/user/0/com.alexvanyo.composelife.ui.test/files/copy-instrumentation_tests_2022-05-22_18-14-33_175.hprof
    2022-05-22 18:16:24.658 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  java.lang.RuntimeException: Not enough memory to allocate buffers for rehashing: 2097152 -> 4194304
    2022-05-22 18:16:24.658 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.hppc.LongLongScatterMap.allocateBuffers(LongLongScatterMap.kt:326)
    2022-05-22 18:16:24.658 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.hppc.LongLongScatterMap.allocateThenInsertThenRehash(LongLongScatterMap.kt:358)
    2022-05-22 18:16:24.658 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.hppc.LongLongScatterMap.set(LongLongScatterMap.kt:103)
    2022-05-22 18:16:24.658 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.DominatorTree.updateDominated(DominatorTree.kt:51)
    2022-05-22 18:16:24.658 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.PathFinder$VisitTracker$Dominated.visited(PathFinder.kt:63)
    2022-05-22 18:16:24.658 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.PathFinder.enqueue(PathFinder.kt:224)
    2022-05-22 18:16:24.658 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.PathFinder.findPathsFromGcRoots(PathFinder.kt:170)
    2022-05-22 18:16:24.658 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.PathFinder.findPathsFromGcRoots(PathFinder.kt:135)
    2022-05-22 18:16:24.658 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.HeapAnalyzer.findLeaks(HeapAnalyzer.kt:275)
    2022-05-22 18:16:24.658 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.HeapAnalyzer.analyzeGraph(HeapAnalyzer.kt:253)
    2022-05-22 18:16:24.658 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.HeapAnalyzer.analyze$shark(HeapAnalyzer.kt:217)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.HeapAnalyzer.analyze(HeapAnalyzer.kt:166)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at leakcanary.internal.InstrumentationHeapAnalyzer.analyze(InstrumentationHeapAnalyzer.kt:63)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at leakcanary.internal.RetryingHeapAnalyzer.analyze(RetryingHeapAnalyzer.kt:26)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at leakcanary.AndroidDetectLeaksAssert.runLeakChecks(AndroidDetectLeaksAssert.kt:80)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at leakcanary.AndroidDetectLeaksAssert.assertNoLeaks(AndroidDetectLeaksAssert.kt:34)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at leakcanary.LeakAssertions.assertNoLeaks(LeakAssertions.kt:21)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at leakcanary.DetectLeaksAfterTestSuccess$apply$1.evaluate(DetectLeaksAfterTestSuccess.kt:26)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at leakcanary.TestDescriptionHolder$wrap$1.evaluate(TestDescriptionHolder.kt:43)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    2022-05-22 18:16:24.659 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    2022-05-22 18:16:24.660 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    2022-05-22 18:16:24.660 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    2022-05-22 18:16:24.660 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:162)
    2022-05-22 18:16:24.660 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.Suite.runChild(Suite.java:128)
    2022-05-22 18:16:24.660 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.Suite.runChild(Suite.java:27)
    2022-05-22 18:16:24.660 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    2022-05-22 18:16:24.660 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    2022-05-22 18:16:24.660 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    2022-05-22 18:16:24.660 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    2022-05-22 18:16:24.660 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    2022-05-22 18:16:24.660 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    2022-05-22 18:16:24.660 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:67)
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:438)
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2205)
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  Caused by: java.lang.OutOfMemoryError: Failed to allocate a 33554456 byte allocation with 13070024 free bytes and 12MB until OOM, target footprint 201326592, growth limit 201326592
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.hppc.LongLongScatterMap.allocateBuffers(LongLongScatterMap.kt:322)
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	... 46 more
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.HeapAnalyzer.analyze$shark(HeapAnalyzer.kt:225)
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.HeapAnalyzer.analyze(HeapAnalyzer.kt:166)
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at leakcanary.internal.InstrumentationHeapAnalyzer.analyze(InstrumentationHeapAnalyzer.kt:63)
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at leakcanary.internal.RetryingHeapAnalyzer.analyze(RetryingHeapAnalyzer.kt:26)
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at leakcanary.AndroidDetectLeaksAssert.runLeakChecks(AndroidDetectLeaksAssert.kt:80)
    2022-05-22 18:16:24.661 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at leakcanary.AndroidDetectLeaksAssert.assertNoLeaks(AndroidDetectLeaksAssert.kt:34)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at leakcanary.LeakAssertions.assertNoLeaks(LeakAssertions.kt:21)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at leakcanary.DetectLeaksAfterTestSuccess$apply$1.evaluate(DetectLeaksAfterTestSuccess.kt:26)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at leakcanary.TestDescriptionHolder$wrap$1.evaluate(TestDescriptionHolder.kt:43)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:162)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.Suite.runChild(Suite.java:128)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.Suite.runChild(Suite.java:27)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    2022-05-22 18:16:24.662 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:67)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:438)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2205)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  Caused by: java.lang.RuntimeException: Not enough memory to allocate buffers for rehashing: 2097152 -> 4194304
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.hppc.LongLongScatterMap.allocateBuffers(LongLongScatterMap.kt:326)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.hppc.LongLongScatterMap.allocateThenInsertThenRehash(LongLongScatterMap.kt:358)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.hppc.LongLongScatterMap.set(LongLongScatterMap.kt:103)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.DominatorTree.updateDominated(DominatorTree.kt:51)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.PathFinder$VisitTracker$Dominated.visited(PathFinder.kt:63)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.PathFinder.enqueue(PathFinder.kt:224)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.PathFinder.findPathsFromGcRoots(PathFinder.kt:170)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.PathFinder.findPathsFromGcRoots(PathFinder.kt:135)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.HeapAnalyzer.findLeaks(HeapAnalyzer.kt:275)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.HeapAnalyzer.analyzeGraph(HeapAnalyzer.kt:253)
    2022-05-22 18:16:24.663 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.HeapAnalyzer.analyze$shark(HeapAnalyzer.kt:217)
    2022-05-22 18:16:24.664 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	... 36 more
    2022-05-22 18:16:24.664 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  Caused by: java.lang.OutOfMemoryError: Failed to allocate a 33554456 byte allocation with 13070024 free bytes and 12MB until OOM, target footprint 201326592, growth limit 201326592
    2022-05-22 18:16:24.664 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	at shark.internal.hppc.LongLongScatterMap.allocateBuffers(LongLongScatterMap.kt:322)
    2022-05-22 18:16:24.664 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  	... 46 more
    2022-05-22 18:16:24.664 26790-26815 LeakCanary              com.alexvanyo.composelife.ui.test    D  
    

    Expected behavior:

    Leak checks for tests running after the tests annotated with @SkipLeakDetection pass, just as they do when those tests are run individually. If I run just Group B, then the tests pass without any leaks detected.

    Version Information

    • LeakCanary version: 2.9.1
    • Android OS version: API 30
    • Gradle version: 7.5-rc-1

    Additional Information

    I'm not sure if this is entirely actionable, since having leaks in the first place is the real issue 🙃 . But figured I'd report an issue since debugging non-deterministic tests isn't very fun. There's also a pretty simple workaround by using Orchestrator to avoid sharing state between tests.

    Based on https://github.com/square/leakcanary/blob/7edf572f4000391e28ef74c5f1ed62aa61ffd945/leakcanary-android-instrumentation/src/main/java/leakcanary/AndroidDetectLeaksAssert.kt#L30

    It looks like when leak detection is skipped, it bypasses all of the analysis, so my guess is that leaves state around for later tests to potentially fail on. Maybe there's an opportunity to clear out that state in some way if a test is known to expose a leak?

    Reviewed by alexvanyo at 2022-05-22 17:22
An app performance monitor(APM) , like "Android Studio profiler", you can easily monitor the performance of your app real time in browser
An app performance monitor(APM) , like

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

Jun 17, 2022
Android TextView with rich support of compound drawables
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

Apr 27, 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

Dec 20, 2021
Reproducible sample with Fix for Memory Leak in RecyclerView Adapter
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

Jun 7, 2022
☯️Sophisticated and cool intro with Material Motion Animations(No more viewpager transformer or Memory leak)
☯️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

Jun 2, 2022
Glide Bitmap Pool is a memory management library for reusing the bitmap memory
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 ,

Jun 17, 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

Jun 17, 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

Jun 21, 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.
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

Jun 15, 2022
An Android library for managing images and the memory they use.
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

Jun 17, 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

Feb 6, 2021
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.

Nov 16, 2021
A Kotlin library providing a simple, high-performance way to use off-heap native memory in JVM applications.
 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

Jun 10, 2022
Android device shake detection.

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

Jun 14, 2022
[Android] Screenshot detection while user using your app
[Android] Screenshot detection while user using your app

[Android] Screenshot detection while user using your app

Jun 15, 2022
An Android project containing image recognition and object detection models.
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.

Feb 26, 2022
TensorFlow Lite Object Detection Android Demo
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

Jan 17, 2022
A sample project of implementing Liveness Detection and Identity OCR on Android app using Kredibel Vision SDK
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

Jun 18, 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.

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

Apr 4, 2022