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. 數據庫 - MySQL 單表500W+數據,查詢超時,如何優化呢?2. python - Django分頁和查詢參數的問題3. 求大神幫我看看是哪里寫錯了 感謝細心解答4. MySQL客戶端吃掉了SQL注解?5. 網頁爬蟲 - python爬蟲翻頁問題,請問各位大神我這段代碼怎樣翻頁,還有價格要登陸后才能看到,應該怎么解決6. javascript - 圖片能在網站顯示,但控制臺仍舊報錯403 (Forbidden)7. php自學從哪里開始?8. mysql - AttributeError: ’module’ object has no attribute ’MatchType’9. android - Windows系統下運行react-native App時,報下面的錯誤?10. phpstady在win10上運行
