1 問題
glide加載圖片出現oom
java.lang.OutOfMemoryError: Failed to allocate a 23970828 byte allocation with 2097152 free bytes and 2MB until OOM
?
?
?
?
?
?
?
?
?
2 解決辦法
1) 簡單粗暴點的在AndroidManifest.xml添加如下,增大安卓虛擬機內存
android:largeHeap="true"
<applicationandroid:allowBackup="true"android:icon="@mipmap/guruji"android:label="@string/app_name"android:supportsRtl="true"android:largeHeap="true"android:theme="@style/AppTheme">
2)在glide里面設置禁止內存緩存和使用磁盤緩存
public static final RequestOptions requestOptions = new RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL).skipMemoryCache(true);
然后使用asDrawable代替asBitmap,drawable更省內存。?
?