How to fix InputMethodManager Leaks in android? -


i keep seeing inputmethodmanager leaks coming android view in login fragment in android. using leakcanary detect these. has faced these issues before , knows how fix it?

here's leak info:

in com.mymyapp.myapp2.beta.debug:2.1 * com.myapp.enterprise.registration.steps.loginfragment has leaked: * gc root android.view.inputmethod.inputmethodmanager$controlledinputconnectionwrapper.mparentinputmethodmanager * references android.view.inputmethod.inputmethodmanager.mnextservedview * references android.support.design.widget.textinputedittext.mlisteners * references java.util.arraylist.elementdata * references array java.lang.object[].[1] * references com.myapp.enterprise.registration.steps.loginfragment$1.this$0 (anonymous implementation of android.text.textwatcher) * leaks com.myapp.enterprise.registration.steps.loginfragment instance  * retaining: 447 b. * reference key: 4cc86cd2-758c-4888-9b57-67d28ff25cab * device: motorola motorola moto g (4) athene_f * android version: 7.0 api: 24 leakcanary: 1.5.1 1be44b3 * durations: watch=5235ms, gc=152ms, heap dump=2299ms, analysis=80574ms  * details: * instance of android.view.inputmethod.inputmethodmanager$controlledinputconnectionwrapper |   static $classoverhead = byte[540]@1877175625 (0x6fe36d49) |   mparentinputmethodmanager = android.view.inputmethod.inputmethodmanager@315489008 (0x12cdfaf0) |   mfinished = false |   mh = com.android.internal.view.iinputconnectionwrapper$myhandler@314608480 (0x12c08b60) |   minputconnection = android.view.inputmethod.baseinputconnection@314608192 (0x12c08a40) |   minputmethodid = null |   mlock = java.lang.object@314601304 (0x12c06f58) |   mmainlooper = android.os.looper@315147520 (0x12c8c500) |   mdescriptor = java.lang.string@1871530992 (0x6f8d4bf0) |   mobject = -1520699784 |   mowner = android.view.inputmethod.inputmethodmanager$controlledinputconnectionwrapper@315227656 (0x12c9fe08) |   shadow$_klass_ = android.view.inputmethod.inputmethodmanager$controlledinputconnectionwrapper |   shadow$_monitor_ = 0 * instance of android.view.inputmethod.inputmethodmanager |   static show_implicit = 1 |   static dispatch_not_handled = 0 |   static $classoverhead = byte[725]@1877047225 (0x6fe177b9) |   static result_shown = 2 |   static sinstance = android.view.inputmethod.inputmethodmanager@315489008 (0x12cdfaf0) |   static result_hidden = 3 |   static msg_unbind = 3 |   static not_an_action_notification_sequence_number = -1 |   static show_im_picker_mode_exclude_auxiliary_subtypes = 2 |   static result_unchanged_hidden = 1 |   static msg_set_active = 4 |   static msg_set_user_action_notification_sequence_number = 9 |   static control_window_first = 4 |   static dispatch_in_progress = -1 |   static hide_not_always = 2 |   static tag = java.lang.string@1873435512 (0x6faa5b78) |   static input_method_not_responding_timeout = 2500 |   static show_forced = 2 |   static control_window_is_text_editor = 2 |   static show_im_picker_mode_include_auxiliary_subtypes = 1 |   static control_window_view_has_focus = 1 |   static msg_bind = 2 |   static request_update_cursor_anchor_info_none = 0 |   static debug = false |   static hide_implicit_only = 1 |   static pending_event_counter = java.lang.string@1873392392 (0x6fa9b308) |   static control_start_initial = 256 |   static msg_flush_input_event = 7 |   static dispatch_handled = 1 |   static msg_send_input_event = 5 |   static show_im_picker_mode_auto = 0 |   static msg_dump = 1 |   static result_unchanged_shown = 0 |   static msg_timeout_input_event = 6 |   mactive = true |   mbindsequence = 9 |   mclient = android.view.inputmethod.inputmethodmanager$1@314607808 (0x12c088c0) |   mcompletions = null |   mcurchannel = android.view.inputchannel@320646608 (0x131cadd0) |   mcurid = java.lang.string@320729664 (0x131df240) |   mcurmethod = com.android.internal.view.iinputmethodsession$stub$proxy@320646592 (0x131cadc0) |   mcurrootview = com.android.internal.policy.decorview@319166464 (0x13061800) |   mcursender = null |   mcurrenttextboxattribute = android.view.inputmethod.editorinfo@315732752 (0x12d1b310) |   mcursoranchorinfo = null |   mcursorcandend = -1 |   mcursorcandstart = -1 |   mcursorrect = android.graphics.rect@315027712 (0x12c6f100) |   mcursorselend = 0 |   mcursorselstart = 0 |   mdummyinputconnection = android.view.inputmethod.baseinputconnection@314608192 (0x12c08a40) |   mfullscreenmode = false |   mh = android.view.inputmethod.inputmethodmanager$h@314608448 (0x12c08b40) |   mhasbeeninactive = false |   miinputcontext = android.view.inputmethod.inputmethodmanager$controlledinputconnectionwrapper@315227656 (0x12c9fe08) |   mlastbindfailed = false |   mlastsentuseractionnotificationsequencenumber = -1 |   mmainlooper = android.os.looper@315147520 (0x12c8c500) |   mnextservedview = android.support.design.widget.textinputedittext@320574464 (0x131b9400) |   mnextuseractionnotificationsequencenumber = 2 |   mpendingeventpool = android.util.pools$simplepool@314591328 (0x12c04860) |   mpendingevents = android.util.sparsearray@315027736 (0x12c6f118) |   mrequestupdatecursoranchorinfomonitormode = 0 |   mservedconnecting = false |   mservedinputconnectionwrapper = android.view.inputmethod.inputmethodmanager$controlledinputconnectionwrapper@320700984 (0x131d8238) |   mservedview = android.support.design.widget.textinputedittext@320574464 (0x131b9400) |   mservice = com.android.internal.view.iinputmethodmanager$stub$proxy@314591312 (0x12c04850) |   mtmpcursorrect = android.graphics.rect@315027688 (0x12c6f0e8) |   shadow$_klass_ = android.view.inputmethod.inputmethodmanager |   shadow$_monitor_ = 0 * instance of android.support.design.widget.textinputedittext |   static $classoverhead = byte[4196]@318885889 (0x1301d001) |   mbackgroundtinthelper = android.support.v7.widget.appcompatbackgroundhelper@320353600 (0x13183540) |   mtexthelper = android.support.v7.widget.appcompattexthelperv17@320586064 (0x131bc150) |   mallowtransformationlengthchange = false |   mautolinkmask = 0 |   mboring = null |   mbreakstrategy = 0 |   mbuffertype = android.widget.textview$buffertype@1876983128 (0x6fe07d58) |   mchangewatcher = android.widget.textview$changewatcher@320578160 (0x131ba270) |   mcharwrapper = null |   mcurhinttextcolor = -2130706433 |   mcurtextcolor = -1 |   mcurrentspellcheckerlocalecache = java.util.locale@320708816 (0x131da0d0) |   mcursordrawableres = 17303398 |   mdeferscroll = -1 |   mdesiredheightatmeasure = 136 |   mdeviceprovisionedstate = 0 |   mdrawables = android.widget.textview$drawables@317326336 (0x12ea0400) |   meditablefactory = android.text.editable$factory@1876974048 (0x6fe059e0) |   meditor = android.widget.editor@320363200 (0x13185ac0) |   mellipsize = null |   mfilters = android.text.inputfilter[1]@320581488 (0x131baf70) |   mfreezestext = false |   mgravity = 8388627 |   mhighlightcolor = 1727238656 |   mhighlightpaint = android.graphics.paint@320566528 (0x131b7500) |   mhighlightpath = android.graphics.path@320715264 (0x131dba00) |   mhighlightpathbogus = false |   mhint = null |   mhintboring = null |   mhintlayout = null |   mhinttextcolor = android.content.res.colorstatelist@315715920 (0x12d17150) |   mhorizontallyscrolling = true |   mhyphenationfrequency = 1 |   mincludepad = true |   mlastlayoutdirection = 0 |   mlastscroll = 0 |   mlayout = android.text.dynamiclayout@316962680 (0x12e47778) |   mlinktextcolor = android.content.res.colorstatelist@315160584 (0x12c8f808) |   mlinksclickable = true |   mlisteners = java.util.arraylist@320590248 (0x131bd1a8) |   mlocaleschanged = false |   mmarquee = null |   mmarqueefademode = 0 |   mmarqueerepeatlimit = 3 |   mmaxmode = 1 |   mmaxwidth = 2147483647 |   mmaxwidthmode = 2 |   mmaximum = 1 |   mminmode = 1 |   mminwidth = 0 |   mminwidthmode = 2 |   mminimum = 1 |   mmovement = android.text.method.arrowkeymovementmethod@314601176 (0x12c06ed8) |   moldmaxmode = 1 |   moldmaximum = 1 |   mpredrawlistenerdetached = false |   mpredrawregistered = false |   mpreventdefaultmovement = false |   mrestartmarquee = false |   msavedhintlayout = null |   msavedlayout = null |   msavedmarqueemodelayout = null |   mscroller = null |   mshadowcolor = 0 |   mshadowdx = 0.0 |   mshadowdy = 0.0 |   mshadowradius = 0.0 |   msingleline = true |   mspacingadd = 0.0 |   mspacingmult = 1.0 |   mspannablefactory = android.text.spannable$factory@1876974072 (0x6fe059f8) |   mtemprect = android.graphics.rect@320671576 (0x131d0f58) |   mtext = android.text.spannablestringbuilder@316625152 (0x12df5100) |   mtextcolor = android.content.res.colorstatelist@1946482152 (0x7404f5e8) |   mtextdir = android.text.textdirectionheuristics$textdirectionheuristicinternal@1876982208 (0x6fe079c0) |   mtexteditsuggestioncontainerlayout = 17367286 |   mtexteditsuggestionhighlightstyle = 16974923 |   mtexteditsuggestionitemlayout = 17367288 |   mtextpaint = android.text.textpaint@317801744 (0x12f14510) |   mtextselecthandleleftres = 17303402 |   mtextselecthandleres = 17303404 |   mtextselecthandlerightres = 17303406 |   mtransformation = android.text.method.singlelinetransformationmethod@314601392 (0x12c06fb0) |   mtransformed = android.text.method.replacementtransformationmethod$spannedreplacementcharsequence@320632600 (0x131c7718) |   musersettextscalex = false |   maccessibilitycursorposition = -1 |   maccessibilitydelegate = null |   maccessibilitytraversalafterid = -1 |   maccessibilitytraversalbeforeid = -1 |   maccessibilityviewid = -1 |   manimator = null |   mattachinfo = android.view.view$attachinfo@318798336 (0x13007a00) |   mattributes = null |   mbackground = android.graphics.drawable.insetdrawable@319232872 (0x13071b68) |   mbackgroundrendernode = android.view.rendernode@320725152 (0x131de0a0) |   mbackgroundresource = 0 |   mbackgroundsizechanged = false |   mbackgroundtint = null |   mbottom = 136 |   mcachingfailed = false |   mclipbounds = null |   mcontentdescription = null |   mcontext = com.myapp.enterprise.registration.registrationactivity@316654784 (0x12dfc4c0) |   mcurrentanimation = null |   mdrawablestate = int[4]@1870821352 (0x6f8277e8) |   mdrawingcache = null |   mdrawingcachebackgroundcolor = 0 |   mfloatingtreeobserver = null |   mforegroundinfo = null |   mframemetricsobservers = null |   mghostview = null |   mhasperformedlongpress = false |   mid = 2131755351 |   mignorenextupevent = false |   mincontextbuttonpress = false |   minputeventconsistencyverifier = null |   mkeyedtags = null |   mlabelforid = -1 |   mlastisopaque = false |   mlayerpaint = null |   mlayertype = 0 |   mlayoutinsets = null |   mlayoutparams = android.widget.framelayout$layoutparams@319233600 (0x13071e40) |   mleft = 0 |   mleftpaddingdefined = false |   mlistenerinfo = null |   mlongclickx = nan |   mlongclicky = nan |   mmatchidpredicate = null |   mmatchlabelforpredicate = null |   mmeasurecache = android.util.longsparselongarray@320670400 (0x131d0ac0) |   mmeasuredheight = 136 |   mmeasuredwidth = 984 |   mminheight = 0 |   mminwidth = 0 |   mnestedscrollingparent = null |   mnextfocusdownid = -1 |   mnextfocusforwardid = -1 |   mnextfocusleftid = -1 |   mnextfocusrightid = -1 |   mnextfocusupid = -1 |   moldheightmeasurespec = 455 |   moldwidthmeasurespec = 1073742808 |   moutlineprovider = android.view.viewoutlineprovider$1@1876974296 (0x6fe05ad8) |   moverscrollmode = 1 |   moverlay = null |   mpaddingbottom = 33 |   mpaddingleft = 12 |   mpaddingright = 12 |   mpaddingtop = 30 |   mparent = android.widget.framelayout@320573440 (0x131b9000) |   mpendingcheckforlongpress = null |   mpendingcheckfortap = null |   mperformclick = null |   mpointericon = null |   mprivateflags = 16943154 |   mprivateflags2 = 1611867688 |   mprivateflags3 = 4 |   mrecreatedisplaylist = false |   mrendernode = android.view.rendernode@319924904 (0x1311aaa8) |   mresources = android.content.res.resources@314613440 (0x12c09ec0) |   mright = 984 |   mrightpaddingdefined = false |   mrunqueue = android.view.handleractionqueue@320644752 (0x131ca690) |   mscrollcache = null |   mscrollindicatordrawable = null |   mscrollx = 0 |   mscrolly = 0 |   msendviewscrolledaccessibilityevent = null |   msendviewstatechangedaccessibilityevent = null |   msendinghoveraccessibilityevents = false |   mstartactivityrequestwho = null |   mstatelistanimator = null |   msystemuivisibility = 0 |   mtag = null |   mtempnestedscrollconsumed = null |   mtop = 0 |   mtouchdelegate = null |   mtouchslop = 48 |   mtransformationinfo = android.view.view$transformationinfo@320671408 (0x131d0eb0) |   mtransientstatecount = 0 |   mtransitionname = null |   munscaleddrawingcache = null |   munsetpressedstate = null |   muserpaddingbottom = 33 |   muserpaddingend = -2147483648 |   muserpaddingleft = 12 |   muserpaddingleftinitial = 12 |   muserpaddingright = 12 |   muserpaddingrightinitial = 12 |   muserpaddingstart = -2147483648 |   mverticalscrollfactor = 0.0 |   mverticalscrollbarposition = 0 |   mviewflags = 405028865 |   mwindowattachcount = 1 |   shadow$_klass_ = android.support.design.widget.textinputedittext |   shadow$_monitor_ = 0 * instance of java.util.arraylist |   static $classoverhead = byte[460]@1870958273 (0x6f848ec1) |   static empty_elementdata = java.lang.object[0]@1870221960 (0x6f795288) |   static default_capacity = 10 |   static max_array_size = 2147483639 |   static serialversionuid = 8683452581122892189 |   elementdata = java.lang.object[10]@319233656 (0x13071e78) |   size = 2 |   modcount = 2 |   shadow$_klass_ = java.util.arraylist |   shadow$_monitor_ = 0 * array of java.lang.object[] |   [0] = android.support.design.widget.textinputlayout$1@320578240 (0x131ba2c0) |   [1] = com.myapp.enterprise.registration.steps.loginfragment$1@319186144 (0x130664e0) |   [2] = null |   [3] = null |   [4] = null |   [5] = null |   [6] = null |   [7] = null |   [8] = null |   [9] = null * instance of com.myapp.enterprise.registration.steps.loginfragment$1 |   static $change = null |   static $classoverhead = byte[328]@317118193 (0x12e6d6f1) |   static serialversionuid = 0 |   this$0 = com.myapp.enterprise.registration.steps.loginfragment@317871008 (0x12f253a0) |   shadow$_klass_ = com.myapp.enterprise.registration.steps.loginfragment$1 |   shadow$_monitor_ = 0 * instance of com.myapp.enterprise.registration.steps.loginfragment |   static $classoverhead = byte[964]@316739585 (0x12e11001) |   static min_password_length = 8 |   static $change = null |   static max_password_length = 26 |   static serialversionuid = 0 |   emailok = false |   errortextview = android.support.v7.widget.appcompattextview@320600064 (0x131bf800) |   forgotpasswordbutton = android.support.v7.widget.appcompatbutton@320603136 (0x131c0400) |   loginregisterbutton = android.support.v7.widget.appcompatbutton@320601088 (0x131bfc00) |   mpasswordwatcher = com.myapp.enterprise.registration.steps.loginfragment$2@319186160 (0x130664f0) |   musernamewatcher = com.myapp.enterprise.registration.steps.loginfragment$1@319186144 (0x130664e0) |   passwordedittext = android.support.design.widget.textinputedittext@320599040 (0x131bf400) |   passwordok = false |   usernameedittext = android.support.design.widget.textinputedittext@320574464 (0x131b9400) |   usernamelayout = android.support.design.widget.textinputlayout@320572416 (0x131b8c00) |   registrationinterface = com.myapp.enterprise.registration.registrationactivity@316654784 (0x12dfc4c0) |   madded = true |   manimationinfo = null |   marguments = null |   mbackstacknesting = 0 |   mcalled = true |   mcheckedforloadermanager = true |   mchildfragmentmanager = android.support.v4.app.fragmentmanagerimpl@317804096 (0x12f14e40) |   mchildnonconfig = null |   mcontainer = android.support.v7.widget.contentframelayout@319220736 (0x1306ec00) |   mcontainerid = 16908290 |   mdeferstart = false |   mdetached = false |   mfragmentid = 16908290 |   mfragmentmanager = android.support.v4.app.fragmentmanagerimpl@317317632 (0x12e9e200) |   mfromlayout = false |   mhasmenu = false |   mhidden = false |   mhiddenchanged = false |   mhost = android.support.v4.app.fragmentactivity$hostcallbacks@319197776 (0x13069250) |   minlayout = false |   mindex = 0 |   minnerview = android.widget.linearlayout@320559104 (0x131b5800) |   misnewlyadded = false |   mloadermanager = null |   mloadersstarted = true |   mmenuvisible = true |   mparentfragment = null |   mpostponedalpha = 0.0 |   mremoving = false |   mrestored = true |   mretaininstance = false |   mretaining = false |   msavedfragmentstate = null |   msavedviewstate = null |   mstate = 5 |   mtag = java.lang.string@317199808 (0x12e815c0) |   mtarget = null |   mtargetindex = -1 |   mtargetrequestcode = 0 |   muservisiblehint = true |   mview = android.widget.linearlayout@320559104 (0x131b5800) |   mwho = java.lang.string@319178112 (0x13064580) |   shadow$_klass_ = com.myapp.enterprise.registration.steps.loginfragment |   shadow$_monitor_ = 0 * excluded refs: | field: android.view.textservice.spellcheckersession$1.this$0 | field: android.view.choreographer$framedisplayeventreceiver.mmessagequeue (always) | thread:finalizerwatchdogdaemon (always) | thread:main (always) | thread:leakcanary-heap-dump (always) | class:java.lang.ref.weakreference (always) | class:java.lang.ref.softreference (always) | class:java.lang.ref.phantomreference (always) | class:java.lang.ref.finalizer (always) | class:java.lang.ref.finalizerreference (always) 

i not using anonymous references textwatcher. separating out avoid leaks. still see leak come through textview? not sure how resolve this? has clues or has experienced before?

follow step step can solve link:- https://medium.com/@amitshekhar/android-memory-leaks-inputmethodmanager-solved-a6f2fe1d1348


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -