2016-03-03 36 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