square / leakcanary

A memory leak detection library for Android.
https://square.github.io/leakcanary
Apache License 2.0
29.34k stars 3.97k forks source link

GC ROOT thread java.lang.Thread.<Java Local> (named 'GAC_Executor[1]') #778

Closed ittianyu closed 7 years ago

ittianyu commented 7 years ago

Is it a sytem issue ? It only happens on this phone.

06-01 13:41:38.361 16375-19710/co.spotchat.leap D/LeakCanary: * co.spotchat.leap.features.MainActivity has leaked:
06-01 13:41:38.361 16375-19710/co.spotchat.leap D/LeakCanary: * GC ROOT thread java.lang.Thread.<Java Local> (named 'GAC_Executor[1]')
06-01 13:41:38.361 16375-19710/co.spotchat.leap D/LeakCanary: * leaks co.spotchat.leap.features.MainActivity instance
06-01 13:41:38.361 16375-19710/co.spotchat.leap D/LeakCanary: * Retaining: 667 KB.
06-01 13:41:38.361 16375-19710/co.spotchat.leap D/LeakCanary: * Reference Key: 78255bba-fc1f-488c-ae28-840c08994925
06-01 13:41:38.361 16375-19710/co.spotchat.leap D/LeakCanary: * Device: Lenovo Lenovo Lenovo A916 A916
06-01 13:41:38.361 16375-19710/co.spotchat.leap D/LeakCanary: * Android Version: 4.4.2 API: 19 LeakCanary: 1.5.1 1be44b3
06-01 13:41:38.361 16375-19710/co.spotchat.leap D/LeakCanary: * Durations: watch=5112ms, gc=274ms, heap dump=1275ms, analysis=48012ms
06-01 13:41:38.361 16375-19710/co.spotchat.leap D/LeakCanary: * Details:
06-01 13:41:38.361 16375-19710/co.spotchat.leap D/LeakCanary: * Instance of java.lang.Thread
06-01 13:41:38.361 16375-19710/co.spotchat.leap D/LeakCanary: |   static $staticOverhead = byte[144]@1102476089 (0x41b67339)
06-01 13:41:38.361 16375-19710/co.spotchat.leap D/LeakCanary: |   static NORM_PRIORITY = 5
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   static defaultUncaughtHandler = com.mob.tools.log.MobUncaughtExceptionHandler@1110122896 (0x422b2190)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   static count = 10513
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   static MIN_PRIORITY = 1
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   static NANOS_PER_MILLI = 1000000
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   static MAX_PRIORITY = 10
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   contextClassLoader = android.app.LoadedApk$WarningContextClassLoader@1109323512 (0x421eeef8)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   vmThread = java.lang.VMThread@1112120312 (0x42499bf8)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   group = java.lang.ThreadGroup@1102535832 (0x41b75c98)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   uncaughtHandler = null
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   target = com.google.android.gms.internal.zzadd@1108394912 (0x4210c3a0)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   inheritableValues = null
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   interruptActions = java.util.ArrayList@1112076736 (0x4248f1c0)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   localValues = java.lang.ThreadLocal$Values@1111831648 (0x42453460)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   name = java.lang.String@1107696568 (0x42061bb8)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   parkBlocker = java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@1109341000 (0x421f3348)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   id = 10393
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   stackSize = 0
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   priority = 5
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   parkState = 3
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   hasBeenStarted = true
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   daemon = false
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: * Instance of co.spotchat.leap.features.MainActivity
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   static TIME_SPACE = 2000
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   static $staticOverhead = byte[72]@1109555881 (0x42227aa9)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   static ACTION_LOCATE = java.lang.String@1112718000 (0x4252bab0)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   static SHARE_APP_URL = java.lang.String@1112718632 (0x4252bd28)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   adapter = co.spotchat.leap.common.adapter.VpAdapter@1118517056 (0x42ab3740)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   bind = co.spotchat.leap.databinding.ActivityMainBinding@1119961152 (0x42c14040)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   starsAdapter = co.spotchat.leap.features.explore.map.adapter.StarsAdapter@1119925224 (0x42c0b3e8)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   connectivityChangeReceiver = co.spotchat.leap.common.receiver.ConnectivityChangeReceiver@1107244048 (0x41ff3410)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   fanIn = null
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   fanOut = null
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   fragments = java.util.ArrayList@1109357544 (0x421f73e8)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   locateReceiver = co.spotchat.leap.features.MainActivity$8@1121548616 (0x42d97948)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   mapsFragment = co.spotchat.leap.features.explore.map.MapsFragment@1120036176 (0x42c26550)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   markReadReceiver = co.spotchat.leap.features.MainActivity$9@1109269240 (0x421e1af8)
06-01 13:41:38.362 16375-19710/co.spotchat.leap D/LeakCanary: |   meFragment = co.spotchat.leap.features.me.MeFragment@1121339912 (0x42d64a08)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   notificationBadge = q.rorbin.badgeview.QBadgeView@1109059488 (0x421ae7a0)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   notificationFragment = co.spotchat.leap.features.notification.NotificationFragment@1120458168 (0x42c8d5b8)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   spotsFragment = co.spotchat.leap.features.spots.SpotsFragment@1120457984 (0x42c8d500)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   starMenuListener = co.spotchat.leap.features.MainActivity$StarMenuListener@1120808656 (0x42ce2ed0)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   unreadCount = 1
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   clickTime = 1496295639286
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mvpDelegate = com.hannesdorfmann.mosby.mvp.delegate.ActivityMvpDelegateImpl@1111413480 (0x423ed2e8)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   presenter = co.spotchat.leap.features.MainPresenter@1112005600 (0x4247dbe0)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   retainInstance = false
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mDelegate = android.support.v7.app.AppCompatDelegateImplV14@1110257336 (0x422d2eb8)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mResources = null
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mEatKeyUpEvent = false
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mThemeId = 2131427507
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mPendingFragmentActivityResults = android.support.v4.util.SparseArrayCompat@1111874952 (0x4245dd88)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mFragments = android.support.v4.app.FragmentController@1113184568 (0x4259d938)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mHandler = android.support.v4.app.FragmentActivity$1@1109095504 (0x421b7450)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mNextCandidateRequestIndex = 0
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mOptionsMenuInvalidated = false
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mCreated = true
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mReallyStopped = true
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mRequestedPermissionsFromFragment = false
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mResumed = false
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mRetaining = false
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mStopped = true
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mStartedActivityFromFragment = false
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mStartedIntentSenderFromFragment = false
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mExtraDataMap = android.support.v4.util.SimpleArrayMap@1109095480 (0x421b7438)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mActionBar = null
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mActivityInfo = android.content.pm.ActivityInfo@1110403216 (0x422f6890)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mAllLoaderManagers = android.util.ArrayMap@1110991752 (0x42386388)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mApplication = co.spotchat.leap.common.base.LeapApplication@1106663800 (0x41f65978)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mWindowManager = android.view.WindowManagerImpl@1110169952 (0x422bd960)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mWindow = com.android.internal.policy.impl.PhoneWindow@1109609144 (0x42234ab8)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mUiThread = java.lang.Thread@1102540184 (0x41b76d98)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mTranslucentCallback = null
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mComponent = android.content.ComponentName@1106894168 (0x41f9dd58)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mToken = android.os.BinderProxy@1106951504 (0x41fabd50)
06-01 13:41:38.363 16375-19710/co.spotchat.leap D/LeakCanary: |   mContainer = android.app.Activity$1@1118022496 (0x42a3ab60)
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mCurrentConfig = android.content.res.Configuration@1109523416 (0x4221fbd8)
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mDecor = null
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mTitle = java.lang.String@1108768464 (0x421676d0)
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mDefaultKeySsb = null
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mSearchManager = null
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mResultData = null
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mEmbeddedID = null
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mParent = null
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mMenuInflater = null
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mFragments = android.app.FragmentManagerImpl@1109095280 (0x421b7370)
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mHandler = android.os.Handler@1109095448 (0x421b7418)
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mManagedDialogs = null
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mInstanceTracker = android.os.StrictMode$InstanceTracker@1113472800 (0x425e3f20)
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mInstrumentation = android.app.Instrumentation@1106655464 (0x41f638e8)
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mIntent = android.content.Intent@1109541616 (0x422242f0)
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mLastNonConfigurationInstances = null
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mLoaderManager = null
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mManagedCursors = java.util.ArrayList@1109095384 (0x421b73d8)
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mMainThread = android.app.ActivityThread@1106628456 (0x41f5cf68)
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mLoadersStarted = false
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mIdent = 1114143040
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mFinished = true
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mEnableDefaultActionBarUp = false
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mResultCode = 0
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mDoReportFullyDrawn = false
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mResumed = false
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mDestroyed = true
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mStartedActivity = false
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mStopped = true
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mTemporaryPause = false
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mDefaultKeyMode = 0
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mTitleColor = 0
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mTitleReady = true
06-01 13:41:38.364 16375-19710/co.spotchat.leap D/LeakCanary: |   mConfigChangeFlags = 0
06-01 13:41:38.365 16375-19710/co.spotchat.leap D/LeakCanary: |   mCheckedForLoaderManager = true
06-01 13:41:38.365 16375-19710/co.spotchat.leap D/LeakCanary: |   mChangingConfigurations = false
06-01 13:41:38.365 16375-19710/co.spotchat.leap D/LeakCanary: |   mVisibleFromClient = true
06-01 13:41:38.365 16375-19710/co.spotchat.leap D/LeakCanary: |   mVisibleFromServer = true
06-01 13:41:38.365 16375-19710/co.spotchat.leap D/LeakCanary: |   mChangeCanvasToTranslucent = false
06-01 13:41:38.365 16375-19710/co.spotchat.leap D/LeakCanary: |   mWindowAdded = true
06-01 13:41:38.365 16375-19710/co.spotchat.leap D/LeakCanary: |   mCalled = true
06-01 13:41:38.365 16375-19710/co.spotchat.leap D/LeakCanary: |   mBase = android.app.ContextImpl@1109357608 (0x421f7428)
06-01 13:41:38.365 16375-19710/co.spotchat.leap D/LeakCanary: |   mInflater = com.android.internal.policy.impl.PhoneLayoutInflater@1110114800 (0x422b01f0)
06-01 13:41:38.365 16375-19710/co.spotchat.leap D/LeakCanary: |   mOverrideConfiguration = null
06-01 13:41:38.365 16375-19710/co.spotchat.leap D/LeakCanary: |   mResources = android.content.res.Resources@1106651608 (0x41f629d8)
06-01 13:41:38.365 16375-19710/co.spotchat.leap D/LeakCanary: |   mTheme = android.content.res.Resources$Theme@1110175952 (0x422bf0d0)
06-01 13:41:38.365 16375-19710/co.spotchat.leap D/LeakCanary: |   mThemeResource = 2131427507
06-01 13:41:38.365 16375-19710/co.spotchat.leap D/LeakCanary: |   mBase = android.app.ContextImpl@1109357608 (0x421f7428)
jrodbx commented 7 years ago

