smallseo.info

leakcanary

A memory leak detection library for Android and Java.

aapt finished with non-zero exit value 1

Recently I'm trying to use LeakCanary to fix OOM(out of memory) issues for my Android app. And I added

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

to my build.gradle, following the instructions on LeakCanary website. After gradle build, I got

"/android-sdk/android-sdk_r22.6.2-linux/build-tools/21.1.1/aapt'' finished with non-zero exit value 1 

This is part of my build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.1'
    }
}

apply plugin: 'android'
apply plugin: 'maven'

android {
    compileSdkVersion 19
    buildToolsVersion '22.0.1'

    defaultConfig {
        multiDexEnabled true
    }

    lintOptions {
        abortOnError false
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            assets.srcDirs = ['assets']
            res.srcDirs = ['res']
        }

        instrumentTest.setRoot('tests')
    }

    dexOptions {
        jumboMode = true
        preDexLibraries = false
        javaMaxHeapSize = '2g'
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
}

repositories {
    flatDir {
        dirs 'libs'
    }
    maven {
        url "http://XXXXX/nexus/content/repositories/releases"
    }
}

dependencies {

    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile(name: 'ShortcutBadger-1.0.1', ext: 'aar')
    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
}

Source: (StackOverflow)

Cant build Gradle for LeakCanary library

I tried to build Gradle:

Executing command: "--stacktrace"

FAILURE: Build failed with an exception.

  • Where: Build file 'H:\Nin_in_the_winD\working.space\development\branch\eazy\build.gradle' line: 2

  • What went wrong: A problem occurred evaluating root project 'eazy'.

    Could not find method debugCompile() for arguments [com.squareup.leakcanary:leakcanary-android:1.3.1@aar] on root project 'eazy'.

  • Try: Run with --info or --debug option to get more log output.

  • Exception is: org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'eazy'. at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:76) at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$1.run(DefaultScriptPluginFactory.java:148) at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:156) at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39) at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26) at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34) at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55) at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:487) at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:85) at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42) at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106) at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86) at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90) at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28) at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:50) at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:27) at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40) at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210) at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35) at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169) at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33) at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22) 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:54) at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35) at org.gradle.launcher.GradleMain.main(GradleMain.java:23) Caused by: org.gradle.api.internal.MissingMethodException: Could not find method debugCompile() for arguments [com.squareup.leakcanary:leakcanary-android:1.3.1@aar] on root project 'eazy'. at org.gradle.api.internal.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:68) at org.gradle.api.internal.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:56) at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:175) at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79) at build_4cypqr1onvufm2h2phqvhowz7$_run_closure1.doCall(H:\Nin_in_the_winD\working.space\development\branch\eazy\build.gradle:2) at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:67) at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130) at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91) at org.gradle.api.internal.project.AbstractProject.dependencies(AbstractProject.java:838) at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:232) at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:127) at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:150) at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79) at build_4cypqr1onvufm2h2phqvhowz7.run(H:\Nin_in_the_winD\working.space\development\branch\eazy\build.gradle:1) at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:74) ... 35 more

Here is my gradle.build:

dependencies {
  debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1@aar'
  releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1@aar'
}
repositories {
  mavenCentral()
}

Source: (StackOverflow)

Android Leak Canary Log

I am using Leaky Canary to detect memory leaks in my app. While I was able to get rid of 2-3 issues before this, I cannot figure out where the leak is from this log

