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)
誰有解決方法,發給我謝謝
問題解答
回答1:看這個log并不能發現什么,圖片加載出現oom是非常高概率的。請仔細判斷1)是否連續的加載了大圖而沒有及時回收?2)是否哪里內存泄漏了?可以嘗試用LeakCanary檢查下內存泄漏,或者用工具持續檢查內存占用狀況
相關文章:
1. javascript - 原生canvas中如何獲取到觸摸事件的canvas內坐標?2. sql語句 - mysql中關聯表查詢問題3. javascript - iframe 為什么加載網頁的時候滾動條這樣顯示?4. javascript - vscode alt+shift+f 格式化js代碼,通不過eslint的代碼風格檢查怎么辦。。。5. javascript - [js]為什么畫布里不出現圖片呢?在線等6. javascript - 有什么比較好的網頁版shell前端組件?7. javascript - 求解答:實例對象調用constructor,此時constructor內的this的指向?8. javascript - 如何將一個div始終固定在某個位置;無論屏幕和分辨率怎么變化;div位置始終不變9. css - chrome下a標簽嵌套img 顯示會多個小箭頭?10. html - vue項目中用到了elementUI問題
