AndroidLeakFixes

enum AndroidLeakFixes : Enum<AndroidLeakFixes>

A collection of hacks to fix leaks in the Android Framework and other Google Android libraries.

Entries

SPELL_CHECKER
Link copied to clipboard

Every editable TextView has an Editor instance which has a SpellChecker instance. SpellChecker is in charge of displaying the little squiggle spans that show typos. SpellChecker starts a SpellCheckerSession as needed and then closes it when the TextView is detached from the window. A SpellCheckerSession is in charge of communicating with the spell checker service (which lives in another process) through TextServicesManager.

IMM_CUR_ROOT_VIEW
Link copied to clipboard

When an activity is destroyed, the corresponding ViewRootImpl instance is released and ready to be garbage collected. Some time after that, ViewRootImpl#W receives a windowfocusChanged() callback, which it normally delegates to ViewRootImpl which in turn calls InputMethodManager#onPreWindowFocus which clears InputMethodManager#mCurRootView.

IMM_FOCUSED_VIEW
Link copied to clipboard

Fix for https://code.google.com/p/android/issues/detail?id=171190 .

VIEW_LOCATION_HOLDER
Link copied to clipboard

In Android P, ViewLocationHolder has an mRoot field that is not cleared in its clear() method. Introduced in https://github.com/aosp-mirror/platform_frameworks_base/commit /86b326012813f09d8f1de7d6d26c986a909d

ACTIVITY_MANAGER
Link copied to clipboard

Samsung added a static mContext field to ActivityManager, holding a reference to the activity.

LAST_HOVERED_VIEW
Link copied to clipboard

mLastHoveredView is a static field in TextView that leaks the last hovered view.

BUBBLE_POPUP
Link copied to clipboard

A static helper for EditText bubble popups leaks a reference to the latest focused view.

SAMSUNG_CLIPBOARD_MANAGER
Link copied to clipboard

ClipboardUIManager is a static singleton that leaks an activity context. This fix makes sure the manager is called with an application context.

CONNECTIVITY_MANAGER
Link copied to clipboard

ConnectivityManager has a sInstance field that is set when the first ConnectivityManager instance is created. ConnectivityManager has a mContext field. When calling activity.getSystemService(Context.CONNECTIVITY_SERVICE) , the first ConnectivityManager instance is created with the activity context and stored in sInstance. That activity context then leaks forever.

ACCESSIBILITY_NODE_INFO
Link copied to clipboard

Until API 28, AccessibilityNodeInfo has a mOriginalText field that was not properly cleared when instance were put back in the pool. Leak introduced here: https://android.googlesource.com/platform/frameworks/base/+ /193520e3dff5248ddcf8435203bf99d2ba667219%5E%21/core/java/android/view/accessibility /AccessibilityNodeInfo.java

FLUSH_HANDLER_THREADS
Link copied to clipboard

HandlerThread instances keep local reference to their last handled message after recycling it. That message is obtained by a dialog which sets on an OnClickListener on it and then never recycles it, expecting it to be garbage collected but it ends up being held by the HandlerThread.

USER_MANAGER
Link copied to clipboard

Obtaining the UserManager service ends up calling the hidden UserManager.get() method which stores the context in a singleton UserManager instance and then stores that instance in a static field.

TEXT_LINE_POOL
Link copied to clipboard

This flushes the TextLine pool when an activity is destroyed, to prevent memory leaks.

MEDIA_SESSION_LEGACY_HELPER
Link copied to clipboard

MediaSessionLegacyHelper is a static singleton and did not use the application context. Introduced in android-5.0.1_r1, fixed in Android 5.1.0_r1. https://github.com/android/platform_frameworks_base/commit/ 9b5257c9c99c4cb541d8e8e78fb04f008b1a9091

Types

Companion
Link copied to clipboard
object Companion

Properties

name
Link copied to clipboard
val name: String
ordinal
Link copied to clipboard
val ordinal: Int