11-14 18:05:05.330 32099-3554/? D/LeakCanary: In com.prism.prism:1.1:2.
11-14 18:05:05.330 32099-3554/? D/LeakCanary: * com.prism.prism.RatePicActivity_ has leaked:
11-14 18:05:05.330 32099-3554/? D/LeakCanary: * GC ROOT android.database.ContentObserver$Transport.mContentObserver
11-14 18:05:05.330 32099-3554/? D/LeakCanary: * references android.app.Activity$SettingsObserver.this$0
11-14 18:05:05.330 32099-3554/? D/LeakCanary: * leaks com.prism.prism.RatePicActivity_ instance
11-14 18:05:05.330 32099-3554/? D/LeakCanary: * Reference Key: 29bcc62a-b7e2-4d80-8cda-be2f841f19aa
11-14 18:05:05.330 32099-3554/? D/LeakCanary: * Device: samsung samsung GT-I9300 m0xx
11-14 18:05:05.330 32099-3554/? D/LeakCanary: * Android Version: 4.4.4 API: 19 LeakCanary: 1.3.1
11-14 18:05:05.330 32099-3554/? D/LeakCanary: * Durations: watch=5024ms, gc=176ms, heap dump=1129ms, analysis=12787ms
11-14 18:05:05.330 32099-3554/? D/LeakCanary: * Details:
11-14 18:05:05.330 32099-3554/? D/LeakCanary: * Instance of android.database.ContentObserver$Transport
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mContentObserver = android.app.Activity$SettingsObserver [id=0x41b22d00]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mDescriptor = java.lang.String [id=0x41913c70]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mOwner = android.database.ContentObserver$Transport [id=0x41b1a878]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mObject = 1570915608
11-14 18:05:05.330 32099-3554/? D/LeakCanary: * Instance of android.app.Activity$SettingsObserver
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   this$0 = com.prism.prism.RatePicActivity_ [id=0x41ba5aa0]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mHandler = android.os.Handler [id=0x41c45f78]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mLock = java.lang.Object [id=0x41c7c220]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mTransport = android.database.ContentObserver$Transport [id=0x41b1a878]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: * Instance of com.prism.prism.RatePicActivity_
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   onViewChangedNotifier_ = org.androidannotations.api.view.OnViewChangedNotifier [id=0x41cceb68]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   application = com.prism.prism.MyApplication_ [id=0x41b26fe0]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   backgroundImageView = android.support.v7.widget.AppCompatImageView [id=0x41ba1960]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   fragment_container = android.widget.FrameLayout [id=0x41b6f098]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mDelegate = android.support.v7.app.AppCompatDelegateImplV14 [id=0x4226a548]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mMediaController = null
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mFragments = android.support.v4.app.FragmentController [id=0x41cd05c0]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mHandler =     android.support.v4.app.FragmentActivity$1 [id=0x41c63520]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mCreated = true
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mOptionsMenuInvalidated = false
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mReallyStopped = true
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mRequestedPermissionsFromFragment = false
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mResumed = false
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mRetaining = false
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mStopped = true
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mActionBar = null
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mActivityInfo = android.content.pm.ActivityInfo [id=0x41c6ab08]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mAllLoaderManagers = android.util.ArrayMap [id=0x41cab818]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mApplication = com.prism.prism.MyApplication_ [id=0x41b26fe0]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mWindowManager = android.view.WindowManagerImpl [id=0x41c48e60]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mWindow = com.android.internal.policy.impl.PhoneWindow [id=0x41b966a0]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mUiThread = java.lang.Thread [id=0x417e1d80]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mTranslucentCallback = null
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mComponent = android.content.ComponentName [id=0x41c76c08]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mToken = android.os.BinderProxy [id=0x41c730f8]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mContainer = android.app.Activity$1 [id=0x41cffe98]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mCurrentConfig = android.content.res.Configuration [id=0x41df0360]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mDecor = null
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mTitle = java.lang.String [id=0x41b66db8]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mDefaultKeySsb = null
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mSettingsObserver = android.app.Activity$SettingsObserver [id=0x41b22d00]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mSearchManager = null
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mEmbeddedID = null
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mResultData = null
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mParent = null
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mFragments = android.app.FragmentManagerImpl [id=0x41ed3590]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mHandler = android.os.Handler [id=0x41c45f78]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mMenuInflater = null
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mImmerseModeRunnable = android.app.Activity$3 [id=0x41cebb80]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mInstanceTracker = android.os.StrictMode$InstanceTracker [id=0x41cf0dc0]
11-14 18:05:05.330 32099-3554/? D/LeakCanary: |   mInstrumentation = android.app.Instrumentation [id=0x41b26818]
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mIntent = android.content.Intent [id=0x41b19e40]
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mLastNonConfigurationInstances = null
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mLoaderManager = null
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mManagedDialogs = null
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mMainThread = android.app.ActivityThread [id=0x41b16958]
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mManagedCursors = java.util.ArrayList [id=0x41c6d948]
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mLoadersStarted = false
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mIdent = 1103360840
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mFinished = true
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mResultCode = 0
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mEnableDefaultActionBarUp = false
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mResumed = false
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mDoReportFullyDrawn = false
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mDestroyed = true
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mStartedActivity = false
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mStopped = true
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mTemporaryPause = false
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mDefaultKeyMode = 0
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mTitleColor = 0
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mTitleReady = true
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mConfigChangeFlags = 0
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mCheckedForLoaderManager = true
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mChangingConfigurations = false
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mVisibleFromClient = true
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mVisibleFromServer = true
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mChangeCanvasToTranslucent = false
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mWindowAdded = true
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mCalled = true
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mBase = uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper [id=0x41c522b8]
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mInflater = uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater [id=0x41df9618]
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mOverrideConfiguration = null
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mResources = android.content.res.XResources [id=0x41b22d80]
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mTheme = android.content.res.Resources$Theme [id=0x41c48c10]
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mThemeResource = 2131492994
11-14 18:05:05.335 32099-3554/? D/LeakCanary: |   mBase = uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper [id=0x41c522b8]
11-14 18:05:05.335 32099-3554/? E/LeakCanary: Leak result dropped because we already store 7 leak traces.

