android - Memory leak by AttachInfo.mRootCallbacks reported by LeakCanary -


i'm using leakcanary library troubleshoot memory leak of activity. after fixing several issues got 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 reference mean. view keeping reference activity prevents being gced? when , how should handle it?
  2. i used eclipse memory analyze tool tool , found there no instances of activity alive. make sense?

also opened issue 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 : part of external jar handles gl rendering. has reference fragment.

public class myview extends glsurfaceview implements renderer {      private void runonuithread(runnable runnable) {           this.gethandler().post(runnable);      } } 

what know when leave activity :

  1. the activity destroyed , there no instances of activity anymore.
  2. the fragment destroyed.
  3. the view detached.

so why canary library claim - there’s leaked reference?

when , how should view lose it's reference it's context?


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -