2

我使用的是安卓 6.0。使用以下布局 LeakCanary 发现内存泄漏:

  <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

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

4

1 回答 1

0

如果该泄漏是正确的,那么它将在库中泄漏,这是 Google 必须在支持库中修复的问题。

于 2016-03-03T18:45:54.970 回答