I am unable to tell where the memory leak is occurring in this case. Can someone point out how to go about identifying it?


Source: (StackOverflow)

Reading LeakCanary Log

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

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

In the doc in github, it says:

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

But I don't know how to do it.

Tx!

Here is my log.

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

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

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

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

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

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

Source: (StackOverflow)

LeakCanary's DisplayLeakActivity has leaked, any insights?

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

The reference path is as follows:

In com.chris:0.890:890.

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

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

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

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


Source: (StackOverflow)

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

The LeakCanary documentation mentions the following for handling build types:

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

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

Here is a skeleton of my current Gradle file:

android {
    ...

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

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

                qa {
                    ...
                }
            }
        }

        bar {
            buildTypes {
                ci {
                    ...
                }

                qa {
                    ...
                }
            }
        }
    }
}

Source: (StackOverflow)

Avoiding memory leak from crittercism in android

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

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

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

Source: (StackOverflow)

Memory leak by AttachInfo.mRootCallbacks reported by LeakCanary

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

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

Also opened this as an issue for canary.


Edit 1 : relevant implementation :

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

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

public static class InteractionCallbackImplementation implements MyView.InteractionCallbacks {

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

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

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

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

What I know is that when I leave the activity :

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

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

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


Source: (StackOverflow)

Memory Leak on AppCompatActivity using LeakCanary

I use LeakCanary and unfortunately got a leak and here is the logcat:

05-10 18:13:00.377    9098-9965/com.ponnex.justdrive D/LeakCanary﹕ In com.ponnex.justdrive:1.0:1.
* com.ponnex.justdrive.DebuggingActivity has leaked:
* GC ROOT static android.support.v4.content.LocalBroadcastManager.mInstance
* references android.support.v4.content.LocalBroadcastManager.mReceivers
* references java.util.HashMap.table
* references array java.util.HashMap$HashMapEntry[].[51]
* references java.util.HashMap$HashMapEntry.key
* references com.ponnex.justdrive.DebuggingActivity$3.this$0 (anonymous class extends android.content.BroadcastReceiver)
* leaks com.ponnex.justdrive.DebuggingActivity instance
* Reference Key: 4fea07d9-9369-4618-a8e0-9e63b3e1b908
* Device: samsung samsung GT-I9100 pa_i9100
* Android Version: 5.1.1 API: 22
* Durations: watch=5219ms, gc=244ms, heap dump=4978ms, analysis=19968ms

This is my DebuggingActivity

@Override
protected void onCreate(Bundle savedInstanceState) {
LeakCanary.install(getApplication());
setContentView(R.layout.activity_debugging);
activityTV = (TextView) findViewById(R.id.debugText);
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(screenReceiver, new IntentFilter("com.ponnex.justdrive.ActivityRecognitionIntentService"));

}
private BroadcastReceiver screenReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        String activity = intent.getStringExtra("Activity");
        updateUI(activity);
    }
};

public static void updateUI(String activity) {
    activityTV.setText(activity);
}

I've been checking my activity and tracing it out but I don't know how to fix this any help? :D

If you need more from my activity code I'll be glad to add or post them here ;)

---EDIT---

I also got a leak from another activity refering to snackbar(Snackbar by Nispok)

