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. nignx - docker內nginx 80端口被占用2. docker網絡端口映射,沒有方便點的操作方法么?3. docker不顯示端口映射呢?4. javascript - nodejs調用qiniu的第三方資源抓取,返回401 bad token,為什么5. angular.js - angular內容過長展開收起效果6. docker綁定了nginx端口 外部訪問不到7. java - 為什么此私有靜態變量能被訪問呢?8. dockerfile - 我用docker build的時候出現下邊問題 麻煩幫我看一下9. docker - 各位電腦上有多少個容器啊?容器一多,自己都搞混了,咋辦呢?10. thinkphp5.1學習時遇到session問題
