I found this memory leak using leak canary, I think is related to the InputHandler. It might be a bug on Android sdk
11-23 19:14:12.267 6871-8173/com.example D/LeakCanary: * com.example.ui.record.RecordActivity has leaked:
11-23 19:14:12.267 6871-8173/com.example D/LeakCanary: * GC ROOT android.view.ViewRootImpl[.this$0 (anonymous class implements android.view.InputHandler)
11-23 19:14:12.267 6871-8173/com.example D/LeakCanary: * references android.view.ViewRootImpl.mFallbackEventHandler
11-23 19:14:12.267 6871-8173/com.example D/LeakCanary: * references com.android.internal.policy.impl.PhoneFallbackEventHandler.mContext
11-23 19:14:12.267 6871-8173/com.example D/LeakCanary: * leaks com.example.ui.record.RecordActivity instance
11-23 19:14:12.267 6871-8173/com.example D/LeakCanary: * Reference Key: f8f44240-d6e0-475e-aaa4-bd6aa90de2bd]
Source: (StackOverflow)
I'm trying to use LeakCanary to detect memory leaks in my app, but it does not go further than the message "Dumping memory, app will freeze. Brrr." I've been waiting for about 20 minutes or so, but no changes. Same behaviour on these devices:
1. Asus fonepad 8 (Android 5.0 stock)
2. Sony Xperia SP (Android 5.1.1 CM 12.1 custom)
3. HTC Desire C (Android 4.4 CM 11 custom)
I did everything as its advised in instruction:
public class ExampleApplication extends Application {
@Override public void onCreate() {
super.onCreate();
LeakCanary.install(this);
}
}
Source: (StackOverflow)
Getting an error with leak canary when doing my gradle sync:
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material'.
My build:
compileSdkVersion 17
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.assistek.ediary"
minSdkVersion 12
targetSdkVersion 12
}
dependencies {
compile 'joda-time:joda-time:2.4'
compile 'joda-time:joda-time:2.4'
compile 'joda-time:joda-time:2.2'
compile files('libs/android-support-v13.jar')
compile files('libs/commons-collections-3.2.1.jar')
compile files('libs/commons-lang-2.6.jar')
compile files('libs/commons-net-2.2.jar')
compile files('libs/ksoap2-android-assembly-2.6.0-jar-with-dependencies.jar')
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
}
Too old a builde for this library?
Source: (StackOverflow)
I've added Leak Canary to a personal Android application and the following stack trace was generated:
05-13 06:49:15.589 27088-28230/com.upwardsnorthwards.blueplaqueslondon D/LeakCanary﹕ In com.upwardsnorthwards.blueplaqueslondon:1.2:3.
* com.upwardsnorthwards.blueplaqueslondon.activities.PanoramaActivity has leaked:
* GC ROOT thread com.google.maps.api.android.lib6.gmm6.streetview.bf.v (named 'Renderer')
* references com.google.maps.api.android.lib6.gmm6.streetview.f.mParent
* references android.widget.FrameLayout.mParent
* references android.widget.FrameLayout.mContext
* leaks com.upwardsnorthwards.blueplaqueslondon.activities.PanoramaActivity instance
* Reference Key: 9d5d97cd-865a-4f93-92c1-63f7a8589525
* Device: motorola motorola XT1021 condor_tescogb
* Android Version: 4.4.4 API: 19
* Durations: watch=5024ms, gc=236ms, heap dump=745ms, analysis=39070ms
The PanoramaActivity
which is causing this has an onCreate
method which looks like:
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_panorama);
final StreetViewPanoramaFragment streetViewPanoramaFragment =
(StreetViewPanoramaFragment) getFragmentManager()
.findFragmentById(R.id.street_view_panorama);
streetViewPanoramaFragment.getStreetViewPanoramaAsync(this);
final Intent intent = getIntent();
if (intent != null) {
placemark = (Placemark) intent
.getParcelableExtra(BluePlaquesConstants.PANORAMA_CLICKED_PARCLEABLE_KEY);
}
}
The .xml layout file for this activity looks like:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/street_view_panorama"
android:name="com.google.android.gms.maps.StreetViewPanoramaFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
My gradle file for the project looks like:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.github.hotchemi:android-rate:0.4.2'
compile 'com.squareup:otto:1.3.6'
}
The full source for the application is available at https://github.com/seanoshea/BluePlaquesLondon-Android and I've created an issue to track this at https://github.com/seanoshea/BluePlaquesLondon-Android/issues/69.
Has anyone else run into this problem? Might you be able to suggest a solution?
Cheers,
Sean
Source: (StackOverflow)
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)
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.
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)
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)
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
- 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?
- 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 :
- The activity is destroyed and there are no instances of the activity anymore.
- The fragment is destroyed.
- 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)
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)
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)
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)
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)
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)
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)
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.

Any help would be appreciated.
Source: (StackOverflow)