05-10 18:27:43.161   9098-16222/com.ponnex.justdrive D/LeakCanary﹕ In com.ponnex.justdrive:1.0:1.
* com.ponnex.justdrive.MainActivity has leaked:
* GC ROOT static com.nispok.snackbar.SnackbarManager.currentSnackbar
* references com.nispok.snackbar.Snackbar.mContext
* leaks com.ponnex.justdrive.MainActivity instance
* Reference Key: 1982a1a8-e66e-4218-9b5a-8f907ee26a7f
* Device: samsung samsung GT-I9100 pa_i9100
* Android Version: 5.1.1 API: 22
* Durations: watch=5291ms, gc=315ms, heap dump=4443ms, analysis=21801ms

Source: (StackOverflow)

LeakCanary - Activity is leaked as it implements SyncStatusObserver

I am using LeakCanary to identify memory leaks. I have an Activity which adds itself as the StatusChangeObserver in onResume as below:

    final int mask = ContentResolver.SYNC_OBSERVER_TYPE_PENDING |
            ContentResolver.SYNC_OBSERVER_TYPE_ACTIVE;

    mSyncObserverHandle = ContentResolver.addStatusChangeListener(mask, this);

And stops listening onPause

    ContentResolver.removeStatusChangeListener(mSyncObserverHandle);

When I exit the Activity, LeakCanary reports my Activity is leaked. Below is gist of the leak trace:

     * com.sample.android.MyListActivity has leaked:
     * GC ROOT android.content.ContentResolver$1.val$callback(anonymous class extends android.content.ISyncStatusObserver$Stub)
     * leaks com.sample.android.MyListActivity instance
     [ 06-11 15:35:23.123 11823:13392 D/LeakCanary ]
     * Reference Key: 1eaf447d-055c-4767-bb3f-56b12c7a4dae
     * Device: motorola motorola XT1022 condor_retaildsds
     * Android Version: 4.4.4 API: 19 LeakCanary: 1.3.1
     * Durations: watch=5029ms, gc=147ms, heap dump=693ms, analysis=15159ms
     [ 06-11 15:35:23.123 11823:13392 D/LeakCanary ]

I have tested on API 19 and 22. I would like to know if its a problem with my code or leakcanary or sdk.

Thanks in advance!


Source: (StackOverflow)

RxJava Observable Zip Causes Memory Leak

I am using RxJava's Observable.zip method to combine two API calls into one result. For some reason I am getting a memory leak despite the fact that I unsubscribe from the subscription. I am not sure if this a bug on my end or if there is something I need to do with the creation of the Observable.

protected void onCreate(Bundle bundle) {
...

subscription = Observable.zip(
      api.getConfiguration(),
      api.getSettings().map(r -> r.getData()),
      new Func2<ConfigurationResponse, List<Datum>, Struct>() {
        @Override
        public Struct call(ConfigurationResponse config, List<Datum> data) {
          return new Struct(data, config.getCopy(), config.getSettings());
        }
      }
    )
      .compose(Schedulers.applyApiSchedulers())
      .subscribe(
        struct -> {
          configurationManager.set(struct.data, struct.copy, struct.settings);
          startNextActivity();
        },
        error -> {
          startNextActivity();
        }
      );
}

protected void onDestroy() {
  if (!subscription.isUnsubscribed()) {
    subscription.unsubscribe();
  }
}

Here is the trace from Leak Canary.

leak trace

Any help would be appreciated.


Source: (StackOverflow)

Android Media player keeps app instance and cause a memory leak

I have an activity with a media player as a member variable.

My media player is initialized like this:

mMediaPlayer = new MediaPlayer(); 
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.setDataSource(MyActivity.this, URL); 
mMediaPlayer.prepareAsync(); 
//i set a on Prepared Listener to start playing on Prepared

Everything works just fine, and then i override my activity onStop method to release the Media Player.

if(mMediaPlayer!=null){
   if(mMediaPlayer.isPlaying()){
       mMediaPlayer.stop();
   }
   mMediaPlayer.release();
   mMediaPlayer=null;
}

But after the activity has stopped i get a memory leak report from LeakCanary.

The report is like this:

MyApp.Instance->

MyApp.mLoadedApk->

LoadedApk.mReceivers->

ArrayMap.mArray->

arrayObject[].[3]->

ArrayMap.mArray->

arrayObject[][0]->