hard to say. Are you using the GoogleApiClient? Are you forgetting to unregister callbacks or disconnect the client? A minimal sample app would greatly help.

ittianyu commented 7 years ago

I have done what I can to release on destroy. But still leak.

    @SuppressWarnings("MissingPermission")
    @Override
    public void onDestroy() {
        if (null != presenter)
            presenter.onDestroy();
        RxUtils.dispose(keywordDisposable);

        locationsMap.clear();
        if (mMap != null) {
            removeMapListeners();

            if (mLocationPermissionGranted)
                mMap.setMyLocationEnabled(false);

            mMap.clear();
        }
        if (mGoogleApiClient != null) {
            mGoogleApiClient.disconnect();
            mGoogleApiClient.stopAutoManage(getActivity());
            mGoogleApiClient.unregisterConnectionCallbacks(this);
            mGoogleApiClient.unregisterConnectionFailedListener(this);
            mGoogleApiClient = null;
        }

        // should be call after map clear
        super.onDestroy();
    }
jrodbx commented 7 years ago

onDestroy isn't guaranteed to be called. Try moving your teardown logic to onStop instead, which is guaranteed to be called in API 11+. Either way, this doesn't appear to be a LeakCanary bug.

NightlyNexus commented 7 years ago

(the only case where Activity.onDestroy will not be called is when the entire process is killed, so that might not be it.)

hqzxzwb commented 5 years ago

Same thing happened to me. Only on some specific devices. Seems that Thread is storing some references in native code.