java - 使用glide加載圖片出現內存溢出
問題描述
Pending exception java.lang.OutOfMemoryError: Failed to allocate a 1125012 byte allocation with 784248 free bytes and 765KB until OOMcom.bumptech.glide.load.resource.bitmap.RecyclableBufferedInputStream, android.graphics.BitmapFactory$Options, com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool, int, int, int, com.bumptech.glide.load.DecodeFormat) (Downsampler.java:217)at android.graphics.Bitmap com.bumptech.glide.load.resource.bitmap.Downsampler.decode(java.io.InputStream, com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool, int, int, com.bumptech.glide.load.DecodeFormat) (Downsampler.java:151)at com.bumptech.glide.load.engine.Resource com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder.decode(java.io.InputStream, int, int) (StreamBitmapDecoder.java:50)at com.bumptech.glide.load.engine.Resource com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder.decode(java.lang.Object, int, int) (StreamBitmapDecoder.java:19)at com.bumptech.glide.load.engine.Resource com.bumptech.glide.load.resource.bitmap.ImageVideoBitmapDecoder.decode(com.bumptech.glide.load.model.ImageVideoWrapper, int, int) (ImageVideoBitmapDecoder.java:39)
誰有解決方法,發(fā)給我謝謝
問題解答
回答1:看這個log并不能發(fā)現什么,圖片加載出現oom是非常高概率的。請仔細判斷1)是否連續(xù)的加載了大圖而沒有及時回收?2)是否哪里內存泄漏了?可以嘗試用LeakCanary檢查下內存泄漏,或者用工具持續(xù)檢查內存占用狀況
相關文章:
1. html5 - ElementUI table中el-table-column怎么設置百分比顯示。2. python - 使用readlines()方法讀取文件內容后,再用for循環(huán)遍歷文件與變量匹配時出現疑難?3. 對mysql某個字段監(jiān)控的功能4. css - 網頁div區(qū)塊 像蘋果一樣可左右滑動 手機與電腦5. 注冊賬戶文字不能左右分離6. JavaScript事件7. javascript - 數組的過濾和渲染8. javascript - table列過多,有什么插件可以提供列排序和選擇顯示列的功能9. html - vue項目中用到了elementUI問題10. javascript - ES6標準入門中l(wèi)et命令提到的for循環(huán)打印i是10,如果不用let怎么替換?