MediaPlayer.mProxyReceiver->

MediaPlayer.mProxyContext->

leaks MyActivity instance.

MyApp.Instance->

MyApp.mLoadedApk->

LoadedApk.mReceivers->

ArrayMap.mArray->

arrayObject[].[3]->

ArrayMap.mArray->

arrayObject[][0]->

MediaPlayer.mProxyReceiver->

MediaPlayer.mProxyContext->

leaks MyActivity instance.

Yes i have a MyApp class which extends Application and i am holding a reference to MyApp instance in a static field, but i never use that reference in my activity, how can i solve this leak ?

[EDIT]

Here is the code of my Activity:

public class PlayActivity extends ActionBarActivity {

private MediaPlayer mediaPlayer;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_play);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

@Override
protected void onStop() {
    super.onStop();
    if(mediaPlayer!=null){
        if(mediaPlayer.isPlaying()){
            mediaPlayer.stop();
        }
        mediaPlayer.release();
        mediaPlayer=null;
    }
}

public void playIt(View view){
    if(mediaPlayer==null){
        mediaPlayer = new MediaPlayer();
        mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                mp.start();
            }
        });


    }
    if(!mediaPlayer.isPlaying()){
        mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        try {
            mediaPlayer.setDataSource(PlayActivity.this, Uri.parse("http://www.noiseaddicts.com/samples_1w72b820/142.mp3"));
            mediaPlayer.prepareAsync();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }



   }

 }

Source: (StackOverflow)

Cannot find symbol class AndroidExcludedRefs, DisplayLeakService,

We are declaring our leak-canary dependencies as stated on the project's Github page.

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

So far, things are working fine. Now we started to exclude a known leak like that:

ExcludedRefs.Builder excludedRefsBuilder = AndroidExcludedRefs.createAppDefaults();
excludedRefsBuilder.staticField("com.google.android.chimera.container.a", "a");
refWatcher = LeakCanary.install(app, DisplayLeakService.class, excludedRefsBuilder.build());

Now when we switch to the release build type, classes like AndroidExcludedRefs, DisplayLeakService and ExcludedRefs are not found anymore, as the "no-op" dependency doesn't include them.

What's the best way to handle this?


Source: (StackOverflow)

Android Chrome Facebook webview memory leak using Leakcanary

Randomly I'm having this leaks after performing login with Facebook Webview

enter image description here enter image description here enter image description here

I've found this (the only mention to com.android.org.chromium):

AW_RESOURCE__SRESOURCES(SAMSUNG.equals(MANUFACTURER) && SDK_INT == KITKAT) {
    @Override void add(ExcludedRefs.Builder excluded) {
      // AwResource#setResources() is called with resources that hold a reference to the
      // activity context (instead of the application context) and doesn't clear it.
      // Not sure what's going on there, input welcome.
      excluded.staticField("com.android.org.chromium.android_webview.AwResource", "sResources");
    }
  },

Inside this class AndroidExcludedRefs.java

This class is a work in progress. You can help by reporting leak traces that seem to be caused by the Android SDK, here: https://github.com/square/leakcanary/issues/new

But I'm not using Samsung so I'm still having this leak.
Said that, is this leak a known issue? Can it be ignored?

UPDATE: I was using Facebook SDK v3.19, I've updated to 4.3 but the problem remains: enter image description here


Source: (StackOverflow)

LeakCanary investigation : com.motorola.pixelpipe.PixelPipeTarget.mContext

With LeakMemory I constantly have a report on com.motorola.pixelpipe.PixelPipeTarget.mContext. I have no idea what this is. Anyone have the same report ?

Using MotoX 2014 with 5.0

LeakCanary  D  In net.ebt.appswitch:0.8.3.394:3940002.
            D  * net.ebt.appswitch.activity.AppSwapActivity has leaked:
            D  * GC ROOT com.motorola.pixelpipe.PixelPipeTarget.mContext
            D  * leaks net.ebt.appswitch.activity.AppSwapActivity instance
            D  * Reference Key: 41a91591-b7f4-4a12-b077-46b35a53f9cf
            D  * Device: motorola motorola XT1095 victara_tmo
            D  * Android Version: 5.0 API: 21
            D  * Durations: watch=5028ms, gc=187ms, heap dump=1626ms, analysis=26686ms

Thanks


Source: (StackOverflow)