2016-03-03 38 views
2

我正在使用Android 6.0。用下面的布局LeakCanary发现内存泄漏:EditText内存泄漏

<android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentTop="true"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="true" 
      android:src="@drawable/background"/> 

     <android.support.design.widget.TextInputLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

     <EditText 
      android:id="@+id/edittext" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hint="Simple hint" 
      android:inputType="number|textNoSuggestions" 
      android:singleLine="true" 
      android:textSize="@dimen/title_text"/> 
     </android.support.design.widget.TextInputLayout> 
    </LinearLayout> 
    </android.support.v4.widget.NestedScrollView> 

没有EditText内存泄漏了。这里是LeakCanary日志:

D/LeakCanary: * com.testapp.MainActivity has leaked: 
D/LeakCanary: * GC ROOT static android.content.res.Resources.sPreloadedDrawables 
D/LeakCanary: * references array android.util.LongSparseArray[].[0] 
D/LeakCanary: * references android.util.LongSparseArray.mValues 
D/LeakCanary: * references array java.lang.Object[].[2] 
D/LeakCanary: * references android.graphics.drawable.InsetDrawable$InsetState.mDrawableState 
D/LeakCanary: * references android.graphics.drawable.StateListDrawable$StateListState.mRes 
D/LeakCanary: * references android.support.v7.widget.TintResources.mContext 
D/LeakCanary: * leaks com.testapp.MainActivity instance 

有没有人有同样的问题?如何解决这个问题?

回答

0

如果泄漏是正确的,那么它会泄漏到图书馆中,这是Google必须在支持库中修复的东西。

+2

是的,不仅我有这个问题。 https://code.google.com/p/android/issues/detail?id=202379 – Near1999